Skip to content

Commit

Permalink
Fix error raised by bad z!duel argument
Browse files Browse the repository at this point in the history
and also broaden the scope of exception types that display the "Format: x" message, rather than being thrown
  • Loading branch information
kaesekaiser authored Jan 1, 2021
1 parent 52e2497 commit 0f60a48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bot/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ async def duel(ctx: commands.Context, opponent: User):
raise commands.CommandError("You can't challenge yourself.")
if opponent.bot:
raise commands.CommandError("You can't duel a bot.")
if opponent not in ctx.guild.members:
raise commands.CommandError("User is not in this server.")

if not await confirm(f"{opponent.display_name}, do you accept the challenge?", ctx, opponent,
emol=du, yes="accept", no="chicken out"):
Expand Down
2 changes: 1 addition & 1 deletion bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ async def on_command_error(ctx: commands.Context, exception):
if ctx.command == epitaph and ctx.channel in zeph.epitaphChannels:
zeph.epitaphChannels.remove(ctx.channel)

if type(exception) in [commands.MissingRequiredArgument, commands.BadArgument, commands.TooManyArguments]:
if isinstance(exception, commands.UserInputError):
await err.send(
ctx, f"Format: `{'` or `'.join(ctx.command.usage.splitlines())}`"
)
Expand Down

0 comments on commit 0f60a48

Please sign in to comment.