Search code examples
javascriptdiscorddiscord.jsbotsembed

Throwing an error when trying to send a embed


I'm trying to create an embed using discord.js v12 and it keeps showing this error

DiscordAPIError: Cannot send an empty message

Heres my code:

        const infoembed = new MessageEmbed()
            .setColor('#0099ff')
            .setTitle(responce.asset.title)
            
        umsg.channel.send({ embeds: infoembed });

Solution

  • If responce.asset.title is empty - you will get an error because discord can't send embed with empty title! But you can try using this code:

    const infoembed = new MessageEmbed()
          .setColor('#0099ff')
          .setTitle(`** **`);
    
    umsg.channel.send(infoembed)