mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
[V3 Sentry] Fix sentry logging (#1169)
This commit is contained in:
@@ -8,7 +8,6 @@ from pkg_resources import DistributionNotFound
|
||||
|
||||
|
||||
import discord
|
||||
from .sentry_setup import should_log
|
||||
from discord.ext import commands
|
||||
|
||||
from . import __version__
|
||||
@@ -134,6 +133,10 @@ def init_events(bot, cli_flags):
|
||||
if bot.rpc_enabled:
|
||||
await initialize(bot)
|
||||
|
||||
@bot.event
|
||||
async def on_error(event_method, *args, **kwargs):
|
||||
sentry_log.exception("Exception in on_{}".format(event_method))
|
||||
|
||||
@bot.event
|
||||
async def on_command_error(ctx, error):
|
||||
if isinstance(error, commands.MissingRequiredArgument):
|
||||
@@ -166,12 +169,6 @@ def init_events(bot, cli_flags):
|
||||
error, error.__traceback__))
|
||||
bot._last_exception = exception_log
|
||||
await ctx.send(inline(message))
|
||||
|
||||
module = ctx.command.module
|
||||
if should_log(module):
|
||||
sentry_log.exception("Exception in command '{}'"
|
||||
"".format(ctx.command.qualified_name),
|
||||
exc_info=error.original)
|
||||
elif isinstance(error, commands.CommandNotFound):
|
||||
pass
|
||||
elif isinstance(error, commands.CheckFailure):
|
||||
@@ -185,6 +182,10 @@ def init_events(bot, cli_flags):
|
||||
else:
|
||||
log.exception(type(error).__name__, exc_info=error)
|
||||
|
||||
sentry_log.exception("Exception in command '{}'"
|
||||
"".format(ctx.command.qualified_name),
|
||||
exc_info=error.original)
|
||||
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
bot.counter["messages_read"] += 1
|
||||
|
||||
Reference in New Issue
Block a user