'discord bot embed code DiscordAPIError problem

im nemson

i have a problem with my embed code this is the code i have for the embed

  if (message.content === prefix + "help") {
    const embed = new MessageEmbed()
      .setTitle("Commandes")
      .setColor("#0099ff")
      .setDescription(
        "**-help** : Affiche les commandes du bot\n" +
        "**-ping** : Affiche le ping du bot\n" +
        "**-cat** : Affiche une image de chat\n" +
        "**-dog** : Affiche une image de chien\n" +
        "**-gif** : Affiche un gif random\n" +
        "**-anime** : Affiche un gif d'anime\n" 
      )
      .setFooter("Bot de test")
      .setTimestamp();
    message.channel.send(embed);
  }
});

but the problem is that wen i run the comand i get this error ant i dont know how to solv it Uncaught DiscordAPIError DiscordAPIError: Cannot send an empty message at DiscordAPIError (c:\Users\user\Documents\receptionist\node_modules\discord.js\src\rest\DiscordAPIError.js:9:5) at execute (c:\Users\user\Documents\receptionist\node_modules\discord.js\src\rest\RequestHandler.js:350:13) at processTicksAndRejections (node:internal/process/task_queues:96:5)

thx for your help



Solution 1:[1]

When you use message.channel.send(embed), discord.js thinks that the embed variable is a string and when it finds out that it isn't, it raises an error. To fix it, all you have to do is change it to: message.channel.send({ embeds: [embed]})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Caladan