Skip to content

Commit

Permalink
fix(discord-jobs): fields too long
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Oct 2, 2024
1 parent 081439c commit c2ccdb7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/fun/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,16 @@ async def discord_jobs(self, interaction: discord.Interaction, query: str | None
)
]
desc = await self.bot._(interaction, "fun.discordjobs.filtered-count", count=len(jobs))
formatted_jobs = [
f"[{x['title'] if len(x['title'])<50 else x['title'][:49]+'…'}]({x['absolute_url']})"
for x in jobs
]
formatted_jobs: list[str] = []
for job in jobs:
max_title_length = min(50, 102 - len(job["absolute_url"] - 4))
if len(title) < max_title_length:
title: str = job["title"]
else:
title = job["title"][:max_title_length-1] + "…"
if title.endswith(" (…"):
title = title[:-3] + "…"
formatted_jobs.append(f"[{title}]({job['absolute_url']})")
_title = await self.bot._(interaction, "fun.discordjobs.title")
class JobsPaginator(Paginator):
"Paginator used to display jobs offers"
Expand Down

0 comments on commit c2ccdb7

Please sign in to comment.