fix: also translate command params for /help

This commit is contained in:
Marius Begby committed 2023-12-23 16:44:12 +01:00
1 parent 1fa0fdc61f
commit e2040baa8d
1 file changed
+10 -3
+10 -3
View File
@@ -106,7 +106,7 @@ class HelpCommand extends BaseSlashCommandInteraction {
let translatedData: CommandMetadata | undefined = undefined;
translatedData = translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined;
const commandParams: string = this.getCommandParams(command);
const commandParams: string = this.getCommandParams(command, interaction);
const beta: string = command.isBeta ? `${this.embedOptions.icons.beta} ` : '';
const newCommand: string = command.isNew ? `${this.embedOptions.icons.new} ` : '';
@@ -116,11 +116,18 @@ class HelpCommand extends BaseSlashCommandInteraction {
}`;
}
private getCommandParams(command: BaseSlashCommandInteraction): string {
private getCommandParams(command: BaseSlashCommandInteraction, interaction: ChatInputCommandInteraction): string {
const commandName = command.data.name;
const option = command.data.options[0];
if (option instanceof SlashCommandNumberOption || option instanceof SlashCommandStringOption) {
return `**\`${option.name}\`** `;
const metadataKey = `commands.${commandName}.metadata.options.${option.name}`;
const locale = interaction.guildLocale ?? 'en';
let translatedData: CommandMetadata | undefined = undefined;
translatedData = translatorInstance.getResource(locale, 'bot', metadataKey) as CommandMetadata | undefined;
return `**\`${translatedData?.name ?? option.name}\`** `;
}
return '';
}
}