示例#1
0
    async def send_cog_help(self, cog: commands.Cog) -> None:
        embed = discord.Embed(title=f"{cog.qualified_name} Help", description=self.get_ending_note(), color=self.color)

        field_value = self.command_lister(cog.get_commands()) if cog.get_commands() else "No commands!"
        embed.add_field(name="Commands:", value=field_value)

        await self.get_destination().send(embed=embed)
示例#2
0
def brief_cog(cog: Cog):
    brief = literals('cog_brief')['no_description']
    if cog.description is not None:
        brief = cog.description
    elif cog.get_commands():
        brief = ''
    if not cog.get_commands():
        return brief
    commands = ''
    for command in cog.get_commands():
        commands += brief_command(command) + '\n'
    if commands:
        brief += '\n' + commands
    return brief
示例#3
0
 async def send_cog_help(self, cog: commands.Cog):
     async with self.get_destination().typing():
         filtered = await self.filter_commands(
             cog.get_commands(), sort=self.sort_commands
         )
         self.paginator.add_cog(cog, filtered)
     await self.send_pages()
示例#4
0
    async def cog(self, ctx, cog: commands.Cog):
        "return cog commands"

        emb = discord.Embed(title=cog.qualified_name,
                            description="",
                            colour=discord.Colour.from_hsv(
                                random.random(), 1, 1),
                            timestamp=ctx.message.created_at)
        emb.set_author(name=ctx.author,
                       icon_url=str(
                           ctx.author.avatar_url_as(static_format="png")))

        commands = cog.get_commands()
        commands = [cmd for cmd in commands if not cmd.hidden]

        cog_str = ""

        if len(commands) >= 1:
            for command in commands:
                cog_str += f"{self.bot.clean_prefix}{command.name} {command.signature}\n" if command.signature else f"{self.bot.clean_prefix}{command.name}\n"

                try:
                    for cmd in command.commands:
                        cog_str += f"{self.bot.clean_prefix}{cmd.parent} {cmd.name} {cmd.signature}\n" if command.signature else f"{self.bot.clean_prefix}{cmd.parent} {cmd.name}\n"
                except:
                    pass

            emb.description = f"```prolog\n{cog_str}\n```"

        else:
            return await self.cog_not_found(ctx, cog.qualified_name)

        return await ctx.send(embed=emb)
示例#5
0
 async def send_cog_help(self, cog: commands.Cog) -> None:
     """Send help for a cog."""
     ctx = self.context
     prefix = ctx.prefix
     embed = discord.Embed(
         title=cog.qualified_name,
         description=textwrap.dedent(
             f"""
             Help syntax : `<Required argument>`. `[t.Optional argument]`
             Command prefix: `{prefix}`
             {cog.description}
             """
         ),
         color=discord.Color.blue(),
     )
     embed.set_author(
         name=str(ctx.message.author),
         icon_url=str(ctx.message.author.avatar_url),
     )
     embed.set_thumbnail(url=str(ctx.bot.user.avatar_url))
     for command in await self.filter_commands(cog.get_commands()):
         embed.add_field(
             name=f"{prefix}{self.get_command_signature(command)}",
             value=command.help,
             inline=False,
         )
     embed.set_footer(
         text=f"Are you interested in {cog.qualified_name}?",
         icon_url=str(ctx.bot.user.avatar_url),
     )
     await ctx.send(embed=embed)
示例#6
0
    async def send_cog_help(self, cog: Cog):
        """
        Async method that will send the specified Cog info in embed format

        Parameters
        ----------
        cog: Cog
            the cog requesting more info for
        """
        if self.checked():
            return

        embed = discord.Embed(colour=self.paginator.color,
                              title=f"**__{cog.qualified_name}__** Cog",
                              description="__Commands__:")

        filtered = await self.filter_commands(cog.get_commands(),
                                              sort=self.sort_commands)
        result = process_command_list(embed, filtered)
        icon = self.context.bot.user.avatar_url_as(size=64)

        for i in range(len(result)):
            result[i].set_footer(icon_url=icon,
                                 text=f"{i + 1} / {len(result)} Pages")
            await (self.context.author.send(embed=result[i])
                   if self.dm_help else self.context.reply(embed=result[i]))
 async def send_cog_help(self, cog: commands.Cog) -> None:
     # Test if the current channel is correct
     result = await self.channelCheck()
     if result is None:
         # Create embed
         cogHelpEmbed = Embed(
             title=f"{self.getCogName(cog.qualified_name)} Help",
             colour=self.colour)
         cogHelpEmbed.set_footer(text=f"{len(cog.get_commands())} commands")
         for command in cog.get_commands():
             # Create aliases string
             aliases = self.createAliases(command)
             if aliases is not None:
                 cogHelpEmbed.add_field(
                     name=f"{self.clean_prefix}{command.qualified_name}",
                     value=f"{command.help}\n\n{aliases}",
                     inline=False)
             else:
                 cogHelpEmbed.add_field(
                     name=f"{self.clean_prefix}{command.qualified_name}",
                     value=f"{command.help}",
                     inline=False)
         # Send embed
         channel = self.get_destination()
         await channel.send(embed=cogHelpEmbed)
     else:
         await Utils.commandDebugEmbed(self.get_destination(), result)
