首页 > 解决方案 > 通过交互发送嵌入

问题描述

我在使用交互命令后尝试发送嵌入,但出现以下错误:

throw new DiscordAPIError(data, res.status, request);
          
DiscordAPIError: Cannot send an empty message
if (interaction.commandName == "ping") {
    const exampleEmbed = new MessageEmbed()
        .setColor("#0099ff")
        .setTitle("Pong")
        .setDescription("Some description here");
    interaction.reply(exampleEmbed);
}

我已经读过我需要将它作为一个数组发送,但是我该怎么做呢?提前致谢。

标签: javascriptnode.jsdiscorddiscord.js

解决方案


快速阅读Sending messages, embeds, files, etc.后,您必须这样做:

if (interaction.commandName == "ping") {
    const exampleEmbed = new MessageEmbed()
        .setColor("#0099ff")
        .setTitle("Pong")
        .setDescription("Some description here");
    interaction.reply({ embeds: [exampleEmbed] });
}

推荐阅读