diff options
author | 2024-01-05 13:50:14 +0000 | |
---|---|---|
committer | 2024-01-05 13:50:14 +0000 | |
commit | 3f93359e6e29b6ee26f17d85facbfca74a9caaa3 (patch) | |
tree | a4dc504845fda0dfbc8abbaa759f776b18d8a00d | |
parent | Voice Verify Button Instead of Voice Verify Command (#2856) (diff) | |
parent | Don't instantiate class to call static method (diff) |
Merge pull request #2880 from python-discord/update-unambiguous-converters
Update unambiguous converter to not support usernames
-rw-r--r-- | bot/converters.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/bot/converters.py b/bot/converters.py index 3c8ea44d7..038f815a5 100644 --- a/bot/converters.py +++ b/bot/converters.py @@ -423,23 +423,19 @@ class HushDurationConverter(Converter): def _is_an_unambiguous_user_argument(argument: str) -> bool: - """Check if the provided argument is a user mention, user id, or username (name#discrim).""" - has_id_or_mention = bool(IDConverter()._get_id_match(argument) or RE_USER_MENTION.match(argument)) + """Check if the provided argument is a user mention or user id.""" + user_id = IDConverter._get_id_match(argument) + user_mention = RE_USER_MENTION.match(argument) - # Check to see if the author passed a username (a discriminator exists) - argument = argument.removeprefix("@") - has_username = len(argument) > 5 and argument[-5] == "#" + return bool(user_id or user_mention) - return has_id_or_mention or has_username - -AMBIGUOUS_ARGUMENT_MSG = ("`{argument}` is not a User mention, a User ID or a Username in the format" - " `name#discriminator`.") +AMBIGUOUS_ARGUMENT_MSG = "`{argument}` is not a User mention or a User ID." class UnambiguousUser(UserConverter): """ - Converts to a `discord.User`, but only if a mention, userID or a username (name#discrim) is provided. + Converts to a `discord.User`, but only if a mention or userID is provided. Unlike the default `UserConverter`, it doesn't allow conversion from a name. This is useful in cases where that lookup strategy would lead to too much ambiguity. @@ -454,7 +450,7 @@ class UnambiguousUser(UserConverter): class UnambiguousMember(MemberConverter): """ - Converts to a `discord.Member`, but only if a mention, userID or a username (name#discrim) is provided. + Converts to a `discord.Member`, but only if a mention or userID is provided. Unlike the default `MemberConverter`, it doesn't allow conversion from a name or nickname. This is useful in cases where that lookup strategy would lead to too much ambiguity. |