Skip to content

Commit

Permalink
Prevent pardon from causing a negative strike count
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianVennen committed Feb 8, 2023
1 parent 1c5d51a commit 379fced
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/commands/user/PardonCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 379fced

Please sign in to comment.