.shardstats improved
This commit is contained in:
parent
ad3dd61d26
commit
b73b670f6f
@ -312,23 +312,32 @@ namespace NadekoBot.Modules.Utility
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task ShardStats(int page = 1)
|
||||
{
|
||||
page -= 1;
|
||||
if (page < 0)
|
||||
if (page < 1)
|
||||
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",
|
||||
shards.Select(x => $"Shard **#{x.ShardId.ToString()}** is in {Format.Bold(x.ConnectionState.ToString())} state with {Format.Bold(x.Guilds.Count.ToString())} servers"));
|
||||
var allShardStrings = NadekoBot.Client.Shards
|
||||
.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()
|
||||
.WithTitle("Shard Stats - page " + (page + 1))
|
||||
.WithDescription(info))
|
||||
.ConfigureAwait(false);
|
||||
.WithDescription(str);
|
||||
}, allShardStrings.Length / 25);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
|
Loading…
Reference in New Issue
Block a user