Discord js 添加对机器人消息的反应

Zar*_*Kai 7 javascript bots discord

我已经创建了自己的不和谐机器人,但此代码出现此错误:

  		message.channel.send(":apple:***SONDAGE :apple:\n "+choix1+" ou "+""+choix2+"***")
    		.then(function (message) {
          message.react("")
          message.react("")
       		message.pin()
          message.delete()
    			});
Run Code Online (Sandbox Code Playgroud)

它向频道发送消息并添加反应,在我的控制台中我有这个错误:

(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
Run Code Online (Sandbox Code Playgroud)

Nev*_*sis 11

那些不是错误,那些是警告。如前所述,当您的承诺被拒绝时,您不会检查。你应该在 .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
             });
Run Code Online (Sandbox Code Playgroud)