JS discord bot is getting error: Cannot send an empty message
JS discord bot is getting error: Cannot send an empty message
我正在制作一个 discord 机器人,但出现错误:
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).
我知道有问题,但不确定是什么。
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);
}
});
如果您键入 s!verifymsg,它会在同一个频道中发送一个嵌入,其中包含同一个嵌入中的一些文本。
查看本指南 (https://anidiots.guide/first-bot/using-embeds-in-messages),表明有几件事可能导致它:
1) new RichEmbed()
应该是 new Discord.RichEmbed()
。这就是 discord.js 文档显示的内容。
2) message.channel.send(embed);
应该是 message.channel.send({embed});
.
我正在制作一个 discord 机器人,但出现错误:
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).
我知道有问题,但不确定是什么。
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);
}
});
如果您键入 s!verifymsg,它会在同一个频道中发送一个嵌入,其中包含同一个嵌入中的一些文本。
查看本指南 (https://anidiots.guide/first-bot/using-embeds-in-messages),表明有几件事可能导致它:
1) new RichEmbed()
应该是 new Discord.RichEmbed()
。这就是 discord.js 文档显示的内容。
2) message.channel.send(embed);
应该是 message.channel.send({embed});
.