private static Task Client_GuildAvailable(DiscordClient client, DSharpPlus.EventArgs.GuildCreateEventArgs e) { client.Logger.Log(LogLevel.Information, new EventId(701, "GuildAvailable"), $"Guild available: {e.Guild.Name}"); return(Task.CompletedTask); }
private Task Client_GuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e) { // let's log the name of the guild that was just // sent to our client e.Client.DebugLogger.LogMessage(LogLevel.Info, "DBot", $"Guild available: {e.Guild.Name}", DateTime.Now); // since this method is not async, let's return // a completed task, so that no additional work // is done return(Task.CompletedTask); }
private Task Client_GuildAvailable(DSharpPlus.EventArgs.GuildCreateEventArgs e) { return(Task.Run(() => { if (e.Guild.Id != ContentManager.Config.SongDiscordGuildId) { return; } var rpgChannel = e.Guild.Channels.FirstOrDefault(c => c.Name == ContentManager.Config.RpgChannel); ContentManager.RpgChannel = rpgChannel ?? throw new ArgumentException("Could not find the RPG channel"); })); }
/// <summary> /// Ensures that any loaded guild is in the database. /// </summary> /// <param name="sender"></param> /// <param name="e">Discord Guild to check.</param> /// <returns></returns> private async Task _discordClient_GuildHandler(DiscordClient sender, DSharpPlus.EventArgs.GuildCreateEventArgs e) { var guild = new Guild() { Id = e.Guild.Id.ToString(), NotificationsChannel = e.Guild.GetDefaultChannel().Id.ToString() }; var filter = Builders <Guild> .Filter.Eq(x => x.Id, guild.Id); var result = (await _guildCollection.FindAsync(filter)).FirstOrDefault(); if (result == null) { await _guildCollection.InsertOneAsync(guild); } }
public static Task Client_GuildAvailable(DiscordClient sender, DSharpPlus.EventArgs.GuildCreateEventArgs e) { return(Task.CompletedTask); }
private async Task BotClient_GuildCreated(DSharpPlus.EventArgs.GuildCreateEventArgs e) { }