Fix error in pagination code
This commit is contained in:
parent
560b79c2ae
commit
41e6b64ad6
@ -363,16 +363,16 @@ async def system_frontpercent(ctx: CommandContext, system: System):
|
||||
|
||||
async def system_list(ctx: CommandContext, system: System):
|
||||
all_members = sorted(await system.get_members(ctx.conn), key=lambda m: m.name)
|
||||
page_size = 10
|
||||
page_size = 5
|
||||
if len(all_members) <= page_size:
|
||||
# If we have less than 10 members, don't bother paginating
|
||||
await ctx.reply(embed=embeds.member_list(await ctx.get_system(), all_members, 0, page_size = page_size))
|
||||
await ctx.reply(embed=embeds.member_list(await ctx.get_system(), all_members, 0, page_size))
|
||||
else:
|
||||
current_page = 0
|
||||
msg: discord.Message = None
|
||||
while True:
|
||||
page_count = math.ceil(len(all_members) / page_size)
|
||||
embed = embeds.member_list(await ctx.get_system(), all_members, current_page)
|
||||
embed = embeds.member_list(await ctx.get_system(), all_members, current_page, page_size)
|
||||
|
||||
# Add reactions for moving back and forth
|
||||
if not msg:
|
||||
|
@ -219,8 +219,8 @@ def help_footer_embed() -> discord.Embed:
|
||||
embed.set_footer(text="By @Ske#6201 | GitHub: https://github.com/xSke/PluralKit/")
|
||||
return embed
|
||||
|
||||
def member_list(system: System, all_members: List[Member], current_page: int = 0, page_size: int = 10):
|
||||
page_count = math.ceil(len(all_members) / page_size)
|
||||
def member_list(system: System, all_members: List[Member], current_page: int, page_size: int):
|
||||
page_count = int(math.ceil(len(all_members) / page_size))
|
||||
|
||||
title = ""
|
||||
if len(all_members) > page_size:
|
||||
@ -234,5 +234,13 @@ def member_list(system: System, all_members: List[Member], current_page: int = 0
|
||||
embed = discord.Embed()
|
||||
embed.title = title
|
||||
for member in all_members[current_page*page_size:current_page*page_size+page_size]:
|
||||
embed.add_field(name=member.name, value=(member.description or "") + "\n*ID: `{}`*".format(member.hid), inline=False)
|
||||
member_description = "**ID**: {}\n".format(member.hid)
|
||||
if member.birthday:
|
||||
member_description += "**Birthday:** {}\n".format(member.birthday.isoformat())
|
||||
if member.pronouns:
|
||||
member_description += "**Pronouns:** {}\n".format(member.pronouns)
|
||||
if member.description:
|
||||
member_description += "\n" + member.description
|
||||
|
||||
embed.add_field(name=member.name, value=member_description or "\u200B", inline=False)
|
||||
return embed
|
Loading…
Reference in New Issue
Block a user