Browse Source

[commands] Add param attribute to MissingRequiredArgument

This should allow easier querying on what argument is missing.

Fixes #470.
pull/1278/head
Rapptz 8 years ago
parent
commit
7bc3750c27
  1. 2
      discord/ext/commands/core.py
  2. 9
      discord/ext/commands/errors.py

2
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:

9
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

Loading…
Cancel
Save