[commands] Pass failed argument's value to BadLiteralArgument

This commit is contained in:
Soheab_ 2023-03-03 15:07:22 +01:00 committed by GitHub
parent 78099992dd
commit a938b10e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

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