mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
[commands] reset view when Optional argument encounters parsing error
This commit is contained in:
parent
f3cb197429
commit
1d2eaf8526
@ -564,7 +564,14 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
if consume_rest_is_special:
|
if consume_rest_is_special:
|
||||||
argument = view.read_rest().strip()
|
argument = view.read_rest().strip()
|
||||||
else:
|
else:
|
||||||
argument = view.get_quoted_word()
|
try:
|
||||||
|
argument = view.get_quoted_word()
|
||||||
|
except ArgumentParsingError as exc:
|
||||||
|
if self._is_typing_optional(param.annotation):
|
||||||
|
view.index = previous
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
raise exc
|
||||||
view.previous = previous
|
view.previous = previous
|
||||||
|
|
||||||
# type-checker fails to narrow argument
|
# type-checker fails to narrow argument
|
||||||
|
Loading…
x
Reference in New Issue
Block a user