Defaulting negative dice inputs.

This commit is contained in:
ThePendulum 2022-10-24 02:47:39 +02:00
parent a0ab0302f3
commit 2c2e7ee532
1 changed files with 2 additions and 7 deletions

View File

@ -15,13 +15,8 @@ function onCommand(args, context) {
return; return;
} }
const rolls = Number(args[0]) || 1; const rolls = Math.max(Number(args[0]) || 1, 1);
const faces = Number(args[1]) || 6; const faces = Math.max(Number(args[1]) || 6, 1);
if (rolls < 1 || faces < 1) {
context.sendMessage('The dice must exist in the physical universe.', context.room.id);
return;
}
if (rolls > config.dice.maxRolls) { if (rolls > config.dice.maxRolls) {
context.sendMessage(`You can only roll ${config.dice.maxRolls} dice at one time`, context.room.id); context.sendMessage(`You can only roll ${config.dice.maxRolls} dice at one time`, context.room.id);