示例#8
0
 async def send_cog_help(self, cog: Cog, /):
     """Function that triggers when help command is used with a cog."""
     full_mapping = {
         com
         for com in cog.get_commands() if com.enabled and not com.hidden
     }
     await self._send_command_list(full_mapping)
示例#9
0
 async def send_cog_help(self, cog: commands.Cog):
     if cog.qualified_name != "System":
         embed = discord.Embed()
         embed.colour = discord.Colour.dark_gold()
         embed.title = cog.qualified_name
         embed.set_author(name=self.context.bot.user.name,
                          icon_url=self.context.bot.user.avatar_url)
         for command in cog.get_commands():
             if command is not None and command in await self.filter_commands(
                     cog.get_commands()):
                 embed.add_field(name=command.name,
                                 value=command.help,
                                 inline=False)
         await self.context.send(embed=embed)
     else:
         await self.context.send("There is no cog named System!")
示例#10
0
    async def send_cog_help(self, cog: commands.Cog):
        locale = self.context.bot.system.locale
        e = discord.Embed()

        fmt = locale("__{0} help__\n").format(
            getattr(cog, "locale_name", cog.qualified_name))

        cmds = await self.filter_commands(cog.get_commands())
        if not cmds:
            return await self.context.send(
                self.command_not_found(cog.qualified_name))

        for command in cmds:
            sig = self.get_command_signature(command)
            fmt += "|- " + sig + "\n"
            if command.short_doc:
                fmt += "|  | " + command.short_doc + "\n"

            if isinstance(command, GroupWithLocale):
                subs = command.commands
                for sub in subs:
                    fmt += "|  |- " + self.get_command_signature(sub) + "\n"

        e.description = fmt

        await self.context.send(embed=e)
示例#11
0
    async def send_cog_help(self, cog: commands.Cog):
        """The coroutine to run when requested help for a Cog
        
        Parameters
        ----------
        cog: discord.ext.commands.Cog
            The cog requested
        """

        cmds = cog.get_commands()

        # filter commands for the ones that pass all checks
        cmds = await self.filter_commands(cmds, sort=True)

        pages = []
        current_page = []
        if len(cmds) > per_page:

            # splits the cog into multiple pages
            for i in range(0, len(cmds), per_page):
                end_index = i + per_page
                current_page.append((cog, cmds[i:end_index]))
                pages.append(current_page)

        else:
            current_page.append((cog, cmds))
            pages.append(current_page)

        paginator = BotOrCogHelp(self, self.context.bot, self.context, pages)

        await paginator.paginate()
示例#12
0
    async def cog(self, ctx, cog: commands.Cog):
        "return cog commands"

        def __init__(self, description=None):
            self.description = description

        emb = discord.Embed(title=cog.qualified_name,
                            description="",
                            colour=self.bot.colour,
                            timestamp=ctx.message.created_at)
        emb.set_author(name=ctx.author,
                       icon_url=str(
                           ctx.author.avatar_url_as(static_format="png")))

        commands = cog.get_commands()
        commands = [cmd for cmd in commands if not cmd.hidden]

        cog_str = f"**{cog.qualified_name.upper()}**\n"

        if len(commands) >= 1:
            for command in commands:
                cog_str += f"`{command.name} {command.signature}` " if command.signature else f"`{command.name}` "

                try:
                    for cmd in command.commands:
                        cog_str += f"`{cmd.parent} {cmd.name} {cmd.signature}` " if command.signature else f"`{cmd.parent} {cmd.name}` "
                except:
                    pass

            emb.description = cog_str

        else:
            return await self.cog_not_found(ctx, cog.qualified_name)

        return await ctx.send(embed=emb)
