discord.js-命令正在添加更多字段以进行嵌入

问题描述

当我执行!命令时,它将使用我再次给出的5个字段进行嵌入,它将5个字段添加到下一个嵌入中,使其依次为10、15、20。如何停止此操作?

const Embed = new discord.MessageEmbed()
const discord = require("discord.js");
const client = new discord.Client();

client.on("message",message => {
        if (message.content === "!commands") {
            cmdEmbed
                .setTitle("Bot Commands")
                .setColor(0xff0000)
                .addField("!website","Brings up the official website")
                .addField("!botinfo","See who helped and made the bot.")
                .addField("!schedule","Brings up the Schedule")
                .addField("!calendar","Brings up the Calendar")
                .addField("!whitecalendar","Brings up the White calendar ")
                .setFooter("Commands");
    
            message.channel.send(Embed); 
        }
    });

解决方法

const discord = require("discord.js");
const client = new discord.Client();

client.on("message",message => {
    if (message.content === "!commands") {
        const Embed = new discord.MessageEmbed()
            .setTitle("Bot Commands")
            .setColor(0xff0000)
            .addField("!website","Brings up the official website")
            .addField("!botinfo","See who helped and made the bot.")
            .addField("!schedule","Brings up the Schedule")
            .addField("!calendar","Brings up the Calendar")
            .addField("!whitecalendar","Brings up the White calendar ")
            .setFooter("Commands");
        message.channel.send(Embed); 
    }
});

这是因为您定义了embed,然后使用下一个命令重新定义了embed,依此类推,依此类推。尝试上面的代码。