Add -all flag on system and group cards (#216)

* Show group count on stats card

* Add -all flag on system and group cards
Shows full count, including private members.

* fix stuff broken by merging conflicts
This commit is contained in:
kittens
2020-09-12 18:10:37 -04:00
committed by GitHub
parent 5ba89d32fc
commit 42b70cde9a
5 changed files with 18 additions and 7 deletions

View File

@@ -26,15 +26,16 @@ namespace PluralKit.Bot {
_repo = repo;
}
public async Task<DiscordEmbed> CreateSystemEmbed(DiscordClient client, PKSystem system, LookupContext ctx)
public async Task<DiscordEmbed> CreateSystemEmbed(Context cctx, PKSystem system, LookupContext ctx)
{
await using var conn = await _db.Obtain();
// Fetch/render info for all accounts simultaneously
var accounts = await _repo.GetSystemAccounts(conn, system.Id);
var users = await Task.WhenAll(accounts.Select(async uid => (await client.GetUser(uid))?.NameAndMention() ?? $"(deleted account {uid})"));
var users = await Task.WhenAll(accounts.Select(async uid => (await cctx.Shard.GetUser(uid))?.NameAndMention() ?? $"(deleted account {uid})"));
var memberCount = cctx.MatchPrivateFlag(ctx) ? await _repo.GetSystemMemberCount(conn, system.Id, PrivacyLevel.Public) : await _repo.GetSystemMemberCount(conn, system.Id);
var memberCount = await _repo.GetSystemMemberCount(conn, system.Id, PrivacyLevel.Public);
var eb = new DiscordEmbedBuilder()
.WithColor(DiscordUtils.Gray)
.WithTitle(system.Name ?? null)
@@ -244,4 +245,4 @@ namespace PluralKit.Bot {
return Task.FromResult(eb.Build());
}
}
}
}