我已经创建了我自己的 discord 机器人,但我有此代码的错误:
message.channel.send(":apple:***SONDAGE :apple:\n "+choix1+" ou "+""+choix2+"***")
.then(function (message) {
message.react("👍")
message.react("👎")
message.pin()
message.delete()
});
它向 channel 发送消息并添加 react ,在我的控制台中出现此错误:
(node:11728) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): DiscordAPIError: Unknown Message
(node:11728) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:11728) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): DiscordAPIError: Unknown Message
最佳答案
那些不是错误,那些是警告。正如所说,当您的 promise 被拒绝时,您不会检查。 你应该在 .then() 之后使用 .catch() 以防它被拒绝。
https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise/catch
尝试:
message.channel.send(":apple:***SONDAGE :apple:\n "+choix1+" ou "+""+choix2+"***")
.then(function (message) {
message.react("👍")
message.react("👎")
message.pin()
message.delete()
}).catch(function() {
//Something
});
关于javascript - Discord js 添加对机器人消息的 react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44284666/