当前位置: 首页>>代码示例>>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;未经允许,请勿转载。