Ardi
Ardi
DIAdiscord.js - Imagine an app
Created by Ardi on 6/28/2024 in #djs-questions
Reaction Collector not getting the correct size (capped at 1)
discord.js: 14.15.3 nodejs: v18.16.0 My intents are: Guilds GuildMessages GuildMessageReactions I'm using a reaction collector. Any time I print the collected.size, it returns 1 despite the filter showing multiple users reacting.
const filter = (reaction, user) => {
const userMember = guild.members.cache.get(user.id)
console.log(reaction.emoji.name === '🔑' && userMember.roles.cache.has(modRoleId))
return reaction.emoji.name === '🔑' && userMember.roles.cache.has(modRoleId)
}

const expireTimeMS = 20000

botMsg.awaitReactions({ filter, time: expireTimeMS })
.then(collected => {
console.log(collected.size)
if (member.roles.cache.has(administratorRoleId)) {
//console.log('User is already an administrator!')
return
}
if (collected.size >= modsRequired) {
member.roles.add(administratorRoleId)
channel.send(`confirmation here`)
}
});
const filter = (reaction, user) => {
const userMember = guild.members.cache.get(user.id)
console.log(reaction.emoji.name === '🔑' && userMember.roles.cache.has(modRoleId))
return reaction.emoji.name === '🔑' && userMember.roles.cache.has(modRoleId)
}

const expireTimeMS = 20000

botMsg.awaitReactions({ filter, time: expireTimeMS })
.then(collected => {
console.log(collected.size)
if (member.roles.cache.has(administratorRoleId)) {
//console.log('User is already an administrator!')
return
}
if (collected.size >= modsRequired) {
member.roles.add(administratorRoleId)
channel.send(`confirmation here`)
}
});
console output when 2 users react:
true
true
1
true
true
1
it prints true twice in the filter, but the collected.size is only 1. What am I doing wrong? If no users react, it does print zero. please @ me if someone responds, server is on @s only
13 replies