Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ def _parse_options(self, params, *, check_params: bool = True) -> list[Option]:
if option == inspect.Parameter.empty:
option = str

option = Option._strip_none_type(option)
if self._is_typing_literal(option):
literal_values = get_args(option)
if not all(isinstance(v, (str, int, float)) for v in literal_values):
Expand Down
6 changes: 3 additions & 3 deletions discord/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ def _strip_none_type(input_type):
raise TypeError("Option type cannot be only NoneType")
if len(filtered) == 1:
return filtered[0]
if all(getattr(t, "__origin__", None) is Literal for t in filtered):
return Union[filtered]
return Union[filtered]

return filtered

return input_type

def to_dict(self) -> dict:
Expand Down
Loading