Пример #1
0
    def make_help_pages(self,
                        ctx: _commands.Context,
                        commands: list,
                        pages: list,
                        cog: str = None,
                        step: int = 10):
        """
        Makes pages (sorted by cogs) for the command iterable given.
        """

        cursor = 0

        title = "**Unsorted** Category"
        if cog:
            title = f"**{cog}** Category"

        for i in range(0, len(commands), step):
            if self.hex_values:
                if cursor <= len(self.hex_values) - 1:
                    colour = self.hex_values[cursor]
                else:
                    colour = other.random_color()
                    cursor = 0
            else:
                colour = other.random_colour()

            quest = "\N{BLACK QUESTION MARK ORNAMENT}"

            page = embeds.Embed(title=title, colour=colour, timestamp=None)
            page.set_author(
                name=f"{quest} {ctx.bot.user.name}'s Commands {quest}",
                icon_url=str(ctx.bot.user.avatar_url),
            )
            page.set_footer(icon_url=str(ctx.bot.user.avatar_url),
                            text="Only commands you can run are visible")

            next_commands = commands[i:i + 10]
            for cmd in next_commands:
                name = cmd.name
                if isinstance(cmd, _commands.Group):
                    name = "**[GROUP]** " + cmd.name

                brief = cmd.brief or self.no_brief_default(ctx.prefix, cmd)

                page.add_field(
                    name=name,
                    value=f"{ZERO_WIDTH_SPACE}{EM_SPACE}{brief.lstrip()}")
            pages.append(page)

            cursor += 1
Пример #2
0
    def make_help_page(self, cmd: typing.Union[_commands.Command,
                                               _commands.Group], prefix: str):
        """
        Makes a help page for the given command with the given prefix.
        """

        if self.hex_values:
            colour = choice(self.hex_values)
        else:
            colour = other.random_colour()

        title = f"`{cmd.qualified_name}` help page"
        if isinstance(cmd, _commands.Group):
            title = f"**[GROUP]** `{cmd.qualified_name}` help page"

        em = embeds.Embed(title=title,
                          description=cmd.brief,
                          colour=colour,
                          timestamp=None)

        em.add_field(
            name="Usage",
            value=f"```md\n{prefix}{cmd.qualified_name} {cmd.signature}```")

        em.add_field(name="Full Description",
                     value=f"{cmd.help or '`No description set yet`'}")
        em.add_field(name="Category",
                     value=f"`{cmd.cog_name}`" or "`Unsorted`")

        if isinstance(cmd, _commands.Group):
            child_commands_short_info = {
                f"\N{BULLET} `{c.name}` - {c.brief}"
                for c in sorted(cmd.commands, key=str)
                if isinstance(c, _commands.Command)
            }
            child_groups_short_info = {
                f"\N{BULLET} `{c.name}` - {c.brief}"
                for c in sorted(cmd.commands, key=str)
                if isinstance(c, _commands.Group)
            }
            if child_groups_short_info:
                em.add_field(name="Subgroups",
                             value=strings.pretty_list(child_groups_short_info,
                                                       sep="\n"))
            em.add_field(name="Subcommands",
                         value=strings.pretty_list(child_commands_short_info,
                                                   sep="\n"))
        return em