Exemplo n.º 1
0
async def _commands(ctx, *args):
    commands = ["!{}".format(c.name) for c in bot.commands]
    if "!help" in commands:
        commands.remove("!help")

    await ctx.send(embed=discord.Embed(
        title="사용 가능한 명령어", color=COLOR.BLUE, description=", ".join(commands)))
Exemplo n.º 2
0
 async def enable(self, ctx, *, command):
     command = self.bot.get_command(command)
     if command is None:
         em = discord.Embed(description=f"This command hasn't been found",
                            color=color())
         await ctx.reply(embed=em, mention_author=False)
     elif command.hidden:
         em = discord.Embed(description=f"This command hasn't been found",
                            color=color())
         await ctx.reply(embed=em, mention_author=False)
     else:
         res = await self.bot.db.fetchrow(
             "SELECT commands FROM commands WHERE guild = $1", ctx.guild.id)
         try:
             res["commands"]
         except TypeError:
             em = discord.Embed(description=f"That command isn't disabled",
                                color=color())
             await ctx.reply(embed=em, mention_author=False)
         else:
             commands = await self.bot.db.fetchrow(
                 "SELECT commands FROM commands WHERE guild = $1",
                 ctx.guild.id)
             commands = commands["commands"]
             commands = commands.split(",")
             command_name = "".join(
                 command.name if command.parent is None else
                 f"{command.parent.name} {command.name}")
             if command_name in commands:
                 commands.remove(command_name)
                 commands = ",".join(cmd for cmd in commands)
                 if len(commands) != 1:
                     await self.bot.db.execute(
                         "UPDATE commands SET commands = $1 WHERE guild = $2",
                         commands, ctx.guild.id)
                     em = discord.Embed(
                         description=
                         f"I've successfully enabled the `{command_name}` command",
                         color=color())
                     await ctx.reply(embed=em, mention_author=False)
                 else:
                     await self.bot.db.fetch(
                         "DELETE FROM commands WHERE guild = $1",
                         ctx.guild.id)
                     em = discord.Embed(
                         description=
                         f"I've successfully enabled the `{command_name}` command",
                         color=color())
                     await ctx.reply(embed=em, mention_author=False)
             else:
                 em = discord.Embed(
                     description=f"That command isn't disabled",
                     color=color())
                 await ctx.reply(embed=em, mention_author=False)
Exemplo n.º 3
0
async def rank(ctx):
    print(
        f"{ctx.message.author} requested rank information from warcraftlogs.com "
    )
    author = str(ctx.message.author)
    commands = str(ctx.message.content).split(" ")
    commands.remove(commands[0])
    # set default values
    name, realm, difficulty, region, metric = None, "sargeras", 4, "us", "dps"

    for item in commands:
        if item.startswith("d-") or item.startswith("difficulty-"):
            item_list = item.split("-")
            if len(item_list) > 1:
                difficulty = int(item_list[1])
        if item.startswith("m-") or item.startswith("metric-"):
            item_list = item.split("-")
            if len(item_list) > 1:
                metric = item_list[1]
        if item.startswith("-"):
            item_list = item.split("-")
            if len(item_list) > 1:
                name_realm_region = item_list[1]
                if "/" in name_realm_region:
                    nrr_list = name_realm_region.split("/")
                    name = nrr_list[0]
                    if len(nrr_list) > 1:
                        realm = nrr_list[1]
                    if len(nrr_list) > 2:
                        region = nrr_list[2]
                else:
                    name = name_realm_region

    if name is None:
        try:
            name = user_character_presets[author][0]
        except:
            print("No name preset for user")
            await ctx.send(
                "Enter a character name or register a character with !register"
            )
        try:
            realm = user_character_presets[author][1]
        except:
            print("No region preset for user")
        try:
            region = user_character_presets[author][2]
        except:
            print("No realm preset for user")

    message = f.get_rankings(name, realm, difficulty, metric, region)
    await ctx.send(embed=message)
Exemplo n.º 4
0
    def get_free_commands(self,
                          guild_id: int,
                          *,
                          commands: List[str] = None,
                          rules: List[ACL_rule] = None) -> Optional[List[str]]:
        """Return list of commands not in database"""
        if commands is None:
            commands = self.get_command_names()
        if rules is None:
            rules = repo_a.get_rules(guild_id)

        for rule in rules:
            if rule.command in commands:
                commands.remove(rule.command)
        return commands
Exemplo n.º 5
0
 async def _cmds(self, ctx):
     conexao = Conexao()
     e = discord.Embed(
         title='Todos os meus comandos',
         colour=discord.Colour(random_color()),
         description=
         f'Caso você queira saber mais informações sobre um comando, '
         'digite \'help comando\'',
         timestamp=datetime.utcnow())
     e.set_author(name='Androxus', icon_url=self.bot.user.avatar_url)
     e.set_footer(text=f'{ctx.author}', icon_url=ctx.author.avatar_url)
     categories = self.bot.get_all_categories()
     servidor = None
     if ctx.guild:
         servidor = ServidorRepository().get_servidor(conexao, ctx.guild.id)
         comandos_desativados = [
             c.comando for c in ComandoDesativadoRepository().get_commands(
                 conexao, servidor)
         ]
     for category in categories:
         commands = self.bot.get_commands_from_category(category)
         if len(commands) != 0:
             for i in range(len(commands)):
                 commands[i] = f'``{commands[i]}``'
             if servidor:
                 # vai remover todos os comandos desativados, da lista que vai aparecer na mensagem
                 for cmds_off in comandos_desativados:
                     if cmds_off in commands:
                         try:
                             commands = commands.remove(cmds_off)
                         except:
                             pass
             e.add_field(
                 name=
                 f'{self.bot.get_emoji_from_category(category)} {capitalize(category)} ({len(commands)})',
                 value=f'{", ".join(commands)}.',
                 inline=False)
     if servidor:
         cmds_personalizados = ComandoPersonalizadoRepository(
         ).get_commands(conexao, servidor)
         commands = []
         if len(cmds_personalizados) >= 1:
             for comando_personalizado in cmds_personalizados:
                 commands.append(f'``{comando_personalizado.comando}``')
             commands.sort()
             e.add_field(
                 name=
                 f'{self.bot.get_emoji_from_category("personalizado")} Comandos personalizados (são '
                 'comandos exclusivos deste servidor, e não precisam do prefixo)'
                 f'({len(commands)})',
                 value=f'{", ".join(commands)}.',
                 inline=False)
     conexao.fechar()
     await ctx.send(embed=e)
Exemplo n.º 6
0
    def filter_commands(self, _commands, *, sort=False, key=None):
        for cmd in list(_commands):
            if cmd.name == '--help':
                _commands.remove(cmd)

        return super().filter_commands(_commands, sort=sort, key=key)