Python discord.ext.commands.Group() Examples
The following are 27
code examples of discord.ext.commands.Group().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
discord.ext.commands
, or try the search function
.
Example #1
Source File: help.py From bot with MIT License | 6 votes |
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)
Example #2
Source File: gen_command_json.py From avrae with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: admin.py From xenon with GNU General Public License v3.0 | 6 votes |
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)
Example #4
Source File: leveler.py From Maybe-Useful-Cogs with MIT License | 5 votes |
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
Example #5
Source File: _utils.py From Dozer with GNU General Public License v3.0 | 5 votes |
def group(**kwargs): """Links command groups""" kwargs.setdefault('cls', Group) return commands.group(**kwargs)
Example #6
Source File: _utils.py From Dozer with GNU General Public License v3.0 | 5 votes |
def group(self, *args, **kwargs): """Initiates a command group""" kwargs.setdefault('cls', Group) return super(Group, self).command(*args, **kwargs)
Example #7
Source File: _utils.py From Dozer with GNU General Public License v3.0 | 5 votes |
def command(self, *args, **kwargs): """Initiates a command""" kwargs.setdefault('cls', Command) return super(Group, self).command(*args, **kwargs)
Example #8
Source File: general.py From Dozer with GNU General Public License v3.0 | 5 votes |
def _help_command(self, ctx, command): """Gets the help message for one command.""" info = discord.Embed(title='Command: {}{} {}'.format(ctx.prefix, command.qualified_name, command.signature), description=command.help or (None if command.example_usage else 'No information provided.'), color=discord.Color.blue()) usage = command.example_usage if usage: info.add_field(name='Usage', value=usage.format(prefix=ctx.prefix, name=ctx.invoked_with), inline=False) info.set_footer(text='Dozer Help | {!r} command | Info'.format(command.qualified_name)) await self._show_help(ctx, info, 'Subcommands: {prefix}{name} {signature}', '', '{name!r} command', command.commands if isinstance(command, Group) else set(), name=command.qualified_name, signature=command.signature)
Example #9
Source File: mm.py From SML-Cogs with MIT License | 5 votes |
def mmset_macro(self, ctx): """Add / remove macro.""" if ctx.invoked_subcommand is None or \ isinstance(ctx.invoked_subcommand, commands.Group): await self.bot.send_cmd_help(ctx)
Example #10
Source File: channelmanager.py From SML-Cogs with MIT License | 5 votes |
def move(self, ctx): """Move channel.""" if ctx.invoked_subcommand is None or isinstance(ctx.invoked_subcommand, commands.Group): await self.bot.send_cmd_help(ctx)
Example #11
Source File: channelmanager.py From SML-Cogs with MIT License | 5 votes |
def create(self, ctx): """Create Channel.""" if ctx.invoked_subcommand is None or isinstance(ctx.invoked_subcommand, commands.Group): await self.bot.send_cmd_help(ctx)
Example #12
Source File: search.py From SML-Cogs with MIT License | 5 votes |
def setsearch_imgur(self, ctx: Context): """Set imgur api settings.""" if ctx.invoked_subcommand is None or\ isinstance(ctx.invoked_subcommand, commands.Group): await send_cmd_help(ctx)
Example #13
Source File: feedback.py From SML-Cogs with MIT License | 5 votes |
def setfeedback_removerole(self, ctx: Context): """Add roles.""" if ctx.invoked_subcommand is None or\ isinstance(ctx.invoked_subcommand, commands.Group): await send_cmd_help(ctx)
Example #14
Source File: feedback.py From SML-Cogs with MIT License | 5 votes |
def setfeedback_addrole(self, ctx: Context): """Set feedback role permissions.""" if ctx.invoked_subcommand is None or\ isinstance(ctx.invoked_subcommand, commands.Group): await send_cmd_help(ctx)
Example #15
Source File: meta.py From EmoteCollector with GNU Affero General Public License v3.0 | 5 votes |
def subcommand_not_found(self, command, subcommand): if isinstance(command, commands.Group) and len(command.all_commands) > 0: return _('Command "{command.qualified_name}" has no subcommand named {subcommand}').format(**locals()) return _('Command "{command.qualified_name}" has no subcommands.').format(**locals())
Example #16
Source File: permissions.py From Squid-Plugins with MIT License | 5 votes |
def role(self, ctx): """Role based permissions Overrides channel based permissions""" if ctx.invoked_subcommand is None or \ isinstance(ctx.invoked_subcommand, commands.Group): await send_cmd_help(ctx)
Example #17
Source File: permissions.py From Squid-Plugins with MIT License | 5 votes |
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)
Example #18
Source File: welcome.py From Dumb-Cogs with MIT License | 5 votes |
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
Example #19
Source File: leveler.py From Maybe-Useful-Cogs with MIT License | 5 votes |
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
Example #20
Source File: leveler.py From Maybe-Useful-Cogs with MIT License | 5 votes |
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
Example #21
Source File: leveler.py From Maybe-Useful-Cogs with MIT License | 5 votes |
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
Example #22
Source File: misc.py From RPGBot with GNU General Public License v3.0 | 5 votes |
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'))
Example #23
Source File: help.py From avrae with GNU General Public License v3.0 | 5 votes |
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)
Example #24
Source File: help.py From bot with MIT License | 5 votes |
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
Example #25
Source File: repl.py From Dumb-Cogs with MIT License | 5 votes |
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)
Example #26
Source File: adventure.py From Dumb-Cogs with MIT License | 5 votes |
def team_list(self, ctx): if ctx.invoked_subcommand is None or \ isinstance(ctx.invoked_subcommand, commands.Group): await send_cmd_help(ctx)
Example #27
Source File: welcome.py From Dumb-Cogs with MIT License | 5 votes |
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