diff --git a/robocop_ng/__main__.py b/robocop_ng/__main__.py index de4c2be0..b0c1cd18 100755 --- a/robocop_ng/__main__.py +++ b/robocop_ng/__main__.py @@ -8,6 +8,8 @@ from discord.ext import commands from discord.ext.commands import CommandError, Context +from robocop_ng.helpers.notifications import report_critical_error + if len(sys.argv[1:]) != 1: sys.stderr.write("usage: ") sys.exit(1) @@ -140,6 +142,25 @@ async def on_command(ctx): async def on_error(event: str, *args, **kwargs): log.exception(f"Error on {event}:") + exception = sys.exception() + is_report_allowed = any( + [ + not isinstance(exception, x) + for x in [ + discord.RateLimited, + discord.GatewayNotFound, + discord.InteractionResponded, + discord.LoginFailure, + ] + ] + ) + if exception is not None and is_report_allowed: + await report_critical_error( + bot, + exception, + additional_info={"Event": event, "args": args, "kwargs": kwargs}, + ) + @bot.event async def on_command_error(ctx: Context, error: CommandError):