Skip to content

Commit 33a0a25

Browse files
committed
Fix issues with converter options
1 parent e44dd80 commit 33a0a25

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

discord/commands/core.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
784784
kwargs = {}
785785
for arg in ctx.interaction.data.get("options", []):
786786
op = find(lambda x: x.name == arg["name"], self.options)
787+
if op is None:
788+
continue
787789
arg = arg["value"]
788790

789791
# Checks if input_type is user, role or channel
@@ -844,7 +846,11 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
844846
arg = Object(id=int(arg))
845847

846848
elif op.input_type == SlashCommandOptionType.string and (converter := op.converter) is not None:
847-
arg = await converter.convert(converter, ctx, arg)
849+
from discord.ext.commands import Converter
850+
if isinstance(converter, Converter):
851+
arg = await converter.convert(ctx, arg)
852+
elif isinstance(converter, type) and hasattr(converter, "convert"):
853+
arg = await converter().convert(ctx, arg)
848854

849855
elif op._raw_type in (SlashCommandOptionType.integer,
850856
SlashCommandOptionType.number,

discord/commands/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def __init__(self, input_type: Any = str, /, description: Optional[str] = None,
138138
if not isinstance(input_type, SlashCommandOptionType):
139139
if hasattr(input_type, "convert"):
140140
self.converter = input_type
141+
self._raw_type = str
141142
input_type = SlashCommandOptionType.string
142143
elif isinstance(input_type, type) and issubclass(input_type, (Enum, DiscordEnum)):
143144
enum_choices = [OptionChoice(e.name, e.value) for e in input_type]

0 commit comments

Comments
 (0)