diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index 31d260a3..79967732 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -272,15 +272,9 @@ export class ModActionsPlugin extends Plugin { } // Make sure we're allowed to mute this member - if (msg.member.id !== args.member.id) { - const ourLevel = this.getMemberLevel(msg.member); - const memberLevel = this.getMemberLevel(args.member); - if (ourLevel <= memberLevel) { - msg.channel.createMessage( - errorMessage("Cannot mute: insufficient permissions") - ); - return; - } + if (!this.canActOn(msg.member, args.member)) { + msg.channel.createMessage(errorMessage("Cannot mute: insufficient permissions")); + return; } // Convert mute time from e.g. "2h30m" to milliseconds @@ -382,6 +376,16 @@ export class ModActionsPlugin extends Plugin { } } + protected canActOn(member1, member2) { + if (member1.id === member2.id) { + return true; + } + + const ourLevel = this.getMemberLevel(member1); + const memberLevel = this.getMemberLevel(member2); + return (ourLevel > memberLevel); + } + /** * Attempts to message the specified user through DMs and/or the message channel. * Returns a promise that resolves to a boolean indicating whether we were able to message them or not.