Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  4] [ 4]  / answers: 1 / hits: 66690  / 7 Years ago, wed, may 31, 2017, 12:00:00

I've been created my own discord bot but i have this error for this code:





  		message.channel.send(:apple:***SONDAGE :apple:n +choix1+ ou ++choix2+***)
.then(function (message) {
message.react(👍)
message.react(👎)
message.pin()
message.delete()
});





It's send a message to the channel and add reaction, and in my console i have this error:





(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




More From » bots

 Answers
3

Those aren't error, those are warning. As it is said, you don't check when your promise is rejected.
You should use .catch() after .then() in case it get rejected.



https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise/catch



Try :



message.channel.send(:apple:***SONDAGE :apple:n +choix1+ ou ++choix2+***)
.then(function (message) {
message.react(👍)
message.react(👎)
message.pin()
message.delete()
}).catch(function() {
//Something
});

[#57611] Saturday, May 27, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
terrellhunterm

Total Points: 82
Total Questions: 109
Total Answers: 98

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
;