예제 #1
0
        public async Task SendGlobalUpdate([Remainder] string updateMessage)
        {
            await ReplyAsync("The global update message process has started...");

            var dbGuilds = await _guildRepo.AllAsync();

            foreach (var guild in Context.Client.Guilds)
            {
                if (dbGuilds.Exists(x => x.GuildId == guild.Id))
                {
                    var dbGuild = dbGuilds.Find(x => x.GuildId == guild.Id);
                    try
                    {
                        var channel = guild.GetChannel(dbGuild.UpdateChannelId);
                        await(channel as ITextChannel).SendAsync(updateMessage);
                    }
                    catch { }
                }
            }
            await ReplyAsync("All global update messages have been sent.");
        }
예제 #2
0
 private void Trivia(object stateObj)
 {
     Task.Run(async() =>
     {
         Logger.Log(LogSeverity.Debug, $"Timers", "Auto Trivia");
         foreach (var dbGuild in await _guildRepo.AllAsync())
         {
             if (dbGuild.AutoTrivia)
             {
                 var guild = await(_client as IDiscordClient).GetGuildAsync(dbGuild.GuildId);
                 if (guild != null)
                 {
                     var defaultChannel = await guild.GetDefaultChannelAsync();
                     try
                     {
                         await _gameService.TriviaAsync(defaultChannel, dbGuild);
                     }
                     catch { }
                 }
             }
         }
     });
 }