forked from AlchemistsLab/covalent-faq-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
33 lines (28 loc) · 985 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sentry_sdk
from discord.ext import commands
def use_sentry(client, **sentry_args):
"""
Use this compatibility library as a bridge between Discord and Sentry.
Arguments:
client: The Discord client object (e.g. `discord.AutoShardedClient`).
sentry_args: Keyword arguments to pass to the Sentry SDK.
"""
sentry_sdk.init(**sentry_args)
@client.event
async def on_error(event, *args, **kwargs):
"""Don't ignore the error, causing Sentry to capture it."""
raise
@client.event
async def on_command_error(msg, error):
# don't report errors to sentry related to wrong permissions
if not isinstance(
error,
(
commands.MissingRole,
commands.MissingAnyRole,
commands.BadArgument,
commands.MissingRequiredArgument,
commands.errors.CommandNotFound,
),
):
raise error