admin管理员组文章数量:1391999
I'm trying to send multiple embeds (more specifically, just 2) at once when a user enters a certain mand. The reason being is that the information I want to print would look horrendously long in just 1 embed. I've heard this can only be done using webhooks as the discord API does not usually allow this. So the following code won't work:
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
I'm also using rich embeds as you can see, but I don't think that has any effect on what I'm trying to do. I have tried looking up how to properly use a webhook to do this, but I've barely even managed to just declare my hook. I'd appreciate it if I could get help on just how I'd go about doing what I'm trying to acplish (and if there actually IS a way to do this without using a webhook, by all means I'd love to hear it!)
I'm trying to send multiple embeds (more specifically, just 2) at once when a user enters a certain mand. The reason being is that the information I want to print would look horrendously long in just 1 embed. I've heard this can only be done using webhooks as the discord API does not usually allow this. So the following code won't work:
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
I'm also using rich embeds as you can see, but I don't think that has any effect on what I'm trying to do. I have tried looking up how to properly use a webhook to do this, but I've barely even managed to just declare my hook. I'd appreciate it if I could get help on just how I'd go about doing what I'm trying to acplish (and if there actually IS a way to do this without using a webhook, by all means I'd love to hear it!)
Share Improve this question edited Mar 15, 2018 at 16:06 André 4,4974 gold badges33 silver badges58 bronze badges asked Feb 5, 2018 at 0:55 asdasd 571 silver badge4 bronze badges2 Answers
Reset to default 6You can send multiple embeds to the same channel, I'm not sure who told you it's not possible. Here's the code I'm using, which successfully sends multiple embeds to a channel:
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);
});
}
As you can see, I wait for the first embed to be sent successfully & for the promise to return before sending the second embed. Are you running into errors while trying things like this?
I think it would be better if you used:
message.channel.send(embed1, embed2)
本文标签: javascriptSending multiple embeds at onceStack Overflow
版权声明:本文标题:javascript - Sending multiple embeds at once - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744620670a2616005.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论