fix(commands:rule>list|Mod): fix order

fix(commands:rule|Mod): fix when <prefix>rule <non digit>
This commit is contained in:
Romain J 2021-05-14 17:35:50 +02:00
parent 067e29a96a
commit 5afadb0f25
2 changed files with 4 additions and 1 deletions

View file

@ -14,6 +14,9 @@ def _(x):
class RuleIDConverter(commands.Converter): class RuleIDConverter(commands.Converter):
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613 async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
if not argument.isdigit():
raise UnknownRuleException(_("Unknown rule"))
arg = int(argument) arg = int(argument)
rule_row = await Rule.get_or_none(server_id=ctx.guild.id, rule_id=arg) rule_row = await Rule.get_or_none(server_id=ctx.guild.id, rule_id=arg)

View file

@ -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]: 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: def get_most_recent_server_rules(rules: list[Rule]) -> Rule: