最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Sending multiple embeds at once - Stack Overflow

programmeradmin2浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 6

You 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)
发布评论

评论列表(0)

  1. 暂无评论