@@ -392,7 +392,7 @@ def __eq__(self, other) -> bool:
392
392
)
393
393
394
394
async def _invoke (self , ctx : ApplicationContext ) -> None :
395
- # TODO: Parse the args better, apply custom converters etc.
395
+ # TODO: Parse the args better
396
396
kwargs = {}
397
397
for arg in ctx .interaction .data .get ("options" , []):
398
398
op = find (lambda x : x .name == arg ["name" ], self .options )
@@ -413,6 +413,9 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
413
413
if arg is None :
414
414
arg = ctx .guild .get_role (arg_id ) or arg_id
415
415
416
+ elif op .input_type == SlashCommandOptionType .string and op ._converter is not None :
417
+ arg = await op ._converter .convert (ctx , arg )
418
+
416
419
kwargs [op .name ] = arg
417
420
418
421
for o in self .options :
@@ -470,8 +473,13 @@ def __init__(
470
473
) -> None :
471
474
self .name : Optional [str ] = kwargs .pop ("name" , None )
472
475
self .description = description or "No description provided"
476
+ self ._converter = None
473
477
if not isinstance (input_type , SlashCommandOptionType ):
474
- input_type = SlashCommandOptionType .from_datatype (input_type )
478
+ to_assign = input_type () if isinstance (input_type , type ) else input_type
479
+ _type = SlashCommandOptionType .from_datatype (to_assign .__class__ )
480
+ if _type == SlashCommandOptionType .custom :
481
+ self ._converter = to_assign
482
+ input_type = SlashCommandOptionType .string
475
483
self .input_type = input_type
476
484
self .required : bool = kwargs .pop ("required" , True )
477
485
self .choices : List [OptionChoice ] = [
0 commit comments