From 1dea7637b4c8f7ee63224a992bcb60cfb502caea Mon Sep 17 00:00:00 2001 From: Qwerty-133 <74311372+Qwerty-133@users.noreply.github.com> Date: Sun, 29 Aug 2021 14:56:10 +0530 Subject: Make the helper function more readable --- bot/converters.py | 12 ++++-------- 1 file 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" -- cgit v1.2.3