向邮件添加多个反应时出现问题

时间:2020-10-08 20:17:54

标签: javascript discord.js

我在向一条消息添加多个反应时遇到了问题(试图添加8-9)。

基本上,脚本会在等待时正常添加响应,但是如果您在脚本全部添加后对表情符号做出反应,即使在消息已被删除后,脚本也会继续尝试添加其余表情符号,从而引发错误在下面。

(node:17500) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
    at RequestHandler.execute (C:\Users\#######\Documents\project-folder\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)

那么,对我在做什么错有任何想法吗?

// Context

message.channel.send({ embed: randomEmbed }).then((msg) => {
  msg.react(emNumber[0]).then(() => {
    for (let i = 0; i < dcArr.length && !msg.deleted; i++) {
      if (dcArr[i]["server_id"] == user.server_id) continue;
      msg.react(emNumber[i + 1]);
    }
  });

  var filter = (reaction, user) => {
    return (
      emNumber.slice(0, dcArr.length - 1).includes(reaction.emoji.name) &&
      user.id === discId
    );
  };

  msg
    .awaitReactions(filter, { max: 1, time: 20000, errors: ["time"] })
    .then(async (collected) => {
      msg.delete();
      message.channel.send({ embed: anotherRandomEmbed }).then((msg) => {
        msg.react(emThumbs[1]);
        msg.react(emThumbs[0]);

        // Something

        var filter = (reaction, user) => {
          return emThumbs.includes(reaction.emoji.name) && user.id === discId;
        };

        msg
          .awaitReactions(filter, { max: 1, time: 20000, errors: ["time"] })
          .then(async (collected) => {
            // Something else
          });
      });
    });
});

0 个答案:

没有答案