aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Woesthuis <[email protected]>2020-01-05 20:44:23 +0100
committerRapptz <[email protected]>2020-01-20 07:14:27 -0500
commitee6f4e85d62888af0960e091fbe9bb1115da1312 (patch)
tree4f3037a2961c11f03007c27de58635ffeccb4747
parentUpdate attachment documentation for width/height applying to videos too (diff)
downloaddiscord.py-ee6f4e85d62888af0960e091fbe9bb1115da1312.tar.xz
discord.py-ee6f4e85d62888af0960e091fbe9bb1115da1312.zip
[commands] Allow @ prefixed usernames in DM contexts for UserConverter
Previously the argument '@user#0000' return None. To fix this, as this is a common user error, an extra check was added to remove the first character from the argument if this is an '@'. Discord names may not contain an '@' anyways.
-rw-r--r--discord/ext/commands/converter.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py
index 12d72bb5..edd815db 100644
--- a/discord/ext/commands/converter.py
+++ b/discord/ext/commands/converter.py
@@ -157,7 +157,13 @@ class UserConverter(IDConverter):
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
+
+ # Remove the '@' character if this is the first character from the argument
+ if arg[0] == '@':
+ # Remove first character
+ arg = arg[1:]
+
+ # check for discriminator if it exists,
if len(arg) > 5 and arg[-5] == '#':
discrim = arg[-4:]
name = arg[:-5]
@@ -173,7 +179,6 @@ class UserConverter(IDConverter):
raise BadArgument('User "{}" not found'.format(argument))
return result
-
class MessageConverter(Converter):
"""Converts to a :class:`discord.Message`.