From 2648f208dac619e116be8ed16ef71bbb67757fd2 Mon Sep 17 00:00:00 2001 From: Bella | Nightshade <47324660+xBelladonna@users.noreply.github.com> Date: Sat, 11 May 2019 10:19:34 +0000 Subject: [PATCH] bot: add member count to system card (#91) * bot: add member count to system card * bot: fix potential crash on edge case Fixes a potential crash if a user queries the system card of a system with no members * bot: tidy up code * bot: move member count to embed title/Member field Displays the member count (between parentheses) in the embed title if the system is named, otherwise shows it in the Member field title (again between parentheses) * bot: move member count to Member field title entirely Removed the member count from the embed title and display it in the Member field title within parentheses in all cases --- src/pluralkit/bot/embeds.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pluralkit/bot/embeds.py b/src/pluralkit/bot/embeds.py index a1570498..ddd3b56d 100644 --- a/src/pluralkit/bot/embeds.py +++ b/src/pluralkit/bot/embeds.py @@ -79,6 +79,9 @@ async def system_card(conn, client: discord.Client, system: System, is_own_syste card = discord.Embed() card.colour = discord.Colour.blue() + all_members = await system.get_members(conn) + member_count = str(len(all_members)) + if system.name: card.title = truncate_title(system.name) @@ -109,7 +112,7 @@ async def system_card(conn, client: discord.Client, system: System, is_own_syste card.add_field(name="Description", value=truncate_field_body(system.description), inline=False) - card.add_field(name="Members", value="*See `pk;system {0} list`for the short list, or `pk;system {0} list full` for the detailed list*".format(system.hid) if not is_own_system else "*See `pk;system list` for the short list, or `pk;system list full` for the detailed list*") + card.add_field(name="Members ({})".format(member_count), value="*See `pk;system {0} list`for the short list, or `pk;system {0} list full` for the detailed list*".format(system.hid) if not is_own_system else "*See `pk;system list` for the short list, or `pk;system list full` for the detailed list*") card.set_footer(text="System ID: {}".format(system.hid)) return card