diff options
| author | 2020-11-08 15:16:30 +0800 | |
|---|---|---|
| committer | 2020-11-08 15:17:04 +0800 | |
| commit | 3e73fd76d73b7e84888af46e0b6b47a1dd4003d3 (patch) | |
| tree | 7cc48bf19821ad41cfa7527604086bfe1b2cb8a5 | |
| parent | Remove unnecessary noqa pragma for flake8 (diff) | |
Raise BadArgument in the Infraction converter
| -rw-r--r-- | bot/converters.py | 9 | ||||
| -rw-r--r-- | bot/exts/moderation/infraction/management.py | 6 |
2 files changed, 4 insertions, 11 deletions
diff --git a/bot/converters.py b/bot/converters.py index 962416238..f350e863e 100644 --- a/bot/converters.py +++ b/bot/converters.py @@ -568,12 +568,11 @@ class Infraction(Converter): infractions = await ctx.bot.api_client.get("bot/infractions", params=params) if not infractions: - await ctx.send( - ":x: Couldn't find most recent infraction; you have never given an infraction." + raise BadArgument( + "Couldn't find most recent infraction; you have never given an infraction." ) - return None - - return infractions[0] + else: + return infractions[0] else: return ctx.bot.api_client.get(f"bot/infractions/{arg}") diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py index 97fc7b1d8..49ddfa473 100644 --- a/bot/exts/moderation/infraction/management.py +++ b/bot/exts/moderation/infraction/management.py @@ -73,9 +73,6 @@ class ModManagement(commands.Cog): Use "p" or "permanent" to mark the infraction as permanent. Alternatively, an ISO 8601 timestamp can be provided for the duration. """ - if not infraction: - return - await self.infraction_edit( ctx=ctx, infraction=infraction, @@ -115,9 +112,6 @@ class ModManagement(commands.Cog): # Unlike UserInputError, the error handler will show a specified message for BadArgument raise commands.BadArgument("Neither a new expiry nor a new reason was specified.") - if not infraction: - return - old_infraction = infraction infraction_id = infraction["id"] |