Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix UserInputError being handled incorrectly. #77

Merged
merged 5 commits into from
Jan 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions bot/exts/backend/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ async def on_command_error(
return # Skip logging CommandNotFound Error

elif isinstance(error, commands.UserInputError):
self.revert_cooldown_counter(ctx.command, ctx.message)
embed = self.error_embed(
f"Your input was invalid: {error}\n\nUsage:\n"
f"```{ctx.prefix}{ctx.command} {ctx.command.signature}```"
)
if isinstance(error, commands.MissingRequiredArgument):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if there is a MissingRequiredArgument happens, this bug occurs? nice catch 💯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if there is a MissingRequiredArgument happens, this bug occurs? nice catch 100

Actually, this bug occurs if any UserInputError happens (including MissingRequriedArgument).

I added special handling of MissingRequiredArgument just so that the message is different.

description = (
f"{error}\n\nUsage:\n"
f"```{ctx.prefix}{ctx.command} {ctx.command.signature}```"
)
else:
description = (
f"Your input was invalid: {error}\n\nUsage:\n"
f"```{ctx.prefix}{ctx.command} {ctx.command.signature}```"
)

embed = self.error_embed(description)
await ctx.send(embed=embed)

elif isinstance(error, commands.CommandOnCooldown):
Expand Down