Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
discord.js v13 slash command interaction failed

The command doesn't run and I get an "interaction failed" error.

Please tell me which file is giving the error and how can I do it?

index.js:

client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    client.commands.set(command.data.name, command);
}

client.once('ready', () => {
    console.log('봇이 준비됐습니다!');
});

client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return interaction.reply({content: '없는 명령어입니다...', ephemeral: true });

    const command = client.commands.get(interaction.commandName);

    if (!command) return interaction.reply({ content: '명령을 실행하는 데 실패했습니다...', ephemeral: true });

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        return interaction.reply({ content: '명령을 실행하는 데 실패했습니다...', ephemeral: true });
    }
});

s();
keepAlive();
client.login(token);

commands/help.js:

    async execute(interaction) {
    const helpembed = new MessageEmbed()
      .setColor('red')
      .setTitle('명령어')
        return interaction.reply({embeds: [helpembed]});
    },
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

there are several things wrong with your code

File help.js:

  • Have you imported the MessageEmbed constructor : const { MessageEmbed } = require('discord.js');
  • You can't do .setColor('red'), you have to do .setColor('#ff0000')

File index.js:

  • const command = client.commands.get(interaction.commandName); Why are you trying to fetch our interactions in commands ? Maybe you should try with const command = client.interactions.get(interaction.commandName); (if the collection of interactions was declared)

For more details about the error, maybe check on your console and provide the error if you have acces to it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda