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

Command localizations don't use camelcase when creating a command with slashcommand builder #9084

Closed
wants to merge 1 commit into from

Conversation

schblondie
Copy link

Please describe the changes this PR makes and why it should be merged:
See #9083

Status and versioning classification:

  • I know how to update typings and have done so, or typings don't need updating
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed) - Not sure if breaking change, because technically object keys changed

@vercel
Copy link

vercel bot commented Jan 23, 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 Jan 23, 2023 at 11:42AM (UTC)

@vercel
Copy link

vercel bot commented Jan 23, 2023

@schblondie is attempting to deploy a commit to the discordjs Team on Vercel.

A member of the Team first needs to authorize it.

@Jiralite
Copy link
Member

Builders is not solely used with discord.js, which makes this pull request incorrect. In addition, changing the casing in discord.js is also wrong, as we are receiving that data from Discord.

@Jiralite Jiralite closed this Jan 23, 2023
Comment on lines +73 to +78
if ('nameLocalizations' in data) {
/**
* The name localizations for this command
* @type {?Object<Locale, string>}
*/
this.nameLocalizations = data.name_localizations;
this.nameLocalizations = data.nameLocalizations;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Discord API data comes with camel-cased keys

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, I apologize.
But when you compare line 78 with line 88 you can see that the this.nameLocalized is also in correct camel case even when getting the non camel case value data.name_localized

@schblondie
Copy link
Author

schblondie commented Jan 23, 2023

I adjusted the code making sure it doesn't conflict with the Discord API.

Now only the SlashCommandBuilder & ContextMenuBuilder Data is in camelCase which doesn't matter when accessing the API as the functions transformCommand() (packages\discord.js\src\managers\ApplicationCommandManager.js - line 233) and transformOption() (packages\discord.js\src\structures\ApplicationCommand.js - line 549) make sure that the keys are in the appropriate case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants