From 379fced2e2c51ccb0c12de32a3ddcdcc80dcd346 Mon Sep 17 00:00:00 2001 From: Julian Date: Wed, 8 Feb 2023 16:35:16 +0100 Subject: [PATCH] Prevent pardon from causing a negative strike count --- src/commands/user/PardonCommand.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/commands/user/PardonCommand.js b/src/commands/user/PardonCommand.js index 078d6966b..ec0411999 100644 --- a/src/commands/user/PardonCommand.js +++ b/src/commands/user/PardonCommand.js @@ -67,6 +67,17 @@ export default class PardonCommand extends Command { async pardon(interaction, member, reason, moderator, count) { await deferReplyOnce(interaction); count = inLimits(count, 1, 100); + count = Math.min(count, await member.getStrikeSum()); + + if (count === 0) { + await replyOrEdit(interaction, new EmbedWrapper() + .setDescription(inlineEmojiIfExists('pardon') + + `${bold(escapeMarkdown(member.user.tag))} has no strikes to pardon`) + .setColor(colors.RED) + .toMessage() + ); + return; + } reason = reason || 'No reason provided'; await member.pardon(reason, moderator, count);