Exemple #1
0
        // called when any of the bot leaves a guild
        private Task Bot_GuildDeleted(DiscordClient sender, GuildDeleteEventArgs e)
        {
            // remove the guild from the bot's guild collection
            GuildQueue guild = BotSettings.BotGuilds.FirstOrDefault(xbg => xbg.Id == e.Guild.Id);;

            BotSettings.BotGuilds.Remove(guild);
            return(Task.CompletedTask);
        }
Exemple #2
0
 // Check for or build Bot Category and Bot Channel
 private void CheckForCategoryAndChannel(GuildQueue guildQueue)
 {
     try
     {
         DiscordChannel discordCat = (from c in guildQueue.Guild.Channels.Values
                                      where (c.Name.ToLower() == GameConst.GUILD_CATEGORY_NAME.ToLower() &&
                                             c.IsCategory)
                                      select c).FirstOrDefault();
         if (discordCat == default)
         {
             Task <DiscordChannel> task = guildQueue.Guild.CreateChannelCategoryAsync("Bot");
             task.Wait();
             guildQueue.discordCategory = task.Result;
         }
         else
         {
             guildQueue.discordCategory = discordCat;
         }
         DiscordChannel discordChan = (from c in guildQueue.Guild.Channels.Values
                                       where (c.Name == GameConst.GUILD_CHANNEL_NAME &&
                                              !c.IsCategory)
                                       select c).FirstOrDefault();
         if (discordChan == default)
         {
             Task <DiscordChannel> task = guildQueue.Guild.CreateChannelAsync(
                 GameConst.GUILD_CHANNEL_NAME,
                 ChannelType.Text,
                 guildQueue.discordCategory);
             task.Wait();
             guildQueue.discordChannel = task.Result;
         }
         else
         {
             guildQueue.discordChannel = discordChan;
         }
         BotSettings.BotGuilds.Add(guildQueue);
     }
     catch (Exception e)
     {
         BotSettings.BotLogErrorList.Add(new BotLogError(e));
     }
 }