question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Name localization for Application Command Subcommands and Option Choices not included in JSON

See original GitHub issue

Which package is this bug report for?

builders

Issue description

Localization options do not seem to work for subcommand name (probably description as well, admittedly I haven’t checked), and subcommand option choice names.

Reproduction Steps

  1. Create a command and subcommand
  2. Add a string command option to the subcommand
  3. After defining the name, set or add the name localizations
  4. Export the command to JSON

Expected: The name localizations are present on the application command subcommand and option choices Actual: The name localizations are not present on the application command subcommand and option choices

Link to one place I think changes might need to happen. I’m pretty sure for the example linked there name_localizations needs to be added to the choice destructuring and on the object that is pushed to the choices array.

JSON result of example code

{
   "name":"test",
   "name_localizations":{
      "en-GB":"test"
   },
   "description":"Schedules an event in this channel",
   "options":[
      {
         "type":1,
         "name":"subcommand",
         "description":"subcommand description",
         "options":[
            {
               "choices":[
                  {
                     "name":"choice",
                     "value":"1"
                  }
               ],
               "type":3,
               "name":"option",
               "name_localizations":{
                  "en-GB":"option"
               },
               "description":"option description",
               "required":false
            }
         ]
      }
   ]
}

Code sample

import { InteractiveCommand } from './command';
import { SlashCommandBuilder } from '@discordjs/builders';

export const Test: InteractiveCommand = {
    data: new SlashCommandBuilder()
        .setName('test')
        .setNameLocalization('en-GB', 'test')
        .setDescription('Schedules an event in this channel')
        .addSubcommand(subcommand =>
            subcommand.setName('subcommand')
                .setNameLocalization('en-GB', 'subcommand')
                .setDescription('subcommand description')
                .addStringOption(option =>
                    option.setName('option')
                        .setNameLocalization('en-GB', 'option')
                        .setDescription('option description')
                        .addChoices(...[{
                            name: 'choice',
                            name_localizations: {
                                'en-GB': 'choice'
                            },
                            value: '1'
                        }])
                )
        ),
    execute: async interaction => {},
    handleMessageComponentInteraction: async interaction => {}
}

Package version

0.13.0

Node.js version

16.14.0

Operating system

WSL

Priority this issue should have

Medium (should be fixed soon)

Which partials do you have configured?

User, Channel, Message

Which gateway intents are you subscribing to?

Guilds

I have tested this issue on a development release

Not yet, I see how to install a discord.js dev release, is it the same for the builders package?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jeddaicommented, Apr 28, 2022

Also thank you very much for the speedy fix! ❤️

1reaction
vladfrangucommented, Apr 28, 2022

Can you check again? b911980 (#7862) should solve it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced command creation - discord.js Guide
Advanced command creation. The examples we've covered so far have all been fairly simple commands, such as ping , server , and user...
Read more >
javascript - How can i update the choices in a slashcommand ...
I'm trying to get the command to reload and re-read the json file to add the new list of addChoice options to the...
Read more >
Application Commands - Developer Portal - Discord
Application commands are native ways to interact with apps in the Discord client. There are 3 types of commands accessible in different interfaces:...
Read more >
CLI: Command-Line Options | Localazy Docs
Learn advanced command-line parameters that you can use for using Localazy CLI in specific situations such as automated builds and testing.
Read more >
Slash Commands - disnake
Localizations. The names and descriptions of commands and options, as well as the names of choices (for use with fixed choices or autocompletion),...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found