gb_factory
gb_factory

Reputation: 25

Empty message problem with discord.js embeds

I'm having some problems with discord embed

I have 3 embeds: embed1, embed2, embed3 but when i try to send an embed with a message with this code: message.channel.send({embed1})

I get this error:

(node:24120) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message

Upvotes: 0

Views: 3595

Answers (2)

Mark Andrew
Mark Andrew

Reputation: 168

I had to do:

    message.channel.send({ embeds: [embed] })

Upvotes: 3

Frustrated programmer
Frustrated programmer

Reputation: 711

This is cause in ES6 without adding the definer in an object. The varible's name is now the definer. Example:

    message.channel.send({embed1});
    //Get's translated to: 
    message.channel.send({embed1:embed1});

Since all objects need an definer and a value. ES6 just shortens it.

So your message.channel.send({embed1}); sets the definer to embed1
Which then embed is undefined, and Discord.js doesn't know where the message is as it looks for the definer embed not embed1. Therefore it thinks it has no message or embed to send, Hence the empty message error

To upload your embed with your current code you'll need message.channel.send({embed:embed1});;

Upvotes: 3

Related Questions