<commit_before>from asyncio import Lock

from discord.ext import commands
from discord.ext.commands import errors as commands_errors
from raven import Client as SentryClient
from raven.exceptions import InvalidDsn

from cogs.utils import checks
from cogs.utils.storage import RedisCollection


class Sentry:
    """A simple cog for bug reports."""
    def __init__(self, liara):
        self.liara = liara
        self.settings = RedisCollection(liara.redis, 'redis')
        self.client = None
        self.client_lock = Lock(loop=self.liara.loop)

    async def on_command_error(self, exception, context):
        # raven setup
        if self.client is None:
            self.client = SentryClient(site=self.liara.user.id)
        dsn = await self.settings.get('dsn', None)
        if dsn is None:
            return
        try:
            self.client.set_dsn(dsn)
        except InvalidDsn:
            await self.settings.delete('dsn')
            return

        if isinstance(exception, commands_errors.MissingRequiredArgument):<commit_msg>Fix the Sentry cog properly<commit_after>from asyncio import Lock

from discord.ext import commands
from discord.ext.commands import errors as commands_errors
from raven import Client as SentryClient
from raven.exceptions import InvalidDsn

from cogs.utils import checks
from cogs.utils.storage import RedisCollection


class Sentry:
    """A simple cog for bug reports."""
    def __init__(self, liara):
        self.liara = liara
        self.settings = RedisCollection(liara.redis, 'redis')
        self.client = None
        self.client_lock = Lock(loop=self.liara.loop)

    async def on_command_error(self, context, exception):
        # raven setup
        if self.client is None:
            self.client = SentryClient(site=self.liara.user.id)
        dsn = await self.settings.get('dsn', None)
        if dsn is None:
            return
        try:
            self.client.set_dsn(dsn)
        except InvalidDsn:
            await self.settings.delete('dsn')
            return

        if isinstance(exception, commands_errors.MissingRequiredArgument):
{'fraction_non_alphanumeric': 0.07859848484848485, 'fraction_numerical': 0.0, 'mean_word_length': 2.7005253940455343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2430811', 'n_tokens_mistral': 605, 'n_tokens_neox': 596, 'n_words': 171}