mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-18 23:15:48 +00:00
Improve error when an invalid slash command name is given
This commit is contained in:
parent
29668c51ae
commit
170ab7b2bb
@ -147,14 +147,16 @@ def _to_kebab_case(text: str) -> str:
|
||||
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')
|
||||
raise ValueError(
|
||||
'names must be between 1-32 characters and contain only lower-case letters, hyphens, or underscores.'
|
||||
)
|
||||
|
||||
# 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')
|
||||
raise ValueError('names must be all lower-case')
|
||||
return name
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user