Skip to content

Commit

Permalink
fix: enum options breaking & incorrect...
Browse files Browse the repository at this point in the history
typing import
  • Loading branch information
Middledot authored and Lulalaby committed Aug 1, 2022
1 parent a8a4a29 commit fde4ded
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions discord/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def __init__(self, input_type: InputType = str, /, description: Optional[str] =
if self.name is not None:
self.name = str(self.name)
self._parameter_name = self.name # default
self._raw_type: Union[InputType, tuple] = input_type

enum_choices = []
input_type_is_class = isinstance(input_type, type)
Expand All @@ -177,13 +178,12 @@ def __init__(self, input_type: InputType = str, /, description: Optional[str] =
enum_choices = [OptionChoice(e.name, e.value) for e in input_type]
value_class = enum_choices[0].value.__class__
if all(isinstance(elem.value, value_class) for elem in enum_choices):
self.input_type = SlashCommandOptionType.from_datatype(enum_choices[0].value.__class__)
input_type = SlashCommandOptionType.from_datatype(enum_choices[0].value.__class__)
else:
enum_choices = [OptionChoice(e.name, str(e.value)) for e in input_type]
self.input_type = SlashCommandOptionType.string
self.description = description or "No description provided"
input_type = SlashCommandOptionType.string

self._raw_type: Union[InputType, tuple] = input_type
self.description = description or "No description provided"
self.channel_types: List[ChannelType] = kwargs.pop("channel_types", [])

if isinstance(input_type, SlashCommandOptionType):
Expand Down
2 changes: 1 addition & 1 deletion discord/shard.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

from .backoff import ExponentialBackoff
from .client import Client
from .enums import Status
from .errors import (
ClientException,
ConnectionClosed,
Expand All @@ -55,7 +56,6 @@

if TYPE_CHECKING:
from .activity import BaseActivity
from .enums import Status
from .gateway import DiscordWebSocket

EI = TypeVar("EI", bound="EventItem")
Expand Down

0 comments on commit fde4ded

Please sign in to comment.