Browse Source

[commands] Pass failed argument's value to BadLiteralArgument

pull/9292/head
Soheab_ 2 years ago
committed by GitHub
parent
commit
a938b10e5a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      discord/ext/commands/converter.py
  2. 7
      discord/ext/commands/errors.py

2
discord/ext/commands/converter.py

@ -1330,7 +1330,7 @@ async def run_converters(ctx: Context[BotT], converter: Any, argument: str, para
return value
# if we're here, then we failed to match all the literals
raise BadLiteralArgument(param, literal_args, errors)
raise BadLiteralArgument(param, literal_args, errors, argument)
# This must be the last if-clause in the chain of origin checking
# Nearly every type is a generic type within the typing library

7
discord/ext/commands/errors.py

@ -920,12 +920,17 @@ class BadLiteralArgument(UserInputError):
A tuple of values compared against in conversion, in order of failure.
errors: List[:class:`CommandError`]
A list of errors that were caught from failing the conversion.
argument: :class:`str`
The argument's value that failed to be converted. Defaults to an empty string.
.. versionadded:: 2.3
"""
def __init__(self, param: Parameter, literals: Tuple[Any, ...], errors: List[CommandError]) -> None:
def __init__(self, param: Parameter, literals: Tuple[Any, ...], errors: List[CommandError], argument: str = "") -> None:
self.param: Parameter = param
self.literals: Tuple[Any, ...] = literals
self.errors: List[CommandError] = errors
self.argument: str = argument
to_string = [repr(l) for l in literals]
if len(to_string) > 2:

Loading…
Cancel
Save