diff options
author | 2022-02-07 18:52:07 -0500 | |
---|---|---|
committer | 2022-02-09 18:13:38 -0500 | |
commit | 88a65659d5c45ed6be54f35245168f6e30192015 (patch) | |
tree | bd207caf718fb90fe1f0ab8c81c524c86b15e5fc /bot | |
parent | pagination (diff) |
fix lists
command
Diffstat (limited to 'bot')
-rw-r--r-- | bot/exts/events/trivianight/_game.py | 22 | ||||
-rw-r--r-- | bot/exts/events/trivianight/trivianight.py | 8 |
2 files changed, 19 insertions, 11 deletions
diff --git a/bot/exts/events/trivianight/_game.py b/bot/exts/events/trivianight/_game.py index 4b115086..4937e6e3 100644 --- a/bot/exts/events/trivianight/_game.py +++ b/bot/exts/events/trivianight/_game.py @@ -177,14 +177,22 @@ class TriviaNightGame: - Question description - Visited/not visited """ + question_list = [] formatted_string = "" - spaces = max(len(q.description) for q in self._all_questions) + visited = ":white_check_mark:" + not_visited = ":x:" for question in self._all_questions: - visited, not_visited = ":white_check_mark:", ":x:" - formatted_string += f"`Q{question.number}: {question.description}" \ - f"{' ' * (spaces - len(question.description))}|`" \ - f" {visited if question not in self._questions else not_visited}\n" - - return formatted_string + formatted_string += ( + f"**Q{question.number}** {not_visited if question in self._questions else visited}" + f"\n{question.description}\n\n" + ) + if question.number % 5 == 0: + question_list.append(formatted_string.rstrip()) + formatted_string = "" + + if formatted_string: + question_list.append(formatted_string) + + return question_list diff --git a/bot/exts/events/trivianight/trivianight.py b/bot/exts/events/trivianight/trivianight.py index cf1e45c3..d190fc13 100644 --- a/bot/exts/events/trivianight/trivianight.py +++ b/bot/exts/events/trivianight/trivianight.py @@ -208,16 +208,16 @@ class TriviaNightCog(commands.Cog): )) return - question_list = self.game.list_questions().split("\n") + question_list = self.game.list_questions() list_embed = Embed(title="All Trivia Night Questions") - if len(question_list) <= 5: - list_embed.description = "\n".join(question_list) + if len(question_list) == 1: + list_embed.description = question_list[0] await ctx.send(embed=list_embed) else: await LinePaginator.paginate( - ("\n".join(question_list[idx:idx+5]) for idx in range(0, len(question_list), 5)), + question_list, ctx, list_embed ) |