1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Display a user friendly message on syntax errors

This commit is contained in:
Steffo 2019-09-05 20:32:22 +02:00
parent 6583823c23
commit 65dac01c58
2 changed files with 6 additions and 0 deletions

View file

@ -121,6 +121,9 @@ class DiscordBot(GenericBot):
with message.channel.typing():
try:
await command.run(CommandArgs(parameters), data=data)
except InvalidInputError as e:
await data.reply(f":warning: {' '.join(e.args)}\n"
f"Syntax: [c]/{command.name} {command.syntax}[/c]")
except Exception as e:
sentry_sdk.capture_exception(e)
error_message = f"{e.__class__.__name__}\n"

View file

@ -174,6 +174,9 @@ class TelegramBot(GenericBot):
# Run the command
try:
await command.run(CommandArgs(parameters), data)
except InvalidInputError as e:
await data.reply(f"⚠️ {' '.join(e.args)}\n"
f"Syntax: [c]/{command.name} {command.syntax}[/c]")
except Exception as e:
sentry_sdk.capture_exception(e)
error_message = f"⛔️ [b]{e.__class__.__name__}[/b]\n"