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

Add property type to SlashCommandBuilder #9183

Closed
wants to merge 3 commits into from
Closed

Conversation

immjs
Copy link

@immjs immjs commented Feb 28, 2023

Please describe the changes this PR makes and why it should be merged:
Might help if people want to categorize their commands, instead of checking if the builder is a SlashCommandBuilder, they can simply check the type property of builder, very much like how ContextMenuCommandBuilder does it

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

Might help if people want to categorize their commands, instead of checking if the builder is a SlashCommandBuilder, they can simply check the `type` property of builder, very much like how `ContextMenuCommandBuilder` does it
@vercel
Copy link

vercel bot commented Feb 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
discord-js ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 28, 2023 at 10:29PM (UTC)
discord-js-guide ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 28, 2023 at 10:29PM (UTC)

@Qjuh
Copy link
Contributor

Qjuh commented Feb 28, 2023

This is not consistent builders design. You use the builder while you want to add to it/change it. When you‘re done you can .toJSON() it and will have an object having that type set already.

@immjs
Copy link
Author

immjs commented Feb 28, 2023

I had spent a few minutes looking at the toJSON and there is nothing adding type automagically. Simply, it is not required by the API.

If you want to talk about design, we can also talk about how ContextMenuCommandBuilder does have a type property yet SlashCommandBuilder doesn't, even though they end up in the same API call.

Add relevant type from the relevant enum `ApplicationCommandType`
@monbrey
Copy link
Member

monbrey commented Feb 28, 2023

Sorry, I have to disagree. ContextMenuCommandBuilder has a type property because there are two types that have no other differences between them, and it's required by the API to define an application command as those types.

For the use-case you described developers can simply add a type property, category property, or literally any other property they like alongside the builder in the exports.

@immjs
Copy link
Author

immjs commented Feb 28, 2023

Sorry, I have to disagree. ContextMenuCommandBuilder has a type property because there are two types that have no other differences between them, and it's required by the API to define an application command as those types.

For the use-case you described developers can simply add a type property, category property, or literally any other property they like alongside the builder in the exports.

Well, what are the downsides?

@jaw0r3k
Copy link
Contributor

jaw0r3k commented Mar 1, 2023

Well, what are the downsides?

There is just no need to add it

@kyranet
Copy link
Member

kyranet commented Apr 13, 2023

The ContextMenuCommandBuilder class has a type property because it uses the old builders design, which we will phase out on builders v2 based on the RFC.

You may use instanceof instead, or call toJSON() to read the type.

@kyranet kyranet closed this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants