提问者:小点点

无效的交互应用程序命令(使用WOKCommands的discord.js斜杠命令)


我正在使用discord.js和WOKCommands来使用斜杠命令,但是当在discord中输入时,它给我一个错误“无效的交互应用程序命令”

下面是该命令的代码:

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

// Simple command for the message
module.exports = {
    name: "ping",
    slash: "both",
    testOnly: false,
    description: "Command to figure out what your current ping is. Also shows API Latency",
    // Executing the message command
    execute(client, message, cmd, args, Discord) {
        // Creating the Embed const
        const newEmbed = new MessageEmbed()
            // ALL EMBED VALUES
            .setColor("#ffdbac")
            .setTitle("Ping")
            .setDescription("Pong! Latency is **" + (Date.now() - message.createdTimestamp) + "ms**. API Latency is **" + message.client.ws.ping + "ms**")
            .setThumbnail(`https://cometiclachlan.github.io/Uploads/pingpong-removebg.png`)
            .setTimestamp()
            .setFooter("v1.2", `https://cometiclachlan.github.io/Uploads/Checkpoint-removebg.png`);

        message.channel.send(newEmbed);
    },
};

仅当我也需要显示主脚本的代码时,该命令的代码才是命令的代码。我会这样做的。


共1个答案

匿名用户

您不能在斜线命令中使用Message,您需要将它改为

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

// Simple command for the message
module.exports = {
    name: "ping",
    slash: "both",
    testOnly: false,
    description: "Command to figure out what your current ping is. Also shows API Latency",
    // Executing the message command
    callback : ({client, message, cmd, args, Discord}) => {
        if (message) {
        // Creating the Embed const
        const newEmbed = new MessageEmbed()
        // ALL EMBED VALUES
        .setColor("#ffdbac")
        .setTitle("Ping")
        .setDescription("Pong! Latency is **" + (Date.now() - message.createdTimestamp) + "ms**. API Latency is **" + client.ws.ping + "ms**")
        .setThumbnail(`https://cometiclachlan.github.io/Uploads/pingpong-removebg.png`)
        .setTimestamp()
        .setFooter("v1.2", `https://cometiclachlan.github.io/Uploads/Checkpoint-removebg.png`);

        message.channel.send(newEmbed);
        }
        // Slash Command
        const newEmbed = new MessageEmbed()
        ...
        return newEmbed
    }
};