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); }
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); }
private Task Client_GuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e) { return(Task.Delay(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); }