diff options
| author | Rapptz <[email protected]> | 2017-02-12 13:53:28 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-02-12 13:53:49 -0500 |
| commit | 7bc3750c273829727d33da5358e0b2477ef69ed7 (patch) | |
| tree | db8650410df88b4be2368767241b80660ce44ced | |
| parent | Implement async checks. Fixes #380. (diff) | |
| download | discord.py-7bc3750c273829727d33da5358e0b2477ef69ed7.tar.xz discord.py-7bc3750c273829727d33da5358e0b2477ef69ed7.zip | |
[commands] Add param attribute to MissingRequiredArgument
This should allow easier querying on what argument is missing.
Fixes #470.
| -rw-r--r-- | discord/ext/commands/core.py | 2 | ||||
| -rw-r--r-- | discord/ext/commands/errors.py | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 38b5ed6a..4d65f058 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -226,7 +226,7 @@ class Command: if param.kind == param.VAR_POSITIONAL: raise RuntimeError() # break the loop if required: - raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param)) + raise MissingRequiredArgument(param) return param.default if consume_rest_is_special: diff --git a/discord/ext/commands/errors.py b/discord/ext/commands/errors.py index 5aa6d164..07d38a22 100644 --- a/discord/ext/commands/errors.py +++ b/discord/ext/commands/errors.py @@ -68,8 +68,15 @@ class CommandNotFound(CommandError): class MissingRequiredArgument(UserInputError): """Exception raised when parsing a command and a parameter that is required is not encountered. + + Attributes + ----------- + param: str + The argument that is missing. """ - pass + def __init__(self, param): + self.param = param.name + super().__init__('{0.name} is a required argument that is missing.'.format(param)) class TooManyArguments(UserInputError): """Exception raised when the command was passed too many arguments and its |