From bfdb629aa519d017089ce6cbfc3f03aef88c77f0 Mon Sep 17 00:00:00 2001 From: Ske Date: Tue, 9 Apr 2019 22:08:27 +0200 Subject: [PATCH] Change format of short member list a bit --- src/pluralkit/bot/commands/system_commands.py | 8 +++++--- src/pluralkit/bot/embeds.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pluralkit/bot/commands/system_commands.py b/src/pluralkit/bot/commands/system_commands.py index e6e42190..0a3d8628 100644 --- a/src/pluralkit/bot/commands/system_commands.py +++ b/src/pluralkit/bot/commands/system_commands.py @@ -362,6 +362,8 @@ async def system_frontpercent(ctx: CommandContext, system: System): await ctx.reply(embed=embed) async def system_list(ctx: CommandContext, system: System): + # TODO: refactor this + all_members = sorted(await system.get_members(ctx.conn), key=lambda m: m.name.lower()) if ctx.match("full"): page_size = 8 @@ -404,10 +406,10 @@ async def system_list(ctx: CommandContext, system: System): else: #Basically same code as above - #A dozen members at a time seems handy - page_size = 12 + #25 members at a time seems handy + page_size = 25 if len(all_members) <= page_size: - # If we have less than 12 members, don't bother paginating + # If we have less than 25 members, don't bother paginating await ctx.reply(embed=embeds.member_list_short(system, all_members, 0, page_size)) else: current_page = 0 diff --git a/src/pluralkit/bot/embeds.py b/src/pluralkit/bot/embeds.py index 60d45dc0..5fec9540 100644 --- a/src/pluralkit/bot/embeds.py +++ b/src/pluralkit/bot/embeds.py @@ -224,6 +224,7 @@ def help_footer_embed() -> discord.Embed: embed.set_footer(text="By @Ske#6201 | GitHub: https://github.com/xSke/PluralKit/") return embed +# TODO: merge these somehow, they're very similar def member_list_short(system: System, all_members: List[Member], current_page: int, page_size: int): page_count = int(math.ceil(len(all_members) / page_size)) @@ -238,11 +239,14 @@ def member_list_short(system: System, all_members: List[Member], current_page: i embed = discord.Embed() embed.title = title + + desc = "" for member in all_members[current_page*page_size:current_page*page_size+page_size]: - member_description = "**ID**: {}\n".format(member.hid) - - #Removed truncating since it's just the ID - embed.add_field(name=member.name, value=member_description, inline=False) + if member.prefix or member.suffix: + desc += "[`{}`] {} *({}text{})*\n".format(member.hid, member.name, member.prefix, member.suffix) + else: + desc += "[`{}`] {}\n".format(member.hid, member.name) + embed.description = desc return embed def member_list_full(system: System, all_members: List[Member], current_page: int, page_size: int):