一次发送多个嵌入
Sending multiple embeds at once
我正在尝试在用户输入特定命令时一次发送多个嵌入(更具体地说,只有 2 个)。原因是我想要打印的信息在 1 个嵌入中看起来会非常长。我听说这只能使用 webhooks 来完成,因为 discord API 通常不允许这样做。所以下面的代码将不起作用:
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);
});
}
如您所见,我等待第一个嵌入成功发送并等待 return 的承诺,然后再发送第二个嵌入。您在尝试这样的事情时 运行 是否遇到过错误?
我觉得如果你用的话会更好:
message.channel.send(embed1, embed2)
我正在尝试在用户输入特定命令时一次发送多个嵌入(更具体地说,只有 2 个)。原因是我想要打印的信息在 1 个嵌入中看起来会非常长。我听说这只能使用 webhooks 来完成,因为 discord API 通常不允许这样做。所以下面的代码将不起作用:
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);
});
}
如您所见,我等待第一个嵌入成功发送并等待 return 的承诺,然后再发送第二个嵌入。您在尝试这样的事情时 运行 是否遇到过错误?
我觉得如果你用的话会更好:
message.channel.send(embed1, embed2)