How to check if user has a role?

I'm trying to like below
module.exports = {
name: "guildMemberRemove",
once: false,

execute(member, client){

roleIds = "1072269497299374130"
const userHasRole = member.roles.some(r => roleIds.has(r));

console.log(userHasRole)
// member.roles.add(NotAuthRoleID).then(console.log('Role remove: ' + member.id));
}
}
module.exports = {
name: "guildMemberRemove",
once: false,

execute(member, client){

roleIds = "1072269497299374130"
const userHasRole = member.roles.some(r => roleIds.has(r));

console.log(userHasRole)
// member.roles.add(NotAuthRoleID).then(console.log('Role remove: ' + member.id));
}
}
But It didnt work... Is it old version code ? ( const userHasRole = member.roles.some(r => roleIds.has(r)); )
7 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
</> Idris
</> Idris2y ago
member.roles.cache.has(roleId) and you’re trying to add a role when the member is leaving which makes no sense
계정 버림
계정 버림OP2y ago
It works perfectly haha Thank youuuu
</> Idris
</> Idris2y ago
no prob
계정 버림
계정 버림OP2y ago
🙂 Can I ask more? how to ban that user from server?
</> Idris
</> Idris2y ago
member.guild.bans.create(member)
계정 버림
계정 버림OP2y ago
Thank uuu

Did you find this page helpful?