Search code examples
javascriptnode.jsdiscorddiscord.js

Error message when sending embed discord.js


here is my code:

client.on('messageCreate', async(msg) => {
if (msg.content.startsWith('do avatar')) {
const user = msg.mentions.users.first() || msg.author;
const avatarEmbed = new discord_js_1.MessageEmbed()
  .setColor(0x333333)
  .setTitle(`${user.username}'s Avatar`)
  .setImage(`https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png?size=256`
  );
msg.channel.send({ embed: [avatarEmbed] });
}
  });

and here is my error:

DiscordAPIError: Cannot send an empty message

what am i doing wrong?


Solution

  • you have are using embed property while sending the message, that doesn't exist. It should be embeds