diff options
| author | Rapptz <[email protected]> | 2016-01-04 23:37:12 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-01-04 23:37:12 -0500 |
| commit | e08d643a7ff43e80904b451a00e7188d68e84c99 (patch) | |
| tree | b0df5f0e076ae1f6986062aea69a9162a248a738 | |
| parent | Use setuputils.find_package to find extension modules. (diff) | |
| download | discord.py-e08d643a7ff43e80904b451a00e7188d68e84c99.tar.xz discord.py-e08d643a7ff43e80904b451a00e7188d68e84c99.zip | |
[commands] Add a way to remove commands.
| -rw-r--r-- | discord/ext/commands/core.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 2c0bf2d0..9035cf33 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -260,6 +260,25 @@ class GroupMixin: raise discord.ClientException('The alias {} is already an existing command or alias.'.format(alias)) self.commands[alias] = command + def remove_command(self, name): + """Remove a :class:`Command` or subclasses from the internal list + of commands. + + This could also be used as a way to remove aliases. + + Parameters + ----------- + name : str + The name of the command to remove. + + Returns + -------- + Command or subclass + The command that was removed. If the name is not valid then + `None` is returned instead. + """ + return self.commands.pop(name, None) + def command(self, *args, **kwargs): """A shortcut decorator that invokes :func:`command` and adds it to the internal command list via :meth:`add_command`. |