@@ -89,7 +89,6 @@ def _get_from_guilds(bot, getter, argument):
8989 return result
9090
9191
92- _utils_get = discord .utils .get
9392T = TypeVar ("T" )
9493T_co = TypeVar ("T_co" , covariant = True )
9594CT = TypeVar ("CT" , bound = discord .abc .GuildChannel )
@@ -194,7 +193,7 @@ async def query_member_named(self, guild, argument):
194193 if len (argument ) > 5 and argument [- 5 ] == "#" :
195194 username , _ , discriminator = argument .rpartition ("#" )
196195 members = await guild .query_members (username , limit = 100 , cache = cache )
197- return discord .utils .get ( members , name = username , discriminator = discriminator )
196+ return discord .utils .find ( lambda m : m . name == username and m . discriminator == discriminator , members )
198197 members = await guild .query_members (argument , limit = 100 , cache = cache )
199198 return discord .utils .find (
200199 lambda m : argument in (m .nick , m .name , m .global_name ),
@@ -239,7 +238,7 @@ async def convert(self, ctx: Context, argument: str) -> discord.Member:
239238 if guild :
240239 result = guild .get_member (user_id )
241240 if ctx .message is not None and result is None :
242- result = _utils_get ( ctx . message . mentions , id = user_id )
241+ result = discord . utils . find ( lambda e : e . id == user_id , ctx . message . mentions )
243242 else :
244243 result = _get_from_guilds (bot , "get_member" , user_id )
245244
@@ -287,7 +286,7 @@ async def convert(self, ctx: Context, argument: str) -> discord.User:
287286 user_id = int (match .group (1 ))
288287 result = ctx .bot .get_user (user_id )
289288 if ctx .message is not None and result is None :
290- result = _utils_get ( ctx . message . mentions , id = user_id )
289+ result = discord . utils . find ( lambda e : e . id == user_id , ctx . message . mentions )
291290 if result is None :
292291 try :
293292 result = await ctx .bot .fetch_user (user_id )
@@ -441,7 +440,7 @@ def _resolve_channel(ctx: Context, argument: str, attribute: str, type: type[CT]
441440 # not a mention
442441 if guild :
443442 iterable : Iterable [CT ] = getattr (guild , attribute )
444- result : CT | None = discord .utils .get ( iterable , name = argument )
443+ result : CT | None = discord .utils .find ( lambda e : e . name == argument , iterable )
445444 else :
446445
447446 def check (c ):
@@ -470,7 +469,7 @@ def _resolve_thread(ctx: Context, argument: str, attribute: str, type: type[TT])
470469 # not a mention
471470 if guild :
472471 iterable : Iterable [TT ] = getattr (guild , attribute )
473- result : TT | None = discord .utils .get ( iterable , name = argument )
472+ result : TT | None = discord .utils .find ( lambda e : e . name == argument , iterable )
474473 else :
475474 thread_id = int (match .group (1 ))
476475 if guild :
@@ -709,7 +708,7 @@ async def convert(self, ctx: Context, argument: str) -> discord.Role:
709708 if match :
710709 result = guild .get_role (int (match .group (1 )))
711710 else :
712- result = discord .utils .get ( guild ._roles .values (), name = argument )
711+ result = discord .utils .find ( lambda e : e . name == argument , guild ._roles .values ())
713712
714713 if result is None :
715714 raise RoleNotFound (argument )
@@ -760,7 +759,7 @@ async def convert(self, ctx: Context, argument: str) -> discord.Guild:
760759 result = ctx .bot .get_guild (guild_id )
761760
762761 if result is None :
763- result = discord .utils .get ( ctx .bot .guilds , name = argument )
762+ result = discord .utils .find ( lambda e : e . name == argument , ctx .bot .guilds )
764763
765764 if result is None :
766765 raise GuildNotFound (argument )
@@ -792,10 +791,10 @@ async def convert(self, ctx: Context, argument: str) -> discord.GuildEmoji:
792791 if match is None :
793792 # Try to get the emoji by name. Try local guild first.
794793 if guild :
795- result = discord .utils .get ( guild . emojis , name = argument )
794+ result = discord .utils .find ( lambda e : e . name == argument , guild . emojis )
796795
797796 if result is None :
798- result = discord .utils .get ( bot . emojis , name = argument )
797+ result = discord .utils .find ( lambda e : e . name == argument , bot . emojis )
799798 else :
800799 emoji_id = int (match .group (1 ))
801800
@@ -858,10 +857,10 @@ async def convert(self, ctx: Context, argument: str) -> discord.GuildSticker:
858857 if match is None :
859858 # Try to get the sticker by name. Try local guild first.
860859 if guild :
861- result = discord .utils .get ( guild .stickers , name = argument )
860+ result = discord .utils .find ( lambda s : s . name == argument , guild .stickers , name = argument )
862861
863862 if result is None :
864- result = discord .utils .get ( bot . stickers , name = argument )
863+ result = discord .utils .find ( lambda s : s . name == argument , bot . stickers )
865864 else :
866865 sticker_id = int (match .group (1 ))
867866
@@ -913,17 +912,23 @@ async def convert(self, ctx: Context, argument: str) -> str:
913912 if ctx .guild :
914913
915914 def resolve_member (id : int ) -> str :
916- m = (None if msg is None else _utils_get (msg .mentions , id = id )) or ctx .guild .get_member (id )
915+ m = (
916+ None if msg is None else discord .utils .find (lambda e : e .id == id , msg .mentions )
917+ ) or ctx .guild .get_member (id )
917918 return f"@{ m .display_name if self .use_nicknames else m .name } " if m else "@deleted-user"
918919
919920 def resolve_role (id : int ) -> str :
920- r = (None if msg is None else _utils_get (msg .mentions , id = id )) or ctx .guild .get_role (id )
921+ r = (
922+ None if msg is None else discord .utils .find (lambda e : e .id == id , msg .mentions )
923+ ) or ctx .guild .get_role (id )
921924 return f"@{ r .name } " if r else "@deleted-role"
922925
923926 else :
924927
925928 def resolve_member (id : int ) -> str :
926- m = (None if msg is None else _utils_get (msg .mentions , id = id )) or ctx .bot .get_user (id )
929+ m = (
930+ None if msg is None else discord .utils .find (lambda e : e .id == id , msg .mentions )
931+ ) or ctx .bot .get_user (id )
927932 return f"@{ m .name } " if m else "@deleted-user"
928933
929934 def resolve_role (id : int ) -> str :
0 commit comments