Command is not registering

i have a issue with register a translated command..

Current code is
import { ApplyOptions } from '@sapphire/decorators';
import { applyLocalizedBuilder } from '@sapphire/plugin-i18next';
import { ChatInputCommand, Command } from '@sapphire/framework';

@ApplyOptions<Command.Options>({
    description: 'ping pong'
})
export class UserCommand extends Command {
    public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
        registry.registerChatInputCommand(
            (builder) => 
            applyLocalizedBuilder(builder, 'ping:CommandName', 'ping:CommandDescription')
        );
    }

    public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
        await interaction.reply({
            content: 'Pong!',
            ephemeral: true
          });
      
    }
}
Solution
@Fabi My current suspicion is that you havent setup @sapphire/plugin-i18next properly. Here is a zip with files that are based on the CLI generated template that show what needs to be done

The important parts are:
  1. Calling the /register of the plugin
  2. Configuring the languages for the plugin (see the config in
    src/index.ts
    )
  3. Adding the languages directory
  4. In languages add the appropriate languages subfolders
  5. In those subfolders create the JSON files (ping.json in your case becaus you references the keys as ping:Something)
  6. Add the appropriate keys in the JSON files, in your case CommandName and CommandDescription
  7. Ensure that TypeScript copies the JSON files when compiling by adding src/**/*.json to the includes array as well as enabling compilerOptions.resolveJsonModule
It should be noted that steps 4, 5 and 6 are directly related to the usage of i18next: https://www.i18next.com. By providing i18n you're taking on a big task of understanding how this framework works.
bot.zip989.56KB
Was this page helpful?