Код просто не хочет работать. Выдает в консоль "Interaction already replied or deferred", хотя в дискорде ответа нет.
const { CommandInteraction, MessageActionRow, MessageSelectMenuBuilder } = require('discord.js');
const i18n = require('i18n');
const { success, fail } = require('../../config.json');
i18n.configure({
locales: ['en', 'ru', 'uk'],
directory: __dirname + '/locales',
defaultLocale: 'ru',
objectNotation: true,
});
module.exports = {
name: 'lang',
description: 'Устанавливает язык бота',
options: [
{
name: 'language',
description: 'Select a language',
type: 'STRING',
required: true,
choices: [
{
name: 'English',
value: 'en',
},
{
name: 'Русский',
value: 'ru',
},
{
name: 'Українська',
value: 'uk',
},
],
},
],
/**
* @param {CommandInteraction} interaction
*/
run: async (client, interaction) => {
try {
console.log('Command executed:', interaction.commandName);
// Check if the interaction is already replied or deferred
if (interaction.deferred || interaction.replied) {
console.log('Interaction already replied or deferred');
return;
}
await interaction.deferReply();
const language = interaction.options.getString('language');
if (language && i18n.getLocales().includes(language)) {
i18n.setLocale(language);
await interaction.followUp({
content: `${success} Language set to ${language}`,
ephemeral: true,
});
} else {
await interaction.followUp({
content: `${fail} Invalid language specified`,
ephemeral: true,
});
}
} catch (error) {
console.error('Error executing lang command:', error);
}
},
};