5151 Converter ,
5252 Group ,
5353 GuildChannelConverter ,
54+ MemberConverter ,
5455 RoleConverter ,
5556 UserConverter ,
5657)
@@ -566,13 +567,21 @@ def predicate(func: Callable | ApplicationCommand):
566567
567568
568569class MentionableConverter (Converter ):
569- """A converter that can convert a mention to a user or a role."""
570+ """A converter that can convert a mention to a member, a user or a role."""
570571
571572 async def convert (self , ctx , argument ):
572573 try :
573574 return await RoleConverter ().convert (ctx , argument )
574575 except BadArgument :
575- return await UserConverter ().convert (ctx , argument )
576+ pass
577+
578+ if ctx .guild :
579+ try :
580+ return await MemberConverter ().convert (ctx , argument )
581+ except BadArgument :
582+ pass
583+
584+ return await UserConverter ().convert (ctx , argument )
576585
577586
578587class AttachmentConverter (Converter ):
@@ -600,6 +609,7 @@ async def convert(self, ctx, arg: bool):
600609 SlashCommandOptionType .mentionable : MentionableConverter ,
601610 SlashCommandOptionType .number : float ,
602611 SlashCommandOptionType .attachment : AttachmentConverter ,
612+ discord .Member : MemberConverter ,
603613}
604614
605615
@@ -608,16 +618,24 @@ class BridgeOption(Option, Converter):
608618 command option and a prefixed command argument for bridge commands.
609619 """
610620
621+ def __init__ (self , input_type , * args , ** kwargs ):
622+ self .converter = kwargs .pop ("converter" , None )
623+ super ().__init__ (input_type , * args , ** kwargs )
624+
625+ self .converter = self .converter or BRIDGE_CONVERTER_MAPPING .get (input_type )
626+
611627 async def convert (self , ctx , argument : str ) -> Any :
612628 try :
613629 if self .converter is not None :
614- converted = await self .converter .convert (ctx , argument )
630+ converted = await self .converter () .convert (ctx , argument )
615631 else :
616- converter = BRIDGE_CONVERTER_MAPPING [ self .input_type ]
617- if issubclass (converter , Converter ):
632+ converter = BRIDGE_CONVERTER_MAPPING . get ( self .input_type )
633+ if isinstance ( converter , type ) and issubclass (converter , Converter ):
618634 converted = await converter ().convert (ctx , argument ) # type: ignore # protocol class
619- else :
635+ elif callable ( converter ) :
620636 converted = converter (argument )
637+ else :
638+ raise TypeError (f"Invalid converter: { converter } " )
621639
622640 if self .choices :
623641 choices_names : list [str | int | float ] = [
0 commit comments