Skip to content

Commit 678bf05

Browse files
Add support for all channel types
1 parent 9345134 commit 678bf05

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

discord/app/commands.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,17 @@ def __init__(
497497
self.name: Optional[str] = kwargs.pop("name", None)
498498
self.description = description or "No description provided"
499499

500-
self.channel_types = []
500+
self.channel_types: List[ChannelType] = kwargs.pop("channel_types", [])
501501
if not isinstance(input_type, OptionType):
502502
self.input_type = OptionType.from_datatype(input_type)
503503
if self.input_type == OptionType.channel:
504-
input_type = (input_type,) if not isinstance(input_type, tuple) else input_type
504+
if not isinstance(input_type, tuple):
505+
input_type = (input_type,)
505506
for i in input_type:
506507
if i.__name__ == 'GuildChannel':
507508
continue
508-
channel_type = channel_type_map[i.__name__].value
509+
510+
channel_type = channel_type_map[i.__name__]
509511
self.channel_types.append(channel_type)
510512
else:
511513
self.input_type = input_type
@@ -526,7 +528,7 @@ def to_dict(self) -> Dict:
526528
"choices": [c.to_dict() for c in self.choices],
527529
}
528530
if self.channel_types:
529-
as_dict["channel_types"] = self.channel_types
531+
as_dict["channel_types"] = [t.value for t in self.channel_types]
530532

531533
return as_dict
532534

discord/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def from_datatype(cls, datatype):
611611
return cls.mentionable
612612
else:
613613
raise TypeError('Invalid usage of typing.Union')
614-
614+
615615
if issubclass(datatype, str):
616616
return cls.string
617617
if issubclass(datatype, bool):

0 commit comments

Comments
 (0)