Skip to content

Commit

Permalink
fix: add validation check to random number command
Browse files Browse the repository at this point in the history
  • Loading branch information
sondr3 committed Dec 19, 2020
1 parent 0001c83 commit a86eca0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/commands/fun/random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ class RandomNumCommand extends Command {
});
}

run = async (message: CommandoMessage, { min, max }: { min: string; max: string }): Promise<Message | Message[]> => {
const num = await randomNumber(parseInt(min), parseInt(max));
run = async (message: CommandoMessage, { min, max }: { min: number; max: number }): Promise<Message | Message[]> => {
if (min >= max || max < min) {
return await message.reply(`That's illegal, yo`);
}

const num = await randomNumber(min, max);

logger.info({
message: "A random number was generated",
Expand Down

0 comments on commit a86eca0

Please sign in to comment.