예제 #1
0
        private Task Discord_GuildCreated(DSharpPlus.EventArgs.GuildCreateEventArgs e)
        {
            discord.DebugLogger.LogMessage(LogLevel.Info, "DGAssistant", "Joined new server, creating default config", DateTime.Now);
            ServerSetting defset = new ServerSetting {
                AnnounceChannelId = e.Guild.GetDefaultChannel().Id
            };

            SettingsManager.Cfg.ServerSettings.Add(e.Guild.Id, defset);
            return(Task.CompletedTask);
        }
예제 #2
0
 private async Task Client_GuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e)
 {
     gotOneServer = true;
     var tokenSourceToken = _tokenSource.Token;
     await Task.Factory.StartNew(async() =>
     {
         var lastCount = e.Client.Guilds.Count;
         await Task.Delay(250, tokenSourceToken);
         if (lastCount == e.Client.Guilds.Count) // download finished?
         {
             if (tokenSourceToken.IsCancellationRequested)
             {
                 return;
             }
             _tokenSource.Cancel();
             DiscordManager.Client.GuildAvailable -= Client_GuildAvailable;
             while (true)
             {
                 var count = DiscordManager.Client.Guilds.Values.Count(s => s.Name != null);
                 if (count != lastCount)
                 {
                     await Dispatcher.InvokeAsync(() =>
                     {
                         ProgressBar.Value = 50 + ((double)count / lastCount) * 50;
                         StatusText.Text   = $"Getting servers' names ({count}/{lastCount})";
                     });
                 }
                 else
                 {
                     break;
                 }
                 await Task.Delay(125);
             }
             await DoneDispatcher();
         }
     }, tokenSourceToken);
 }
예제 #3
0
 private Task Client_GuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e)
 {
     return(Task.Delay(0));
 }
예제 #4
0
파일: Bot.cs 프로젝트: TrueBoxGuy/SilkBot
 private Task OnGuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e)
 {
     e.Client.DebugLogger.LogMessage(LogLevel.Info, "Silk!", $"Guild available: {e.Guild.Name}", DateTime.Now);
     return(Task.CompletedTask);
 }