Had an issue the other day when all valid holders had their roles removed. I think this is because of:
if (userQualifiesForRole && !discordUser.roles.cache.has(role.id)) {
this.logger.info(`Assigning Role: ${role.name}`);
await discordUser.roles.add(role);
} else {
if (discordUser.roles.cache.has(role.id)) {
this.logger.info(`Removing Role: ${role.name}`);
await discordUser.roles.remove(role);
}
}
I fixed it by changing if (discordUser.roles.cache.has(role.id)) to if (!userQualifiesForRole && discordUser.roles.cache.has(role.id))
Am I missing something here?
Had an issue the other day when all valid holders had their roles removed. I think this is because of:
I fixed it by changing
if (discordUser.roles.cache.has(role.id))toif (!userQualifiesForRole && discordUser.roles.cache.has(role.id))Am I missing something here?