roll: actually fix 0 and no args/nan

This commit is contained in:
Cynthia Foxwell 2024-08-18 15:15:32 -06:00
parent 16ea0aaef0
commit 33065b8aa6

View file

@ -6,14 +6,14 @@ roll.helpText = "Roll a dice";
roll.usage = "<sides>";
roll.addAlias("img");
roll.callback = function (msg, line) {
if (line == null || line == "") line = 6;
line = Number(line);
if (Number.isNaN(line)) line = 6;
if (line < 0) line = Math.abs(line);
if (line == 0) return ":hole:";
if (line == 1) return ":one:";
if (line == null || line == "" || Number.isNaN(line)) line = 6;
if (line < 0) line = Math.abs(line);
const res = Math.floor(Math.random() * line);
if (line == 2) {