mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-12 08:40:11 +00:00
Display member count on system card
This commit is contained in:
parent
7475980bd3
commit
da307c2dc9
2 changed files with 9 additions and 1 deletions
|
|
@ -29,6 +29,8 @@ namespace PluralKit.Bot {
|
||||||
// Fetch/render info for all accounts simultaneously
|
// Fetch/render info for all accounts simultaneously
|
||||||
var users = await Task.WhenAll(accounts.Select(async uid => (await _client.GetUserAsync(uid))?.NameAndMention() ?? $"(deleted account {uid})"));
|
var users = await Task.WhenAll(accounts.Select(async uid => (await _client.GetUserAsync(uid))?.NameAndMention() ?? $"(deleted account {uid})"));
|
||||||
|
|
||||||
|
var memberCount = await _members.MemberCount(system);
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.WithColor(Color.Blue)
|
.WithColor(Color.Blue)
|
||||||
.WithTitle(system.Name ?? null)
|
.WithTitle(system.Name ?? null)
|
||||||
|
|
@ -37,7 +39,7 @@ namespace PluralKit.Bot {
|
||||||
.WithFooter($"System ID: {system.Hid}");
|
.WithFooter($"System ID: {system.Hid}");
|
||||||
|
|
||||||
eb.AddField("Linked accounts", string.Join(", ", users));
|
eb.AddField("Linked accounts", string.Join(", ", users));
|
||||||
eb.AddField("Members", $"(see `pk;system {system.Hid} list` or `pk;system {system.Hid} list full`)");
|
eb.AddField($"Members ({memberCount})", $"(see `pk;system {system.Hid} list` or `pk;system {system.Hid} list full`)");
|
||||||
// TODO: fronter
|
// TODO: fronter
|
||||||
return eb.Build();
|
return eb.Build();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,12 @@ namespace PluralKit {
|
||||||
using (var conn = await _conn.Obtain())
|
using (var conn = await _conn.Obtain())
|
||||||
return await conn.QuerySingleAsync<int>("select count(*) from messages where member = @Id", member);
|
return await conn.QuerySingleAsync<int>("select count(*) from messages where member = @Id", member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> MemberCount(PKSystem system)
|
||||||
|
{
|
||||||
|
using (var conn = await _conn.Obtain())
|
||||||
|
return await conn.ExecuteScalarAsync<int>("select count(*) from members where system = @Id", system);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MessageStore {
|
public class MessageStore {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue