message.awaitReactions 没有检测到我的反应 [英] message.awaitReactions not detecting my reactions

查看:12
本文介绍了message.awaitReactions 没有检测到我的反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要反应的不和谐命令.但是当我对消息做出反应时,它根本什么都不做,当它结束时它会记录 Collected 0 items.

I have a discord command that requires reactions. But when I react to the message it doesn't do anything at all and when it ends it logs Collected 0 items.

代码:

const msg = await message.reply("React to this message as quickly as you can.").catch(console.error);
const filter = (reaction, user) => {
    return reaction.emoji.name && user.id === message.author.id;
};
            
const collector = msg.createReactionCollector({ filter, time: 15000 });
      
collector.on('collect', (reaction, user) => {
    console.log(`Collected ${reaction.emoji.name} from ${user.tag}`);
});
    
collector.on('end', collected => {
    console.log(`Collected ${collected.size} items`);
});

推荐答案

收集器需要 Intent.你必须确保你有公会消息意图和公会消息反应意图.您还必须确保消息被缓存.

Collectors require intents. You must make sure you have Guild messages intents, and guild message reaction intents. You must also make sure the message is cached.

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MESSAGE_REACTIONS
  ]
})

这篇关于message.awaitReactions 没有检测到我的反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