Skip to content

Commit

Permalink
Update validation regex for command names & options (#1309)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlluminatiFish committed May 4, 2022
1 parent fe17218 commit ea6f59d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
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

0 comments on commit ea6f59d

Please sign in to comment.