Added ellipsis truncation to system list descriptions
This commit is contained in:
parent
0aea658af9
commit
0266db5589
@ -363,9 +363,9 @@ 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.lower())
|
||||
page_size = 5
|
||||
page_size = 8
|
||||
if len(all_members) <= page_size:
|
||||
# If we have less than 10 members, don't bother paginating
|
||||
# If we have less than 8 members, don't bother paginating
|
||||
await ctx.reply(embed=embeds.member_list(system, all_members, 0, page_size))
|
||||
else:
|
||||
current_page = 0
|
||||
|
@ -25,6 +25,12 @@ def truncate_description(s: str) -> str:
|
||||
return s[:2048]
|
||||
|
||||
|
||||
def truncate_description_list(s: str) -> str:
|
||||
if len(s) > 512:
|
||||
return s[:512-45] + "..."
|
||||
return s
|
||||
|
||||
|
||||
def truncate_title(s: str) -> str:
|
||||
return s[:256]
|
||||
|
||||
@ -238,7 +244,9 @@ def member_list(system: System, all_members: List[Member], current_page: int, pa
|
||||
member_description += "**Birthday:** {}\n".format(member.birthday_string())
|
||||
if member.pronouns:
|
||||
member_description += "**Pronouns:** {}\n".format(member.pronouns)
|
||||
if member.description:
|
||||
if len(member.description) > 512:
|
||||
member_description += "\n" + truncate_description_list(member.description) + "\n" + "Type `pk;member {}` for full description.".format(member.hid)
|
||||
else:
|
||||
member_description += "\n" + member.description
|
||||
|
||||
embed.add_field(name=member.name, value=truncate_field_body(member_description) or "\u200B", inline=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user