我的机器人发送了一个所有用户都看不到的嵌入,并且没有显示任何消息已发送

My bot sends an embed that is invisible to all users and shows no message sent

我一直致力于使用 JS 为我的服务器创建一个简单的 Discord Bot。我一直试图让它发送一条消息,其中嵌入了服务器的规则。当 /rules 命令为 运行 时,我收到一条通知,说明消息已发送,但在任何设备上都看不到任何消息。我可以查看消息历史记录,所以我不明白为什么没有可见的嵌入或消息。

我的代码是使用 Autocode 的 Discord Embed Builder 编写的,并且适用于同一机器人中的其他嵌入。 link 用于查看生成器中的完整嵌入代码并查看其外观是 here

与使用生成器并尝试对它们的编码工作原理进行逆向工程相比,自己学习制作这些要容易得多:

一个简单的例子是这样的:

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

module.exports = {
    name: "rules",
    description: "Post rules",

    run: async (client, interaction) => {

// build the message
        const embed = new MessageEmbed()
            .setColor('#00ff00') //change the color if you want
            .setTitle('Some Title')
            .setDescription(`Some description`)
            .addFields({
                name: 'Rule Name/Number',
                value: 'Rule text',
                inline: true
            }, {
                name: 'Rule Name/Number',
                value: `Rule text`,
                inline: true
            }, {
                name: 'Rule Name/Number',
                value: 'Rule text',
                inline: true
            })
// add more if needed


// send the message
        interaction.channel.send({
            embeds: [embed]
        })

// confirm they are sent and complete the interaction only visible to you
        return interaction.reply({
            content: 'Done',
            ephemeral: true
        })
    }
}