【问题标题】:Discord js Add reaction to a bot messageDiscord js添加对机器人消息的反应
【发布时间】:2017-11-01 06:03:24
【问题描述】:

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

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

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

(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

【问题讨论】:

    标签: javascript bots discord


    【解决方案1】:

    我遇到了同样的错误,你做message.delete(),但你想添加反应。删除消息后,机器人无法添加反应。只需删除message.delete() 就不会出现错误。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-13
        • 2019-09-16
        • 2021-09-12
        • 2020-08-12
        • 2020-07-29
        • 2020-06-13
        • 1970-01-01
        • 2020-12-23
        相关资源
        最近更新 更多