mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 00:07:51 +00:00
[commands] Add param attribute to MissingRequiredArgument
This should allow easier querying on what argument is missing. Fixes #470.
This commit is contained in:
parent
47ef657fbd
commit
7bc3750c27
@ -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:
|
||||
|
@ -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…
x
Reference in New Issue
Block a user