示例#13
0
文件: help.py 项目: vivax3794/ABGDB
 async def send_cog_help(self, cog: commands.Cog) -> None:
     allowed_commands = await self.filter_commands(cog.get_commands())
     embed = discord.Embed(title=cog.qualified_name,
                           description="\n".join(
                               f"`{command.name}` - {command.short_doc}"
                               for command in allowed_commands),
                           color=discord.Color.blue())
     await self.send_embed(embed)
示例#14
0
    def build_list_cog_help(self, cog: commands.Cog) -> str:
        result_string = f'{self.emoji_mapping[cog.qualified_name]} Here is a list of commands in the `{cog.qualified_name}` category\n'

        cmds: List[commands.Command] = sorted(cog.get_commands(),
                                              key=lambda x: x.name)
        for cmd in cmds:
            result_string += f'`{cmd.name}` - {cmd.description}\n'
        return result_string
示例#15
0
 async def send_cog_help(self, cog: commands.Cog):
     embed = self.embed
     embed.set_author(name=f"Commands in the {cog.qualified_name} Category")
     embed.description = f"Use `{self.context.bot.command_prefix}help [command]` for more information."
     for cmd in cog.get_commands():
         embed.add_field(name=f"`{self.get_cmd_string(cmd)}`",
                         value=cmd.brief if cmd.brief else cmd.help,
                         inline=False)
     await self.get_destination().send(embed=embed)
示例#16
0
    def __init__(self, cog: Cog, prefix: str, *, per_page=3):
        if not isinstance(cog, Cog):
            raise TypeError("a valid cog wasn't passed")

        self._prefix = prefix
        self._doc = Embed(title=cog.qualified_name,
                          description=cog.description,
                          color=get_color())
        super().__init__(cog.get_commands(), per_page=per_page)
示例#17
0
def get_cog_commands(cog: Cog, include_hidden=False) -> Dict[str, Command]:
    commands = {}
    for command in cog.get_commands():
        hidden = command.hidden if not include_hidden else False
        if not hidden:
            commands[command.name] = command
        if isinstance(command, Group):
            commands.update(get_group_commands(command))
    return commands
示例#18
0
文件: help.py 项目: kal-byte/test-bot
    async def send_cog_help(self, cog: commands.Cog):
        embed = discord.Embed(title=f"Help for {cog.qualified_name}")
        for command in cog.get_commands():
            embed.add_field(
                name=self.get_command_signature(command),
                value=command.short_doc or "No help provided...",
                inline=False,
            )

        await self.get_destination().send(embed=embed)
 async def send_cog_help(self, cog: commands.Cog):
     if cog.qualified_name != "System":
         embed = discord.Embed()
         embed.colour = discord.Colour.dark_gold()
         embed.title = cog.qualified_name
         embed.description = cog.__doc__.format(prefix_1=self.clean_prefix) if cog.__doc__ else "Information about this module not available. Owner has forgot to add " \
                                                                                                "information to this cog or he may be adding information to the cog."
         embed.set_author(name=self.context.bot.user.name,
                          icon_url=self.context.bot.user.avatar_url)
         for command in cog.get_commands():
             if command is not None and command in await self.filter_commands(
                     cog.get_commands()):
                 embed.add_field(
                     name=f"`{self.clean_prefix}{command.name}`",
                     value=command.help,
                     inline=False)
         await self.context.send(embed=embed)
     else:
         await self.context.send("There is no cog named System!")
示例#20
0
    async def send_cog_help(self, cog: commands.Cog):
        """Sends help for an entire cog.

        Args:
            cog (commands.Cog): The cog to send help for.
        """
        async with self.get_destination().typing():
            filtered = await self.filter_commands(cog.get_commands(),
                                                  sort=self.sort_commands)
            self.paginator.add_cog(cog, filtered)
        await self.send_pages()
示例#21
0
    async def send_cog_help(self, cog: commands.Cog):
        ctx = self.context
        embed = discord.Embed(title=f"Help for {cog.qualified_name}")
        embed.set_footer(text=f"Do {self.clean_prefix}help [command] for more help")

        entries = await self.filter_commands(cog.get_commands(), sort=True)
        for cmd in entries:
            embed.add_field(name=f"{self.clean_prefix}{cmd.name} {cmd.signature}",
                            value=f"{cmd.help}",
                            inline=False)

        await ctx.send(embed=embed)
