From 446c5029952d2b6f466348b973888c01b0b2ef6e Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 15 Mar 2022 23:37:43 -0400 Subject: [PATCH] Change lowercase detection to work with CJK languages str.islower() does not properly work with characters in the Lo category so CJK languages fail the check. Fix #7698 --- discord/app_commands/commands.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py index 0508fb4a1..fd8770de9 100644 --- a/discord/app_commands/commands.py +++ b/discord/app_commands/commands.py @@ -142,7 +142,12 @@ def validate_name(name: str) -> str: match = VALID_SLASH_COMMAND_NAME.match(name) if match is None: raise ValueError('names must be between 1-32 characters') - if not name.islower(): + + # Ideally, name.islower() would work instead but since certain characters + # are Lo (e.g. CJK) those don't pass the test. I'd use `casefold` instead as + # well, but chances are the server-side check is probably something similar to + # this code anyway. + if name.lower() != name: raise ValueError('names must be all lower case') return name