Ejemplo n.º 1
0
 async def on_command_error(self, ctx, error):
     if isinstance(error, commands.CommandNotFound):
         async for message in ctx.history(limit=1):
             if message.author == self.disclient.user:
                 print("sent out a custom command")
             else:
                 prefix = get_prefix(self.disclient, ctx.message)[0]
                 # once guild prefix is enabled need to change regex
                 regexstr = r'(\..*){}|\{}\{}.*$'.format(
                     '{2,}', prefix, prefix)
                 print(regexstr)
                 regex2 = re.compile(regexstr)
                 # regex1 = re.compile(r'(\..*){2,}')
                 match = re.search(regex2, message.content)
                 if match:
                     print('user wrote some ...')
                 else:
                     await ctx.send(embed=error_embed("Command not found!"))
                     # raise error
     if isinstance(error, commands.MissingRequiredArgument):
         await ctx.send(embed=error_embed(f'Missing argument! {error}'))
     # always raise errors
     if isinstance(error, commands.CommandInvokeError):
         if ctx.command.name == 'timer':
             return
         else:
             await ctx.send(embed=error_embed('Something went wrong!'))
     if isinstance(error, commands.NoPrivateMessage):
         await ctx.send(
             embed=error_embed('This command does not work in DMs!'))
         return
     if isinstance(error, commands.CheckFailure):
         await ctx.send(embed=permission_denied_embed())
     raise error
Ejemplo n.º 2
0
    async def on_message(self, message: discord.Message):
        if message.author == self.bot.user:
            return

        Data.c.execute("SELECT * FROM afks")
        afks = Data.c.fetchall()

        for afk in afks:
            guild_prefix = get_prefix(self.bot, message)
            if int(
                afk[0]
            ) == message.author.id and not message.content.startswith(
                guild_prefix
            ):
                await message.channel.send(
                    f"{message.author.mention}, you have been un-AFK'd"
                )
                Data.delete_afk_data(message.author)
                continue

            user = await self.bot.fetch_user(int(afk[0]))
            if user in message.mentions:
                afk_reason = afk[1]
                await message.channel.send(
                    f"{message.author.mention}, {user} is currently AFK because:\n*{afk_reason}*"
                )
Ejemplo n.º 3
0
    async def prefix(self, ctx):
        """Gets the bot prefixes"""
        prefixes = bot.get_prefix(self.bot, ctx.message)
        prefixes.pop(1)
        prefixes.pop(1)
        prefixes.pop(1)
        output = ", ".join(prefixes)

        await ctx.send(f"My prefixes are {output}")
Ejemplo n.º 4
0
    async def prefix(self, ctx):
        prefixes = bot.get_prefix(self.bot, ctx.message)
        prefixes.pop(1)
        prefixes.pop(1)
        prefixes.pop(1)
        output = ""
        for i in prefixes:
            output += i + ", "

        await ctx.send(f"My prefixes are {output}")
Ejemplo n.º 5
0
 async def list(self, ctx):
     """List bot's prefixes."""
     prefix = bot.get_prefix(self.bot, ctx.message)
     if self.bot.user.mention in prefix:
         prefix.pop(0)
     prefixes = ", ".join([f"`{i}`" for i in prefix
                           ]).replace(r"`<@![0-9]*.*`",
                                      self.bot.user.mention)
     prefixes = re.sub(r"`<\S*[0-9]+(..)`", self.bot.user.mention, prefixes)
     if len(prefix) > 1:
         s = "es are"
     else:
         s = " is"
     await ctx.send(f"My prefix{s} {prefixes}")
Ejemplo n.º 6
0
    async def on_message(self, message):
        if message.author == self.disclient.user:
            return

        # user = message.author
        msg = message.content.split(" ")
        # bonegrip feature
        regex_uoh = re.compile(r'\b[uU]+[oO]+[hH]+\b')
        match = re.search(regex_uoh, message.content)
        if match:
            await message.add_reaction(emoji='😭')
        if message.guild:
            guild = message.guild.id
            banned_words = get_banned_words(guild)
            if banned_words:
                w = any(x in banned_words for x in msg)
                if w:
                    await message.delete()
                    await message.author.send(
                        banned_word_embed(message.guild, w))
        try:
            if msg[0].startswith(get_prefix(self.disclient, message)):
                command = msg[0][1:]
                command_list = get_commands()
                if command in command_list:
                    await message.channel.send(command_list[command])
        except TypeError:
            pass
        try:
            if message.mentions[0] == self.disclient.user and len(
                    message.content.split(" ")) == 1:
                if message.guild:
                    msg = f'My prefix in this server is `{get_prefix(self.disclient, message)[-1]}`!'
                else:
                    msg = f'My prefix is `{get_prefix(self.disclient, message)[-1]}`!'
                mention = f'\nYou can always mention me to use the commands, try `@{self.disclient.user.name} help`'
                embed = discord.Embed(title=f'My Prefixes',
                                      description=f'{msg}{mention}',
                                      color=discord.Color.blurple())
                await message.channel.send(embed=embed)
        except IndexError:
            pass