From 5afadb0f252a4604e924c715c52c30455206688c Mon Sep 17 00:00:00 2001 From: Romain J Date: Fri, 14 May 2021 17:35:50 +0200 Subject: [PATCH] fix(commands:rule>list|Mod): fix order fix(commands:rule|Mod): fix when rule --- tuxbot/cogs/Mod/functions/converters.py | 3 +++ tuxbot/cogs/Mod/functions/utils.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tuxbot/cogs/Mod/functions/converters.py b/tuxbot/cogs/Mod/functions/converters.py index 6dea812..64e68be 100644 --- a/tuxbot/cogs/Mod/functions/converters.py +++ b/tuxbot/cogs/Mod/functions/converters.py @@ -14,6 +14,9 @@ def _(x): class RuleIDConverter(commands.Converter): async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613 + if not argument.isdigit(): + raise UnknownRuleException(_("Unknown rule")) + arg = int(argument) rule_row = await Rule.get_or_none(server_id=ctx.guild.id, rule_id=arg) diff --git a/tuxbot/cogs/Mod/functions/utils.py b/tuxbot/cogs/Mod/functions/utils.py index f4a92af..ab8fee3 100644 --- a/tuxbot/cogs/Mod/functions/utils.py +++ b/tuxbot/cogs/Mod/functions/utils.py @@ -11,7 +11,7 @@ async def save_lang(bot: Tux, ctx: ContextPlus, lang: str) -> None: async def get_server_rules(guild_id: int) -> list[Rule]: - return await Rule.filter(server_id=guild_id).all() + return await Rule.filter(server_id=guild_id).all().order_by("rule_id") def get_most_recent_server_rules(rules: list[Rule]) -> Rule: