diff options
| author | Sebastian Law <[email protected]> | 2021-08-19 16:56:28 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-19 19:56:28 -0400 |
| commit | 1d2eaf852627f5fe152653bae82d1a161d38b5a1 (patch) | |
| tree | e17167103a502389e6118fa788726421f98888b7 /discord/ext/commands | |
| parent | [commands][types] Type hint commands-ext (diff) | |
| download | discord.py-1d2eaf852627f5fe152653bae82d1a161d38b5a1.tar.xz discord.py-1d2eaf852627f5fe152653bae82d1a161d38b5a1.zip | |
[commands] reset view when Optional argument encounters parsing error
Diffstat (limited to 'discord/ext/commands')
| -rw-r--r-- | discord/ext/commands/core.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 88e65507..2d58f95a 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -564,7 +564,14 @@ class Command(_BaseCommand, Generic[CogT, P, T]): if consume_rest_is_special: argument = view.read_rest().strip() 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 # type-checker fails to narrow argument |