Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2938](https://github.com/Pycord-Development/pycord/pull/2938))
- Fixed a KeyError when a text input is left blank in a modal.
([#2938](https://github.com/Pycord-Development/pycord/pull/2938))
- Fixed `TypeError` when using Python 3.12+ `type` syntax for typing slash command
parameters. ([#2952](https://github.com/Pycord-Development/pycord/pull/2952))

### Removed

Expand Down
17 changes: 16 additions & 1 deletion discord/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@
import logging
import types
from enum import Enum
from typing import TYPE_CHECKING, Literal, Optional, Type, Union, get_args
from typing import (
TYPE_CHECKING,
Literal,
Optional,
Type,
TypeAliasType,
Union,
get_args,
)

from ..abc import GuildChannel, Mentionable
from ..channel import (
Expand Down Expand Up @@ -197,6 +205,7 @@ def __init__(
if self.name is not None:
self.name = str(self.name)
self._parameter_name = self.name # default
input_type = self._parse_type_alias(input_type)
input_type = self._strip_none_type(input_type)
self._raw_type: InputType | tuple = input_type

Expand Down Expand Up @@ -367,6 +376,12 @@ def __init__(
if input_type is None:
raise TypeError("input_type cannot be NoneType.")

@staticmethod
def _parse_type_alias(input_type: InputType) -> InputType:
if isinstance(input_type, TypeAliasType):
return input_type.__value__
return input_type

@staticmethod
def _strip_none_type(input_type):
if isinstance(input_type, SlashCommandOptionType):
Expand Down