예제 #1
0
        public virtual Task UseLeft(SocketGuildUser user)
        {
            try
            {
                
                var conf =   confmngr.GetServersConfigurationById(this.mdconv.IGuildToBotGearServer(user.Guild).Id).Result;
                if (conf != null && conf.welcome_channel_name!=null )
                {
                    var channel = user.Guild.TextChannels.First(x => x.Name == conf.welcome_channel_name);
                    if (channel != null && user.IsBot == false)
                    {
                        channel.SendMessageAsync(String.Format("Bye {0} ", user.Mention));
                    }
                }
                else
                {

                    /*var channel = user.Guild.DefaultChannel;

                    if (channel != null && user.IsBot == false)
                    {
                        channel.SendMessageAsync(String.Format("Bye {0} ", user.Mention));
                    }*/
                }
                
                return Task.CompletedTask;
            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);
                return Task.CompletedTask;
            }
        }
예제 #2
0
        public async Task SetRulesChannel(string rulechannelname)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(rulechannelname) != true)
                {
                    String serverid = Convert.ToString(this.Context.Guild.Id);
                    if (await srvConfmngr.ServersConfigurationExists(serverid) == true &&
                        await srvmngr.ServerExists(serverid) == true)
                    {
                        var oldconf = await srvConfmngr.GetServersConfigurationById(serverid);

                        oldconf.rules_channel_name = rulechannelname;
                        await srvConfmngr.EditServerConfiguration(serverid, oldconf);
                        await ReplyAsync("Rule Channel had been Set");
                    }
                    else if (await srvConfmngr.ServersConfigurationExists(serverid) == true &&
                             await srvmngr.ServerExists(serverid) != true)
                    {
                        var oldconf = await srvConfmngr.GetServersConfigurationById(serverid);

                        oldconf.rules_channel_name = rulechannelname;
                        await srvConfmngr.EditServerConfiguration(serverid, oldconf);

                        await srvmngr.addServer(this.Context.Guild);
                        await ReplyAsync("Rule Channel had been Set");
                    }
                    else if (await srvConfmngr.ServersConfigurationExists(serverid) != true && await srvmngr.ServerExists(serverid) == true)
                    {
                        BotGearServerConfiguration conf = new BotGearServerConfiguration();
                        conf.ServerId           = serverid;
                        conf.rules_channel_name = rulechannelname;
                        await this.srvConfmngr.AddServerConfiguration(conf);
                        await ReplyAsync("Rule Channel had been Set");
                    }

                    else
                    {
                        await srvmngr.addServer(this.Context.Guild);

                        BotGearServerConfiguration conf = new BotGearServerConfiguration();
                        conf.ServerId           = serverid;
                        conf.rules_channel_name = rulechannelname;
                        await this.srvConfmngr.AddServerConfiguration(conf);
                        await ReplyAsync("Rule Channel had been Set");
                    }
                }
            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);
            }
        }