diff --git a/lib/commands/mutemenu.js b/lib/commands/mutemenu.js index abec1a281..a951f0fcc 100644 --- a/lib/commands/mutemenu.js +++ b/lib/commands/mutemenu.js @@ -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.`) } } diff --git a/lib/security.js b/lib/security.js index 4fa8b6e4c..d487a1d16 100644 --- a/lib/security.js +++ b/lib/security.js @@ -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) @@ -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.` } @@ -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.` }