Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update validation regex for command names & options #1309

Merged
merged 3 commits into from May 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions discord/commands/core.py
Expand Up @@ -1616,7 +1616,7 @@ def command(**kwargs):

# Validation
def validate_chat_input_name(name: Any, locale: Optional[str] = None):
# Must meet the regex ^[\w-]{1,32}$
# Must meet the regex ^[-_\w\d\u0901-\u097D\u0E00-\u0E7F]{1,32}$
if locale is not None and locale not in valid_locales:
raise ValidationError(
f"Locale '{locale}' is not a valid locale, "
Expand All @@ -1625,9 +1625,9 @@ def validate_chat_input_name(name: Any, locale: Optional[str] = None):
error = None
if not isinstance(name, str):
error = TypeError(f"Command names and options must be of type str. Received \"{name}\"")
elif not re.match(r"^[\w-]{1,32}$", name):
elif not re.match(r"^[-_\w\d\u0901-\u097D\u0E00-\u0E7F]{1,32}$", name):
error = ValidationError(
r"Command names and options must follow the regex \"^[\w-]{1,32}$\". For more information, see "
r"Command names and options must follow the regex \"^[-_\w\d\u0901-\u097D\u0E00-\u0E7F]{1,32}$\". For more information, see "
f"{docs}/interactions/application-commands#application-command-object-application-command-naming. "
f"Received \"{name}\""
)
Expand Down