aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Qwerty-133 <[email protected]>2021-08-29 14:56:10 +0530
committerGravatar Qwerty-133 <[email protected]>2021-08-29 14:56:10 +0530
commit1dea7637b4c8f7ee63224a992bcb60cfb502caea (patch)
tree6a90005fc7a9e1017de49e0e20941abdc442af7e
parentUse unambiguous converters for infraction commands (diff)
Make the helper function more readable
-rw-r--r--bot/converters.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/bot/converters.py b/bot/converters.py
index 57c513246..54ee2a90a 100644
--- a/bot/converters.py
+++ b/bot/converters.py
@@ -499,15 +499,11 @@ def _is_an_unambiguous_user_argument(argument: str) -> bool:
"""Check if the provided argument is a user mention, user id, or username."""
has_id_or_mention = bool(IDConverter()._get_id_match(argument) or RE_USER_MENTION.match(argument))
- if not has_id_or_mention:
- if argument[0] == '@':
- argument = argument[1:]
+ # Check to see if the author passed a username (a discriminator exists)
+ argument = argument.removeprefix('@')
+ has_username = len(argument) > 5 and argument[-5] == '#'
- # Check to see if the author passed a username (a discriminator exists)
- if len(argument) > 5 and argument[-5] == '#':
- return True
-
- return has_id_or_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"