diff options
| author | Rapptz <[email protected]> | 2019-07-10 04:36:07 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-07-10 04:51:27 -0400 |
| commit | 2e6882bd8c8e21765794a6b2b54ee0be19339716 (patch) | |
| tree | 0ab22c66c638beabf830d360881da9aa773d44c2 | |
| parent | Add upgraded Member to Message.mentions in case of no cache. (diff) | |
| download | discord.py-2e6882bd8c8e21765794a6b2b54ee0be19339716.tar.xz discord.py-2e6882bd8c8e21765794a6b2b54ee0be19339716.zip | |
[commands] Fall back to using Message.mentions in converters
Useful if there's no cache.
| -rw-r--r-- | discord/ext/commands/converter.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 86a3db45..ea202b65 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -58,6 +58,8 @@ def _get_from_guilds(bot, getter, argument): return result return result +_utils_get = discord.utils.get + class Converter: """The base class of custom converters that require the :class:`.Context` to be passed to be useful. @@ -124,7 +126,7 @@ class MemberConverter(IDConverter): else: user_id = int(match.group(1)) if guild: - result = guild.get_member(user_id) + result = guild.get_member(user_id) or _utils_get(ctx.message.mentions, id=user_id) else: result = _get_from_guilds(bot, 'get_member', user_id) @@ -152,7 +154,7 @@ class UserConverter(IDConverter): if match is not None: 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: arg = argument # check for discriminator if it exists |