當前位置: 首頁>>代碼示例>>Python>>正文


Python commands.Group方法代碼示例

本文整理匯總了Python中discord.ext.commands.Group方法的典型用法代碼示例。如果您正苦於以下問題:Python commands.Group方法的具體用法?Python commands.Group怎麽用?Python commands.Group使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在discord.ext.commands的用法示例。


在下文中一共展示了commands.Group方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send_group_help

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def send_group_help(self, group: Group) -> None:
        """Sends help for a group command."""
        subcommands = group.commands

        if len(subcommands) == 0:
            # no subcommands, just treat it like a regular command
            await self.send_command_help(group)
            return

        # remove commands that the user can't run and are hidden, and sort by name
        commands_ = await self.filter_commands(subcommands, sort=True)

        embed = await self.command_formatting(group)

        command_details = self.get_commands_brief_details(commands_)
        if command_details:
            embed.description += f"\n**Subcommands:**\n{command_details}"

        message = await self.context.send(embed=embed)
        await help_cleanup(self.context.bot, self.context.author, message) 
開發者ID:python-discord,項目名稱:bot,代碼行數:22,代碼來源:help.py

示例2: parse_command

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def parse_command(command):
    """
    :type command discord.ext.commands.Command
    """
    subcommands = []
    if isinstance(command, Group):
        commands = sorted(command.commands, key=lambda c: c.name)
        for subcommand in commands:
            subcommands.append(parse_command(subcommand))

    arguments = parse_command_args(command)
    command_meta = {
        "name": command.name,
        "short": command.short_doc,
        "docs": command.help,
        "args": arguments,
        "signature": get_command_signature(command),
        "subcommands": subcommands,
        "example": ""
    }
    return command_meta 
開發者ID:avrae,項目名稱:avrae,代碼行數:23,代碼來源:gen_command_json.py

示例3: sudo

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def sudo(self, ctx, *, command):
        """
        Execute a command and bypass cooldown


        __Arguments__

        **command**: The command
        """
        message = ctx.message
        message.content = command

        new_ctx = await self.bot.get_context(message, cls=context.Context)
        new_ctx.command.reset_cooldown(new_ctx)
        if isinstance(new_ctx.command, cmd.Group):
            for command in new_ctx.command.all_commands.values():
                command.reset_cooldown(new_ctx)

        await self.bot.invoke(new_ctx) 
開發者ID:Xenon-Bot,項目名稱:xenon,代碼行數:21,代碼來源:admin.py

示例4: welcomeset_msg

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def welcomeset_msg(self, ctx):
        """Manage welcome messages
        """
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx)
            return 
開發者ID:irdumbs,項目名稱:Dumb-Cogs,代碼行數:9,代碼來源:welcome.py

示例5: welcomeset_bot

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def welcomeset_bot(self, ctx):
        """Special welcome for bots"""
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx)
            return 
開發者ID:irdumbs,項目名稱:Dumb-Cogs,代碼行數:8,代碼來源:welcome.py

示例6: team_list

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def team_list(self, ctx):
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx) 
開發者ID:irdumbs,項目名稱:Dumb-Cogs,代碼行數:6,代碼來源:adventure.py

示例7: replset_print

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def replset_print(self, ctx):
        """Sets where repl content goes when response is too large."""
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx) 
開發者ID:irdumbs,項目名稱:Dumb-Cogs,代碼行數:7,代碼來源:repl.py

示例8: get_all_help_choices

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def get_all_help_choices(self) -> set:
        """
        Get all the possible options for getting help in the bot.

        This will only display commands the author has permission to run.

        These include:
        - Category names
        - Cog names
        - Group command names (and aliases)
        - Command names (and aliases)
        - Subcommand names (with parent group and aliases for subcommand, but not including aliases for group)

        Options and choices are case sensitive.
        """
        # first get all commands including subcommands and full command name aliases
        choices = set()
        for command in await self.filter_commands(self.context.bot.walk_commands()):
            # the the command or group name
            choices.add(str(command))

            if isinstance(command, Command):
                # all aliases if it's just a command
                choices.update(command.aliases)
            else:
                # otherwise we need to add the parent name in
                choices.update(f"{command.full_parent_name} {alias}" for alias in command.aliases)

        # all cog names
        choices.update(self.context.bot.cogs)

        # all category names
        choices.update(cog.category for cog in self.context.bot.cogs.values() if hasattr(cog, "category"))
        return choices 
