[commands] Fall back to using Message.mentions in converters
Useful if there's no cache.
This commit is contained in:
parent
bbc50c92d0
commit
2e6882bd8c
@ -58,6 +58,8 @@ def _get_from_guilds(bot, getter, argument):
|
|||||||
return result
|
return result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
_utils_get = discord.utils.get
|
||||||
|
|
||||||
class Converter:
|
class Converter:
|
||||||
"""The base class of custom converters that require the :class:`.Context`
|
"""The base class of custom converters that require the :class:`.Context`
|
||||||
to be passed to be useful.
|
to be passed to be useful.
|
||||||
@ -124,7 +126,7 @@ class MemberConverter(IDConverter):
|
|||||||
else:
|
else:
|
||||||
user_id = int(match.group(1))
|
user_id = int(match.group(1))
|
||||||
if guild:
|
if guild:
|
||||||
result = guild.get_member(user_id)
|
result = guild.get_member(user_id) or _utils_get(ctx.message.mentions, id=user_id)
|
||||||
else:
|
else:
|
||||||
result = _get_from_guilds(bot, 'get_member', user_id)
|
result = _get_from_guilds(bot, 'get_member', user_id)
|
||||||
|
|
||||||
@ -152,7 +154,7 @@ class UserConverter(IDConverter):
|
|||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
user_id = int(match.group(1))
|
user_id = int(match.group(1))
|
||||||
result = ctx.bot.get_user(user_id)
|
result = ctx.bot.get_user(user_id) or _utils_get(ctx.message.mentions, id=user_id)
|
||||||
else:
|
else:
|
||||||
arg = argument
|
arg = argument
|
||||||
# check for discriminator if it exists
|
# check for discriminator if it exists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user