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
FabiOP10mo ago
No description
Favna
Favna10mo ago
Is2g why are application commands failing for literally everyone today @vladdy :stress: :stress: :stress: :stress:
vladdy
vladdy10mo ago
??? wtf happened everything worked fine for so long and randomly it breaks? is this a cjs/esm moment??
Favna
Favna10mo ago
Nah doubt it. That's been fixed for a while now too.
vladdy
vladdy10mo ago
yeah but why did it randomly break now after all this time when it worked FINE
kyra
kyra10mo ago
Maybe Discord shitting itself?
Favna
Favna10mo ago
For starters, please list all your dependencies @Fabi
vladdy
vladdy10mo 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
Favna10mo ago
yes hm it works for me
vladdy
vladdy10mo ago
node version diffs?
Favna
Favna10mo ago
My thought is that @Fabi hasnt fully set up i18next
vladdy
vladdy10mo ago
doesn't explain the other issues
Favna
Favna10mo ago
those are separate and need separate investigation
Solution
Favna
Favna10mo 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
FabiOP10mo 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
Favna
Favna10mo ago
See #Subcommands Not Working for an example of how to do that
Fabi
FabiOP10mo ago
i did it now like that, it breaks
No description
Favna
Favna10mo ago
My code definitely works so go through everything once again I tested it myself
Fabi
FabiOP10mo ago
alright alr worked! Was just a missing import :AGC_Pepeyup:
Want results from more Discord servers?
Add your server