示例#22
0
    async def send_cog_help(self, cog: commands.Cog):
        e = discord.Embed(title=cog.qualified_name,
                          description=cog.description or 'No help provided.')

        filtered = await self.filter_commands(cog.get_commands(), sort=True)

        if filtered:
            for command in filtered:
                e.add_field(name=self.get_command_signature(command),
                            value=command.short_doc or 'No help provided.')

        await self.context.send(embed=e)
示例#23
0
    async def send_cog_help(self, cog: Cog):
        if cog.description:
            self.paginator.add_line(cog.description, empty=True)

        filtered = await self.filter_commands(cog.get_commands())
        await self.add_commands_recursive(filtered)

        note = self.get_ending_note()
        if note:
            self.paginator.add_line()
            self.paginator.add_line(note)

        await self.send_pages()
示例#24
0
    async def send_cog_help(self, cog: commands.Cog):
        pages = []

        await self.format_commands(
            cog, await self.filter_commands(cog.get_commands(), sort=True), pages=pages
        )

        total = len(pages)
        for i, embed in enumerate(pages, start=1):
            embed.title = f"Page {i}/{total}: {embed.title}"

        pg = RoboPages(HelpSource(range(0, len(pages)), pages))
        await pg.start(self.context)
示例#25
0
文件: help.py 项目: mvettosi/teambot
    async def send_cog_help(self, cog: Cog) -> None:
        title = f'{cog.qualified_name} Commands'
        embed = discord.Embed(title=title,
                              description=cog.description,
                              colour=config.BOT_COLOR)

        filtered = await self.filter_commands(cog.get_commands(), sort=True)
        for command in filtered:
            field_name = self.get_command_signature(command)
            field_desc = command.short_doc or 'No short description yet'
            embed.add_field(name=field_name, value=field_desc, inline=False)

        await self.get_destination().send(embed=embed)
示例#26
0
    async def send_cog_help(self, cog: Cog) -> None:
        """Send help for a cog."""
        commands = await self.filter_commands(cog.get_commands(), sort=True)

        embed = discord.Embed()
        embed.set_author(name='Command Help')
        embed.description = f'**{cog.qualified_name}**\n*{cog.description}*'

        command_details = self.get_command_details(commands)
        if command_details:
            embed.description += f'\n\n**Commands:**\n{command_details}'

        message = await self.context.send(embed=embed)
        await help_cleanup(self.context.bot, self.context.author, message)
示例#27
0
文件: bot.py 项目: 5t0n3/AuthBot
    async def send_cog_help(self, cog: commands.Cog):
        help_embed = discord.Embed(title=f"{cog.qualified_name} Help",
                                   color=discord.Color.gold())

        # Subcommands are omitted so the embed isn't too long
        for cmd in cog.get_commands():
            help_embed.add_field(
                name=f"`{self.context.prefix}{cmd.qualified_name}`",
                value=cmd.short_doc or "None",
                inline=False)

        await self.context.send(embed=help_embed)

        return None
示例#28
0
    async def send_cog_help(self, cog: commands.Cog):
        filtered = await self.filter_commands(cog.get_commands())
        embed = discord.Embed(title=f"Commands in `{cog.qualified_name}`",
                              colour=0xd7342a)

        embed.set_footer(icon_url=self.context.bot.user.avatar_url,
                         text=f"Comrade Bot, Version {version}")

        command: commands.Command
        for command in filtered:
            embed.add_field(name="`" + command.qualified_name + "`",
                            value=command.short_doc)

        await self.context.send(embed=embed)
示例#29
0
    async def send_cog_help(self, cog: commands.Cog):
        self.embed.title = f"Help: {cog.qualified_name}"
        self.embed.description = cog.description

        paginator = self.get_paginator()

        commands = await self.filter_commands(cog.get_commands(), sort=True)
        for command in commands:
            paginator.add_field(
                name=f"{self.get_command_signature(command)}",
                value=command.short_doc,
                inline=False,
            )

        await paginator.send(self.context)
示例#30
0
 async def send_cog_help(self, cog: commands.Cog):
     embed = discord.Embed(
         title=f"Help for the `{cog.qualified_name}` catagory.",
         colour=0xDFCFBE)
     for command in cog.get_commands():
         embed.add_field(
             name=command.name,
             value=command.help or "No description for this command",
             inline=False,
         )
     if len(embed.fields) >= 5:
         view = PaginatedView.from_embed(self.context, embed, 4)
         await view.start()
     else:
         await self.get_destination().send(embed=embed)