[commands] Properly use Optional's default value on parsing error

This commit is contained in:
Jakub Kuczys 2022-06-07 02:18:25 +02:00 committed by GitHub
parent 75d57ab3ce
commit 4e7529138c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -672,7 +672,7 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
except ArgumentParsingError as exc: except ArgumentParsingError as exc:
if self._is_typing_optional(param.annotation): if self._is_typing_optional(param.annotation):
view.index = previous view.index = previous
return None return None if param.required else await param.get_default(ctx)
else: else:
raise exc raise exc
view.previous = previous view.previous = previous