.shardstats improved

This commit is contained in:
Kwoth 2017-02-06 08:35:45 +01:00
parent ad3dd61d26
commit b73b670f6f

View File

@ -312,23 +312,32 @@ namespace NadekoBot.Modules.Utility
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task ShardStats(int page = 1) public async Task ShardStats(int page = 1)
{ {
page -= 1; if (page < 1)
if (page < 0)
return; return;
var shards = NadekoBot.Client.Shards.Skip(page * 25).Take(25); var status = string.Join(", ", NadekoBot.Client.Shards.GroupBy(x => x.ConnectionState)
.Select(x => $"{x.Count()} shards {x.Key}")
.ToArray());
var info = string.Join("\n", var allShardStrings = NadekoBot.Client.Shards
shards.Select(x => $"Shard **#{x.ShardId.ToString()}** is in {Format.Bold(x.ConnectionState.ToString())} state with {Format.Bold(x.Guilds.Count.ToString())} servers")); .Select(x => $"Shard **#{x.ShardId.ToString()}** is in {Format.Bold(x.ConnectionState.ToString())} state with {Format.Bold(x.Guilds.Count.ToString())} servers")
.ToArray();
if (string.IsNullOrWhiteSpace(info))
info = "No shard stats on this page.";
await Context.Channel.EmbedAsync(new EmbedBuilder()
await Context.Channel.SendPaginatedConfirmAsync(page, (curPage) => {
var str = string.Join("\n", allShardStrings.Skip(25 * (curPage - 1)).Take(25));
if (string.IsNullOrWhiteSpace(str))
str = "No shards on this page.";
return new EmbedBuilder()
.WithAuthor(a => a.WithName("Shard Stats"))
.WithTitle(status)
.WithOkColor() .WithOkColor()
.WithTitle("Shard Stats - page " + (page + 1)) .WithDescription(str);
.WithDescription(info)) }, allShardStrings.Length / 25);
.ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]