開發者ID:python-discord,項目名稱:bot,代碼行數:36,代碼來源:help.py

示例9: add_commands

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def add_commands(self, commands, *, heading):
        """Adds a list of formatted commands under a field title."""
        if not commands:
            return

        self.embed_paginator.add_field(name=heading)

        for command in commands:
            if isinstance(command, Group):
                name = f"**__{command.name}__**"
            else:
                name = f"**{command.name}**"
            entry = f"{name} - {command.short_doc}"
            self.embed_paginator.extend_field(entry) 
開發者ID:avrae,項目名稱:avrae,代碼行數:16,代碼來源:help.py

示例10: makedoc

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def makedoc(self, ctx):
        cogs = {name: {} for name in ctx.bot.cogs.keys()}

        all_commands = []
        for command in ctx.bot.commands:
            all_commands.append(command)
            if isinstance(command, commands.Group):
                all_commands.extend(command.commands)

        for c in all_commands:
            if c.cog_name not in cogs or c.help is None or c.hidden:
                continue
            if c.qualified_name not in cogs[c.cog_name]:
                skip = False
                for ch in c.checks:
                    if 'is_owner' in repr(ch):  # mine. don't put on docs
                        skip = True
                if skip:
                    continue
                help = c.help.replace('\n\n', '\n>')
                cogs[c.cog_name][
                    c.qualified_name] = f'#### {c.qualified_name}\n>**Description:** {help}\n\n>**Usage:** `{ctx.prefix + c.signature}`'

        index = '\n\n# Commands\n\n'
        data = ''

        for cog in sorted(cogs):
            index += '- [{0} Commands](#{1})\n'.format(cog, (cog + ' Commands').replace(' ', '-').lower())
            data += '## {0} Commands\n\n'.format(cog)
            extra = inspect.getdoc(ctx.bot.get_cog(cog))
            if extra is not None:
                data += '#### ***{0}***\n\n'.format(extra)

            for command in sorted(cogs[cog]):
                index += '  - [{0}](#{1})\n'.format(command, command.replace(' ', '-').lower())
                data += cogs[cog][command] + '\n\n'

        fp = io.BytesIO((index.rstrip() + '\n\n' + data.strip()).encode('utf-8'))
        await ctx.author.send(file=discord.File(fp, 'commands.md')) 
開發者ID:henry232323,項目名稱:RPGBot,代碼行數:41,代碼來源:misc.py

示例11: profileset

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def profileset(self, ctx):
        """Profile options"""
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx)
            return 
開發者ID:AznStevy,項目名稱:Maybe-Useful-Cogs,代碼行數:8,代碼來源:leveler.py

示例12: rankset

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def rankset(self, ctx):
        """Rank options"""
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx)
            return 
開發者ID:AznStevy,項目名稱:Maybe-Useful-Cogs,代碼行數:8,代碼來源:leveler.py

示例13: levelupset

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def levelupset(self, ctx):
        """Level-Up options"""
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx)
            return 
開發者ID:AznStevy,項目名稱:Maybe-Useful-Cogs,代碼行數:8,代碼來源:leveler.py

示例14: lvladminbg

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def lvladminbg(self, ctx):
        """Admin Background Configuration"""
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx)
            return 
開發者ID:AznStevy,項目名稱:Maybe-Useful-Cogs,代碼行數:8,代碼來源:leveler.py

示例15: channel

# 需要導入模塊: from discord.ext import commands [as 別名]
# 或者: from discord.ext.commands import Group [as 別名]
def channel(self, ctx):
        """Channel based permissions

        Will be overridden by role based permissions."""
        if ctx.invoked_subcommand is None or \
                isinstance(ctx.invoked_subcommand, commands.Group):
            await send_cmd_help(ctx) 
開發者ID:tekulvw,項目名稱:Squid-Plugins,代碼行數:9,代碼來源:permissions.py


注:本文中的discord.ext.commands.Group方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。