Javascript 一次发送多个嵌入

Javascript 一次发送多个嵌入,javascript,node.js,discord.js,Javascript,Node.js,Discord.js,我试图在用户输入某个命令时一次发送多个嵌入(更具体地说,仅2个)。原因是,我想要打印的信息在1分钟内看起来会非常长。我听说这只能使用webhook来实现,因为discordapi通常不允许这样做。因此,以下代码将不起作用: const embed = new Discord.RichEmbed() .setAuthor("blah") .addField("blah") message.channel.send({embed}) // this will send fine const emb

我试图在用户输入某个命令时一次发送多个嵌入(更具体地说,仅2个)。原因是,我想要打印的信息在1分钟内看起来会非常长。我听说这只能使用webhook来实现,因为discordapi通常不允许这样做。因此,以下代码将不起作用:

const embed = new Discord.RichEmbed()
.setAuthor("blah")
.addField("blah")
message.channel.send({embed}) // this will send fine

const embed2 = new Discord.RichEmbed()
.setAuthor("blah")
.addField("blah")
message.channel.send({embed2});   // This wont work

正如你所看到的,我也在使用富嵌入,但我不认为这对我的尝试有任何影响。我曾尝试查找如何正确使用webhook来实现这一点,但我甚至都没能声明我的钩子。如果我能得到帮助,帮助我完成我想要完成的事情,我将不胜感激(如果真的有一种不用webhook就能做到这一点的方法,我很乐意听到!)

你可以将多个嵌入发送到同一个频道,我不确定是谁告诉你这是不可能的。下面是我正在使用的代码,它成功地将多个嵌入发送到一个通道:

function send2Embeds(message) {
    let channel = message.channel;

    // next create rich embeds
    let embed1 = new Discord.RichEmbed({
        title: 'embed1',
        description: 'description1',
        author: {
            name: 'author1'
        }
    });

    let embed2 = new Discord.RichEmbed({
        title: 'embed2',
        description: 'description2',
        author: {
            name: 'author2'
        }
    });

    // send embed to channel
    channel.send(embed1)
    .then(msg => {
        // after the first is sent, send the 2nd (makes sure it's in the correct order)
        channel.send(embed2);
    });
}

如您所见,我等待第一个嵌入成功发送&等待承诺在发送第二个嵌入之前返回。您在尝试这样的事情时是否遇到错误?

我认为如果您使用:

message.channel.send(embed1, embed2)

哦,就是这样!当我尝试使用.addfield等方法时,它不起作用。它说我试图发送一条空消息。我在discord.js discord服务器中,我尝试在“问题”频道中搜索“发送多个嵌入”,每个回复都说必须使用Webhook。所以,要么是我试图做的事情和他们正在谈论的事情之间存在着沟通错误,要么是他们都错了。不管怎样,谢谢你,这正是我需要它做的。@SirOxorsid-啊,奇怪,也许你需要添加一个
标题
说明
,而不仅仅是
作者
字段
?很高兴这有帮助!