diff options
author | 2022-10-20 00:06:45 +0100 | |
---|---|---|
committer | 2022-10-20 00:06:45 +0100 | |
commit | e57c6aa59e24899087b0de454824e32bb1d070ee (patch) | |
tree | 258fee920f7c39d26ad2192a10f4dc297b7493d8 | |
parent | Merge pull request #2245 from python-discord/update-autoreview-system (diff) |
change the signature to include a "zen_rule_index"
-rw-r--r-- | bot/exts/utils/utils.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 67dd27728..99484b85e 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -86,7 +86,8 @@ class Utils(Cog): await LinePaginator.paginate(char_list, ctx, embed, max_lines=10, max_size=2000, empty=False) @command() - async def zen(self, ctx: Context, *, search_value: Union[int, str, None] = None) -> None: + async def zen(self, ctx: Context, zen_rule_index: int | None, + *, search_value: Union[int, str, None] = None) -> None: """ Show the Zen of Python. @@ -100,22 +101,23 @@ class Utils(Cog): description=ZEN_OF_PYTHON ) - if search_value is None: + if zen_rule_index is None and search_value is None: embed.title += ", by Tim Peters" await ctx.send(embed=embed) return zen_lines = ZEN_OF_PYTHON.splitlines() - # handle if it's an index int - if isinstance(search_value, int): + # Prioritize passing the zen rule index + if zen_rule_index is not None: + upper_bound = len(zen_lines) - 1 lower_bound = -1 * len(zen_lines) - if not (lower_bound <= search_value <= upper_bound): + if not (lower_bound <= zen_rule_index <= upper_bound): raise BadArgument(f"Please provide an index between {lower_bound} and {upper_bound}.") - embed.title += f" (line {search_value % len(zen_lines)}):" - embed.description = zen_lines[search_value] + embed.title += f" (line {zen_rule_index % len(zen_lines)}):" + embed.description = zen_lines[zen_rule_index] await ctx.send(embed=embed) return |