2017-05-31 13 views
3

私は自分の不和のボットを作成してきたが、私はこのコードのためにこのエラーを持っている:確執JSボットメッセージに反応を追加

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

それはチャネルにメッセージを送信しますと、反応を追加し、私のコンソールで、私はこのエラーを持っている:

(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

答えて

3

これらはエラーではなく、警告です。それが言われているように、あなたの約束が拒否されたときはチェックしません。 拒否される場合は、.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 
      }); 
関連する問題