Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 private Task Client_GuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e)
 {
     return(Task.Delay(0));
 }
Ejemplo n.º 4
0
 private Task OnGuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e)
 {
     e.Client.DebugLogger.LogMessage(LogLevel.Info, "Silk!", $"Guild available: {e.Guild.Name}", DateTime.Now);
     return(Task.CompletedTask);
 }