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

Use Template String Literal Type for ApplicationCommandData.name #5814

Closed
suneettipirneni opened this issue Jun 11, 2021 · 3 comments
Closed

Comments

@suneettipirneni
Copy link
Member

suneettipirneni commented Jun 11, 2021

Is your feature request related to a problem? Please describe.

The discord API outlines the requirements of slash command names:

Command names must be lower-case and match the regular expression ^[\w-]{1,32}$. Commands (including sub-commands) with upper- or mixed- case names will be rejected by the API with a HTTP 400 (Bad Request) response.

It would be nice if this was type checked beforehand, to prevent invalid request errors later.

Describe the ideal solution
A clear and concise description of what you want to happen.

Template string literals could be used to enforce the format of the string.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Runtime regex assertions, but that's runtime.

@suneettipirneni suneettipirneni changed the title Use Template String Literal for ApplicationCommandData.name Use Template String Literal Type for ApplicationCommandData.name Jun 11, 2021
@monbrey
Copy link
Member

monbrey commented Jun 16, 2021

I don't believe TypeScript supports regular expression type literals yet, so I'm not sure how we could achieve this. At most, maybe Lowercase<string>?

Disregard - that's only for converting string literals.

@suneettipirneni
Copy link
Member Author

yeah it looks you're correct they a discussion about it here, but nothing has come of it.

@iCrawl
Copy link
Member

iCrawl commented Jun 18, 2021

As we currently cannot really do anything about this, I will close this issue.

We can revisit this whenever there is a possible way of doing this.

@iCrawl iCrawl closed this as completed Jun 18, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants