AlexzanderFlores / WOKCommands

130 stars 61 forks source link

Discord gives "Invalid application interaction command" error when I run a slash command #126

Closed open-antux closed 11 months ago

open-antux commented 3 years ago

I have several slash commands, but often when I run my discord bot and run one of the commands, discord gives me an Invalid application interaction command and the only thing that I can do is stop the bot, wait a while and rerun the bot. This is an example of command:

const { MessageEmbed } = require('discord.js');

module.exports = {
    name: 'info',
    alias: ['i'],
    category: 'Info',
    description: 'Show info.',
    slash: true,

    callback: async ({}) => {
        return new MessageEmbed()
            .setTitle('x')
            .setAuthor('x')
            .setColor('0ffd0')
            .setDescription('x')
    }
}

The rest of the commands are very similar to this one. How can I solve this? If could help, this is my index.js

const Discord = require('discord.js');
const WOKCommands = require('wokcommands');

const Config = require('./config.json');

const client = new Discord.Client({ partials: ['MESSAGE', 'REACTION'] });

client.on('ready', () => {
    new WOKCommands(client, {
        commandsDir: 'commands',
        showWarns: true,
        del: -1,
        ignoreBots: true,
    }).setDefaultPrefix(Config.prefix);

    console.log('Bot is ready!');
})

client.login(Config.token);
Wolletje01 commented 3 years ago

Can you send the error.

daniieljc commented 3 years ago

The same thing happens to me, the first time you run the discord command it sends you that error but from there it works correctly

open-antux commented 3 years ago

I also tried to create and use slash commands without using the WOKcommands handler, and I noticed that the error persist but it start to work again when the bot goes offline and return online.

@Wolletje01 my bot doesn't give any error, is discord that gives me Invalid application interaction command error.

That's an offtopic question: Where can I find some cool docs about interactions?

Thanks to everyone

dvd-22 commented 3 years ago

The same thing happens to me, the first time you run the discord command it sends you that error but from there it works correctly

Mine had the same issue, solved it by adding an if(interaction) statement before the command.