简体   繁体   中英

Discord.js awaitReactions

const filter = (reaction, user) => {
  return (
    ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣"].includes(reaction.emoji.name) &&
    user.id === msg.author.id
  );
};

message
  .awaitReactions({ filter, max: 1, time: 30000, errors: ["time"] })
  .then(async function (collected) {
    const reaction = collected.first();

    console.log(reaction.emoji.name);

    if (reaction.emoji.name === "1️⃣") {
      message.delete();

      msg.reply("Done");
    }
  })
  .catch((collected) => {
    message.delete();
    msg.reply("No response given.");
  });

My Code Above is not working and never firing, I do not know why I looked up on google and they all give out this code. Any Help is Appreciated thanks.

The problem was I forgot to use the GUILD_MESSAGE_REACTIONS intent. My Bad.

Try replacing this line

  .awaitReactions({ filter, max: 1, time: 30000, errors: ["time"] })

with this

  .awaitReactions(filter,{ max: 1, time: 30000, errors: ["time"] })

awaitReactions has 2 optional parameters, the filter and the options . The problem is that you put all of them into the first parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM