Change format of short member list a bit

This commit is contained in:
Ske 2019-04-09 22:08:27 +02:00
parent 2efaca706f
commit bfdb629aa5
2 changed files with 13 additions and 7 deletions

View File

@ -362,6 +362,8 @@ async def system_frontpercent(ctx: CommandContext, system: System):
await ctx.reply(embed=embed) await ctx.reply(embed=embed)
async def system_list(ctx: CommandContext, system: System): 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()) all_members = sorted(await system.get_members(ctx.conn), key=lambda m: m.name.lower())
if ctx.match("full"): if ctx.match("full"):
page_size = 8 page_size = 8
@ -404,10 +406,10 @@ async def system_list(ctx: CommandContext, system: System):
else: else:
#Basically same code as above #Basically same code as above
#A dozen members at a time seems handy #25 members at a time seems handy
page_size = 12 page_size = 25
if len(all_members) <= page_size: 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)) await ctx.reply(embed=embeds.member_list_short(system, all_members, 0, page_size))
else: else:
current_page = 0 current_page = 0

View File

@ -224,6 +224,7 @@ def help_footer_embed() -> discord.Embed:
embed.set_footer(text="By @Ske#6201 | GitHub: https://github.com/xSke/PluralKit/") embed.set_footer(text="By @Ske#6201 | GitHub: https://github.com/xSke/PluralKit/")
return embed 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): 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)) 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 = discord.Embed()
embed.title = title embed.title = title
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 desc = ""
embed.add_field(name=member.name, value=member_description, inline=False) for member in all_members[current_page*page_size:current_page*page_size+page_size]:
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 return embed
def member_list_full(system: System, all_members: List[Member], current_page: int, page_size: int): def member_list_full(system: System, all_members: List[Member], current_page: int, page_size: int):