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
});

}
}
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)...
Jump to solution
19 Replies
Fabi
Fabi6mo ago
No description
Favna
Favna6mo ago
Is2g why are application commands failing for literally everyone today @vladdy :stress: :stress: :stress: :stress:
vladdy
vladdy6mo ago
??? wtf happened everything worked fine for so long and randomly it breaks? is this a cjs/esm moment??
Favna
Favna6mo ago
Nah doubt it. That's been fixed for a while now too.
vladdy
vladdy6mo ago
yeah but why did it randomly break now after all this time when it worked FINE
kyra
kyra6mo ago
Maybe Discord shitting itself?
Favna
Favna6mo ago
For starters, please list all your dependencies @Fabi
vladdy
vladdy6mo ago
this is on sapphire not discord something strange is happening are all plugins esm'd yet @Favna if you remember i know you're out
Favna
Favna6mo ago
yes hm it works for me
vladdy
vladdy6mo ago
node version diffs?
Favna
Favna6mo ago
My thought is that @Fabi hasnt fully set up i18next
vladdy
vladdy6mo ago
doesn't explain the other issues
Favna
Favna6mo ago
those are separate and need separate investigation
Solution
Favna
Favna6mo ago
@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.
Fabi
Fabi6mo ago
I'll look later into it Other question, related to that: Can I put a subcommands into multiple files. Like /voice lock own file and /voice unlock own file
Want results from more Discord servers?
Add your server