0

Added missing bounds check to dice maximum range.

This commit is contained in:
Logan Fick
2019-05-31 18:17:22 -04:00
parent 1122bff7e2
commit 68ecf4acd1

View File

@@ -40,6 +40,12 @@ public final class Dice implements Command {
.setDeletionDelay(30, TimeUnit.SECONDS);
}
if (maximumRange < 1) {
return new CommandResponse("x",
"Sorry " + executor.getAsMention() + ", but the maximum range must be at least 1.")
.setDeletionDelay(30, TimeUnit.SECONDS);
}
return new CommandResponse("game_die",
executor.getAsMention() + ", the dice rolled **" + (rng.nextInt(maximumRange) + 1) + "**.");
}