26
26
from typing import Any , Dict , List , Literal , Optional , Union
27
27
from enum import Enum
28
28
29
+ from ..abc import GuildChannel
30
+ from ..channel import TextChannel , VoiceChannel , StageChannel , CategoryChannel , Thread
29
31
from ..enums import ChannelType , SlashCommandOptionType , Enum as DiscordEnum
30
32
31
33
__all__ = (
35
37
"option" ,
36
38
)
37
39
38
- channel_type_map = {
39
- " TextChannel" : ChannelType .text ,
40
- " VoiceChannel" : ChannelType .voice ,
41
- " StageChannel" : ChannelType .stage_voice ,
42
- " CategoryChannel" : ChannelType .category ,
43
- " Thread" : ChannelType .public_thread ,
40
+ CHANNEL_TYPE_MAP = {
41
+ TextChannel : ChannelType .text ,
42
+ VoiceChannel : ChannelType .voice ,
43
+ StageChannel : ChannelType .stage_voice ,
44
+ CategoryChannel : ChannelType .category ,
45
+ Thread : ChannelType .public_thread ,
44
46
}
45
47
46
48
@@ -61,10 +63,6 @@ def __init__(self, thread_type: Literal["public", "private", "news"]):
61
63
}
62
64
self ._type = type_map [thread_type ]
63
65
64
- @property
65
- def __name__ (self ):
66
- return "ThreadOption"
67
-
68
66
69
67
class Option :
70
68
"""Represents a selectable option for a slash command.
@@ -165,13 +163,13 @@ def __init__(self, input_type: Any = str, /, description: Optional[str] = None,
165
163
else :
166
164
input_type = (input_type ,)
167
165
for i in input_type :
168
- if i . __name__ == " GuildChannel" :
166
+ if isinstance ( i , type ) and issubclass ( i , GuildChannel ) :
169
167
continue
170
168
if isinstance (i , ThreadOption ):
171
169
self .channel_types .append (i ._type )
172
170
continue
173
171
174
- channel_type = channel_type_map [ i . __name__ ]
172
+ channel_type = CHANNEL_TYPE_MAP [ i ]
175
173
self .channel_types .append (channel_type )
176
174
input_type = _type
177
175
self .input_type = input_type
0 commit comments