简体   繁体   English

discord.js “awaitReactions”事件不起作用?

[英]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.代码运行并输出“stuff applied.. waiting.”,但是当添加反应时什么也没有发生。

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 "}").代码看起来不错(您共享的代码缺少 3 结尾的“}”)。

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.尝试使用{max: 1, time: 10000}让听众等待 10 秒。

If you are using discord.js v13 make sure You have anabled the intents for reactions like that:如果您使用的是 discord.js v13,请确保您已启用此类反应的意图:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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