Beispiel #1
0
    async def send_cog_help(self, cog: commands.Cog) -> None:
        if cog.qualified_name in NO_ACCESS_COGS or not cog.help_check(self.context):
            raise self.command_not_found(cog.qualified_name)

        embed = Embed(
            title=f"Help for extension: `{cog.qualified_name}`",
            description="Ooooh ther's lots of fun stuff in here!",
            color=Color.blue(),
        )
        embed.add_field(
            name="What does this extension do?", value=cog.__doc__, inline=False
        )
        command = commands.Command

        commands_in_cog = [
            f"`{command.name}`"
            for command in cog.walk_commands()
            if command.parent is None
        ]

        embed.add_field(
            name="Commands:",
            value=(", ".join(commands_in_cog))
            if commands_in_cog
            else "No Commands Found!",
        )
        await self.dispatch_help(embed)
Beispiel #2
0
 async def send_cog_help(self, cog: commands.Cog):
     embed = Embed('Commands in ' + cog.qualified_name)
     for cmd in cog.walk_commands():
         embed.description += f'**{cmd.name}**: {cmd.help}\n'
     embed.set_footer(text='Version ' + cog.description.split('Version')[1])
     await self.context.reply(
         f"Send `{await self.context.bot.get_prefix(self.context.message)}help <command>`!",
         embed=embed)
Beispiel #3
0
    async def send_cog_help(self, cog: Cog):
        embed = discord.Embed(title=cog.qualified_name,
                              description=cog.description,
                              color=discord.Color.blue())

        for cmd in cog.walk_commands():
            embed.add_field(
                name=await self.context.bot.get_prefix(self.context.message) +
                cmd.name,
                value=cmd.brief)

        if len(embed.fields) == 0:
            embed.add_field(name="Error",
                            value="This category does not have any commands.")
        await self.context.send(embed=embed)
Beispiel #4
0
    def get_cog_commands(self, cog: commands.Cog):

        ctx = self.context
        filtered_commands = []

        for command in cog.walk_commands():

            if ctx.author.id in ctx.bot.config.owner_ids:
                filtered_commands.append(command)  # Show all commands if author is owner.
            elif command.hidden or command.root_parent and command.root_parent.hidden:
                continue  # Skip command if it or its parents are hidden.
            else:
                filtered_commands.append(command)

        return filtered_commands
Beispiel #5
0
    def get_cog_help(cog: commands.Cog) -> discord.Embed:
        """generates a help embed from the cog."""
        out = discord.Embed(title=cog.qualified_name,
                            description=cog.description)
        for cmd_or_group in cog.walk_commands():
            # In python 3.10 this should be a match.
            if isinstance(cmd_or_group, commands.Group):
                out.add_field(
                    name=cmd_or_group.qualified_name,
                    value=f"{count(cmd_or_group.walk_commands())} commands.",
                )
                continue
            out.add_field(
                name=command_usage(cmd_or_group),
                value=(cmd_or_group.help if cmd_or_group.help else ""),
            )

        return out
Beispiel #6
0
    def embeddify(self, cog: commands.Cog) -> discord.Embed:
        """Transform command group documentation into the format of a Discord embed."""
        embed = utilities.Embeds.standard(description=cog.description)
        embed.title = f"Documentation for `{cog.__class__.__module__}`:"

        embed.set_footer(
            text="Arguments enclosed in <> are required while [] are optional.",
            icon_url=utilities.Icons.INFO
        )

        for command in cog.walk_commands():
            # We don't want group parent commands listed, ignore those.
            if isinstance(command, commands.Group):
                continue

            signature = utilities.Commands.signature(command)
            embed.add_field(name=signature, value=command.help)

        return embed
Beispiel #7
0
    async def add_cog(self, cog: commands.Cog, force=False):
        cog_name = cog.__class__.__name__
        cog_desc = cog.__doc__

        commands = []
        added = []

        for command in cog.walk_commands():
            if command in added:
                continue

            added.append(command)

            pack = await self.package_command(command, force=force)
            if pack is None:
                continue

            commands.append(pack)

        if not commands:
            return True

        self.pager.add_page(cog_name, cog_desc, commands)
Beispiel #8
0
 async def send_cog_help(self, cog: Cog):
     # embed = me.MyEmbed
     embed = self.dfembed.clone(ctx=self.context)
     temp = str()
     mention = str()
     command_name_list = list()
     count = 1
     empty_message = str()
     if cog.walk_commands:
         for cmd in cog.walk_commands():
             if (temp != cmd.name) & (not (cmd.root_parent)):
                 temp = cmd.name
                 embed.add(
                     name=f"> {count} ${cmd.name}",
                     value=f"{cmd.description}",
                 )
                 command_name_list.append(temp)
                 count += 1
     else:
         empty_message = "\rコマンドはありません"
     embed.change(
         header="ℹカテゴリ説明",
         title=f"{cog.qualified_name}",
         description=f"{cog.description}{empty_message}",
         bottoms_sub=self.counts[:len(command_name_list)],
         bottom_args=command_name_list,
     )
     botid = (await self.context.bot.application_info()).id
     if self.context.author.id == botid:
         if self.context.bot.config[str(
                 self.context.guild.id)]["help_author"].get(
                     self.context.channel.id):
             mention = (self.context.bot.config[str(
                 self.context.guild.id)]["help_author"].get(
                     self.context.channel.id).get(cog.__class__.__name__))
     await embed.sendEmbed(mention=mention)
Beispiel #9
0
    def get_cog_help(cog: commands.Cog) -> discord.Embed:
        """generates a help embed from the cog."""
        out = discord.Embed(
            title=cog.qualified_name,
            description=cog.description,
            color=discord.Color(0x2F3136),
        )
        for cmd_or_group in cog.walk_commands():
            cmd_usage = command_usage(cmd_or_group)
            # In python 3.10 this should be a match.
            if isinstance(cmd_or_group, commands.Group):
                out.add_field(
                    name=cmd_or_group.qualified_name,
                    value=f"{count(cmd_or_group.walk_commands())} commands.",
                )
                continue
            out.add_field(
                name=cmd_usage,
                value=(cmd_or_group.help if cmd_or_group.help else "") +
                f'\n```ini\n{cmd_usage if cmd_or_group.signature is None else cmd_usage + "[None]"}```',
                inline=False,
            )

        return out
Beispiel #10
0
 async def send_cog_help(self, cog: commands.Cog):
     """Send help for a specific cog."""
     await self.send_bot_help({cog: cog.walk_commands()})