Skip to content

Commit

Permalink
[commands] Change lookup order to place nicknames last
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Jun 26, 2023
1 parent 2fdbe59 commit 5e86be3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions discord/ext/commands/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ class MemberConverter(IDConverter[discord.Member]):
2. Lookup by mention.
3. Lookup by username#discriminator (deprecated).
4. Lookup by username#0 (deprecated, only gets users that migrated from their discriminator).
5. Lookup by guild nickname.
5. Lookup by user name.
6. Lookup by global name.
7. Lookup by user name.
7. Lookup by guild nickname.
.. versionchanged:: 1.5
Raise :exc:`.MemberNotFound` instead of generic :exc:`.BadArgument`
Expand All @@ -217,7 +217,7 @@ async def query_member_named(self, guild: discord.Guild, argument: str) -> Optio
predicate = lambda m: m.name == username and m.discriminator == discriminator
else:
lookup = argument
predicate = lambda m: m.nick == argument or m.global_name == argument or m.name == argument
predicate = lambda m: m.name == argument or m.global_name == argument or m.nick == argument

members = await guild.query_members(lookup, limit=100, cache=cache)
return discord.utils.find(predicate, members)
Expand Down Expand Up @@ -289,8 +289,8 @@ class UserConverter(IDConverter[discord.User]):
2. Lookup by mention.
3. Lookup by username#discriminator (deprecated).
4. Lookup by username#0 (deprecated, only gets users that migrated from their discriminator).
5. Lookup by global name.
6. Lookup by user name.
5. Lookup by user name.
6. Lookup by global name.
.. versionchanged:: 1.5
Raise :exc:`.UserNotFound` instead of generic :exc:`.BadArgument`
Expand Down Expand Up @@ -329,7 +329,7 @@ async def convert(self, ctx: Context[BotT], argument: str) -> discord.User:
if discriminator == '0' or (len(discriminator) == 4 and discriminator.isdigit()):
predicate = lambda u: u.name == username and u.discriminator == discriminator
else:
predicate = lambda u: u.global_name == argument or u.name == argument
predicate = lambda u: u.name == argument or u.global_name == argument

result = discord.utils.find(predicate, state._users.values())
if result is None:
Expand Down

0 comments on commit 5e86be3

Please sign in to comment.