From 1fe9f596fdcc3c64af47a1394f41662f405397ef Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 4 Feb 2017 18:19:03 +0100 Subject: [PATCH] .shardstats added --- src/NadekoBot/Modules/Utility/Utility.cs | 35 ++++++++++++++++--- .../Resources/CommandStrings.Designer.cs | 27 ++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 +++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 1c1af1e0..ddb34011 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -279,11 +279,41 @@ namespace NadekoBot.Modules.Utility await Context.Channel.SendConfirmAsync($"{Context.User.Mention} https://discord.gg/{invite.Code}"); } + [NadekoCommand, Usage, Description, Aliases] + public async Task ShardStats(int page = 1) + { + page -= 1; + if (page < 0) + return; + + var shards = NadekoBot.Client.Shards.Skip(page * 25).Take(25); + + var info = string.Join("\n", + shards.Select(x => $"Shard **#{x.ShardId.ToString()}** is in {Format.Bold(x.ConnectionState.ToString())} state with {Format.Bold(x.Guilds.Count.ToString())} servers")); + + if (string.IsNullOrWhiteSpace(info)) + info = "No shard stats on this page."; + + await Context.Channel.EmbedAsync(new EmbedBuilder() + .WithOkColor() + .WithTitle("Shard Stats - page " + (page + 1)) + .WithDescription(info)) + .ConfigureAwait(false); + } + [NadekoCommand, Usage, Description, Aliases] public async Task Stats() { var stats = NadekoBot.Stats; + var shardId = Context.Guild != null + ? NadekoBot.Client.GetShardIdFor(Context.Guild.Id) + : 0; + var footer = $"Shard {shardId} | {NadekoBot.Client.Shards.Count} total shards"; +#if !GLOBAL_NADEKO + footer += $" | Playing {Music.Music.MusicPlayers.Where(mp => mp.Value.CurrentSong != null).Count()} songs, {Music.Music.MusicPlayers.Sum(mp => mp.Value.Playlist.Count)} queued."; +#endif + await Context.Channel.EmbedAsync( new EmbedBuilder().WithOkColor() .WithAuthor(eab => eab.WithName($"NadekoBot v{StatsService.BotVersion}") @@ -298,10 +328,7 @@ namespace NadekoBot.Modules.Utility .AddField(efb => efb.WithName(Format.Bold("Owner ID(s)")).WithValue(string.Join("\n", NadekoBot.Credentials.OwnerIds)).WithIsInline(true)) .AddField(efb => efb.WithName(Format.Bold("Uptime")).WithValue(stats.GetUptimeString("\n")).WithIsInline(true)) .AddField(efb => efb.WithName(Format.Bold("Presence")).WithValue($"{NadekoBot.Client.GetGuildCount()} Servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels").WithIsInline(true)) -#if !GLOBAL_NADEKO - .WithFooter(efb => efb.WithText($"Playing {Music.Music.MusicPlayers.Where(mp => mp.Value.CurrentSong != null).Count()} songs, {Music.Music.MusicPlayers.Sum(mp => mp.Value.Playlist.Count)} queued.")) -#endif - ); + .WithFooter(efb => efb.WithText(footer))); } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 634991da..0a7ff768 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -7025,6 +7025,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to shardstats. + /// + public static string shardstats_cmd { + get { + return ResourceManager.GetString("shardstats_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Stats for shards. Paginated with 25 shards per page.. + /// + public static string shardstats_desc { + get { + return ResourceManager.GetString("shardstats_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}shardstats` or `{0}shardstats 2`. + /// + public static string shardstats_usage { + get { + return ResourceManager.GetString("shardstats_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to shorten. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 9b0b01be..d6074104 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -3051,4 +3051,13 @@ `{0}reloadimages` + + shardstats + + + Stats for shards. Paginated with 25 shards per page. + + + `{0}shardstats` or `{0}shardstats 2` + \ No newline at end of file