I can't get this code to work. I am trying to check if a user has this role and ban them.
You're going about it the wrong way, you don't need to look for the ban
role, you just need to check if the GuildMember
has a role named ban
if (message.member.roles.cache.some(role => role.name === 'ban')) return message.member.ban({ reason: 'Had the ban role' })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.