Skip to content

Commit

Permalink
Remove verified role on mute (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
raiyni authored Aug 4, 2024
1 parent 8b4e35a commit 40116fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/commands/mutemenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default {
await logs.send(`:mute: ${buildUserDetail(user)} was muted by **${interaction.user.tag}**.`)
}

await removeRole(member, guild.roles, config.roles.verified)

return interaction.followUp(`${buildUserDetail(user)} was muted.`)
}
}
Expand Down
10 changes: 6 additions & 4 deletions lib/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ function resetMessageCache () {
return Promise.resolve()
}

function hasRole (member, roleName) {
return member.roles.cache.find(r => r.name.toLowerCase() === roleName)
}

async function ensureRoles (member, allRoles) {
const roles = roleDb.get(member.id)

Expand All @@ -364,9 +368,8 @@ async function ensureRoles (member, allRoles) {

async function assignRole (member, allRoles, roleToGive) {
const roleName = roleToGive.toLowerCase()
const hasRole = member.roles.cache.find(r => r.name.toLowerCase() === roleName)

if (hasRole) {
if (hasRole(member, roleName)) {
return `Cannot assign role ${roleToGive} to user ${member.toString()}, user already has the role.`
}

Expand Down Expand Up @@ -401,9 +404,8 @@ async function assignRole (member, allRoles, roleToGive) {

async function removeRole (member, allRoles, roleToRemove) {
const roleName = roleToRemove.toLowerCase()
const foundRole = member.roles.cache.find(r => r.name.toLowerCase() === roleName)

if (!foundRole) {
if (!hasRole(member, roleName)) {
return `Cannot remove role ${roleToRemove} from user ${member.toString()}, user already has the role.`
}

Expand Down

0 comments on commit 40116fa

Please sign in to comment.