public async Task Leave(IUserMessage umsg, [Remainder] string guildStr) { var channel = (ITextChannel)umsg.Channel; guildStr = guildStr.Trim().ToUpperInvariant(); var server = _client.GetGuilds().FirstOrDefault(g => g.Id.ToString().Trim().ToUpperInvariant() == guildStr) ?? _client.GetGuilds().FirstOrDefault(g => g.Name.Trim().ToUpperInvariant() == guildStr); if (server == null) { await channel.SendMessageAsync("⚠️ Cannot find that server").ConfigureAwait(false); return; } if (server.OwnerId != _client.GetCurrentUser().Id) { await server.LeaveAsync().ConfigureAwait(false); await channel.SendMessageAsync("✅ Left server " + server.Name).ConfigureAwait(false); } else { await server.DeleteAsync().ConfigureAwait(false); await channel.SendMessageAsync("Deleted server " + server.Name).ConfigureAwait(false); } }
public async Task <string> Print() { var curUser = await client.GetCurrentUserAsync(); return($@"`Author: Kwoth` `Library: Discord.Net` `Bot Version: {BotVersion}` `Bot id: {curUser.Id}` `Owners' Ids: {string.Join(", ", NadekoBot.Credentials.OwnerIds)}` `Uptime: {GetUptimeString()}` `Servers: {client.GetGuilds().Count} | TextChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is ITextChannel)).Count()} | VoiceChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is IVoiceChannel)).Count()}` `Commands Ran this session: {commandsRan}` `Messages: {messageCounter} ({messageCounter / (double)GetUptime().TotalSeconds:F2}/sec)` `Heap: {Heap} MB`"); }
public async Task <string> Print() { var curUser = await client.GetCurrentUserAsync(); return($@"```css Author: [Kwoth#2560] | Library: [Discord.Net] Bot Version: [{BotVersion}] Bot ID: {curUser.Id} Owner ID(s): {string.Join(", ", NadekoBot.Credentials.OwnerIds)} Uptime: {GetUptimeString()} Servers: {client.GetGuilds().Count} | TextChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is ITextChannel)).Count()} | VoiceChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is IVoiceChannel)).Count()} Commands Ran this session: {commandsRan} Messages: {messageCounter} [{messageCounter / (double)GetUptime().TotalSeconds:F2}/sec] Heap: [{Heap} MB]```"); }
public async Task <string> Print() { var curUser = await client.GetCurrentUserAsync(); return($@" Author: [{Author}] | Library: [{Library}] Bot Version: [{BotVersion}] Bot ID: {curUser.Id} Owner ID(s): {OwnerIds} Uptime: {GetUptimeString()} Servers: {client.GetGuilds().Count} | TextChannels: {TextChannels} | VoiceChannels: {VoiceChannels} Commands Ran this session: {CommandsRan} Messages: {MessageCounter} [{MessagesPerSecond:F2}/sec] Heap: [{Heap} MB]"); }
public async Task StartHandling() { ownerChannels = (await Task.WhenAll(_client.GetGuilds().SelectMany(g => g.GetUsers()) .Where(u => NadekoBot.Credentials.OwnerIds.Contains(u.Id)) .Distinct(new IGuildUserComparer()) .Select(async u => { try { return(await u.CreateDMChannelAsync()); } catch { return(null); } }))) .Where(ch => ch != null) .ToList(); if (!ownerChannels.Any()) { _log.Warn("No owner channels created! Make sure you've specified correct OwnerId in the credentials.json file."); } else { _log.Info($"Created {ownerChannels.Count} out of {NadekoBot.Credentials.OwnerIds.Length} owner message channels."); } _client.MessageReceived += MessageReceivedHandler; }