本文整理汇总了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)
示例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
示例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)
示例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
示例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
示例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)
示例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)
示例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
示例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)
示例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'))
示例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
示例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
示例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
示例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
示例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)