Skip to content

Commit b28d07c

Browse files
committed
Fix bugs with option converters
1 parent 017deae commit b28d07c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

discord/commands/commands.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -507,21 +507,20 @@ def __init__(
507507
self._converter = None
508508
self.channel_types: List[SlashCommandOptionType] = kwargs.pop("channel_types", [])
509509
if not isinstance(input_type, SlashCommandOptionType):
510-
to_assign = input_type() if isinstance(input_type, type) else input_type
511-
_type = SlashCommandOptionType.from_datatype(to_assign.__class__)
512-
if _type == SlashCommandOptionType.custom:
513-
self._converter = to_assign
510+
if hasattr(input_type, "convert"):
511+
self._converter = input_type
514512
input_type = SlashCommandOptionType.string
515-
elif _type == SlashCommandOptionType.channel:
516-
if not isinstance(input_type, tuple):
517-
input_type = (input_type,)
518-
for i in input_type:
519-
if i.__name__ == 'GuildChannel':
520-
continue
521-
522-
channel_type = channel_type_map[i.__name__]
523-
self.channel_types.append(channel_type)
524513
else:
514+
_type = SlashCommandOptionType.from_datatype(input_type)
515+
if _type == SlashCommandOptionType.channel:
516+
if not isinstance(input_type, tuple):
517+
input_type = (input_type,)
518+
for i in input_type:
519+
if i.__name__ == 'GuildChannel':
520+
continue
521+
522+
channel_type = channel_type_map[i.__name__]
523+
self.channel_types.append(channel_type)
525524
input_type = _type
526525
self.input_type = input_type
527526
self.required: bool = kwargs.pop("required", True)

0 commit comments

Comments
 (0)