简体   繁体   中英

JS discord bot is getting error: Cannot send an empty message

I'm making a discord bot, but I'm getting the error:

Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch() . (rejection id: 2).

I know something is wrong, but not sure what is it.

client.on('message', message => {
  if (message.content === 's!verifymsg') {
    const embed = new RichEmbed()
      .setTitle('__**VERIFICACIÓN**__')
      .setColor(0xFF0000)
      .setDescription('¡Para poder ver los demás canales, es necesario que reacciones para verificar! \n- Reacciona con (✅)')
    message.channel.send(embed);
  }
});

If you type s!verifymsg it sends an embed in that same channel containing some text in that same embed.

Looking at this guide ( https://anidiots.guide/first-bot/using-embeds-in-messages ), shows be that there are a couple things that might be causing it:

1) new RichEmbed() should probably be new Discord.RichEmbed() . This is what the discord.js documentation shows.

2) message.channel.send(embed); should probably be message.channel.send({embed}); .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM