diff options
| author | Rapptz <[email protected]> | 2016-01-10 22:10:42 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-01-10 22:10:42 -0500 |
| commit | 1e941925c2729690a6c3d3a5acb4bc86cf883ed0 (patch) | |
| tree | 0e44cf3f0731dffaa6241ef030be84529be2bd96 | |
| parent | [commands] Remove all aliases if the main command is being deleted. (diff) | |
| download | discord.py-1e941925c2729690a6c3d3a5acb4bc86cf883ed0.tar.xz discord.py-1e941925c2729690a6c3d3a5acb4bc86cf883ed0.zip | |
[commands] Add Command.clean_params to have nicer params.
These are params without the self/context parameters. Useful for
showing signature information in the help command without being
bogged down by knowing if the self/context parameters are there.
Hence it makes it easier to iterate knowing that you shouldn't care
about those two parameters.
| -rw-r--r-- | discord/ext/commands/core.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 8503dcaf..63f57242 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -209,6 +209,24 @@ class Command: except Exception: raise BadArgument('Converting to "{0.__name__}" failed.'.format(converter)) + @property + def clean_params(self): + """Retrieves the parameter OrderedDict without the context or self parameters. + + Useful for inspecting signature. + """ + result = self.params.copy() + if self.instance is not None: + # first parameter is self + result.popitem(last=False) + + if self.pass_context: + # first/second parameter is context + result.popitem(last=False) + + return result + + def _parse_arguments(self, ctx): try: ctx.args = [] if self.instance is None else [self.instance] |