From 3f85ed69cb53a48f953e3cf487a3ea4ac0e493cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Bl=C3=B6meke?= Date: Mon, 17 Jun 2019 18:25:17 +0200 Subject: [PATCH] Fully tested, also check if we can before asking for reason --- src/plugins/ModActions.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index ee372c4a..757ccc3b 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -1066,6 +1066,15 @@ export class ModActionsPlugin extends ZeppelinPlugin { return; } + // Verify we can act on each of the users specified + for (const userId of args.userIds) { + const member = this.guild.members.get(userId); // TODO: Get members on demand? + if (member && !this.canActOn(msg.member, member)) { + this.sendErrorMessage(msg.channel, "Cannot massban one or more users: insufficient permissions"); + return; + } + } + // Ask for ban reason (cleaner this way instead of trying to cram it into the args) msg.channel.createMessage("Ban reason? `cancel` to cancel"); const banReasonReply = await waitForReply(this.bot, msg.channel as TextChannel, msg.author.id); @@ -1076,15 +1085,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { const banReason = this.formatReasonWithAttachments(banReasonReply.content, msg.attachments); - // Verify we can act on each of the users specified - for (const userId of args.userIds) { - const member = this.guild.members.get(userId); // TODO: Get members on demand? - if (member && !this.canActOn(msg.member, member)) { - this.sendErrorMessage(msg.channel, "Cannot massban one or more users: insufficient permissions"); - return; - } - } - // Ignore automatic ban cases and logs for these users // We'll create our own cases below and post a single "mass banned" log instead args.userIds.forEach(userId => { @@ -1148,6 +1148,15 @@ export class ModActionsPlugin extends ZeppelinPlugin { return; } + // Verify we can act upon all users + for (const userId of args.userIds) { + const member = this.guild.members.get(userId); + if (member && !this.canActOn(msg.member, member)) { + this.sendErrorMessage(msg.channel, "Cannot massmute one or more users: insufficient permissions"); + return; + } + } + // Ask for mute reason msg.channel.createMessage("Mute reason? `cancel` to cancel"); const muteReasonReceived = await waitForReply(this.bot, msg.channel as TextChannel, msg.author.id); @@ -1162,15 +1171,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { const muteReason = this.formatReasonWithAttachments(muteReasonReceived.content, msg.attachments); - // Verify we can act upon all users - for (const userId of args.userIds) { - const member = this.guild.members.get(userId); - if (member && !this.canActOn(msg.member, member)) { - this.sendErrorMessage(msg.channel, "Cannot massmute one or more users: insufficient permissions"); - return; - } - } - // Ignore automatic mute cases and logs for these users // We'll create our own cases below and post a single "mass muted" log instead args.userIds.forEach(userId => {