Skip to content

Commit

Permalink
Merge pull request #562 from aternosorg/pardon
Browse files Browse the repository at this point in the history
Prevent pardon from causing a negative strike count
  • Loading branch information
JulianVennen authored Feb 9, 2023
2 parents a4955eb + 379fced commit 51611d6
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 51611d6

Please sign in to comment.