简体   繁体   中英

discord.js "awaitReactions" event not functional?

Below is a small section from the code, if you need more to understand the issue then let me know. The code runs and outputs "stuff applied.. awaiting.", but when a reaction is added nothing happens.

let PossibleMessage = await Message.channel.send({embeds: [msgEmbed1]});

PossibleMessage.react("✅").then(() => {
  PossibleMessage.react("❎").then(() => {
    console.log("stuff applied.. awaiting.")
    PossibleMessage.awaitReactions(
      (Reaction, User) => User.id == Message.author.id && (Reaction.emoji.name == "❎" || Reaction.emoji.name == "✅"),
      {max: 1, time: 3000}

    ).then(Collected => {
      console.log("yes")
      if (Collected.first().emoji.name == "✅") {
        console.log("ye2")

The code looks fine (the code you shared miss the 3 ending "}").

Maybe the time you have insterted in the options is too fast and the event ends without get any response. Try with {max: 1, time: 10000} to make the listener wait for 10 seconds.

If you are using discord.js v13 make sure You have anabled the intents for reactions like that:

const Discord = require('discord.js');
const client = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS] });

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