add roll command per request
This commit is contained in:
parent
042f42e02e
commit
68a313e0ab
1 changed files with 24 additions and 0 deletions
24
src/modules/misc/roll.js
Normal file
24
src/modules/misc/roll.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const Command = require("#lib/command.js");
|
||||
|
||||
const roll = new Command("roll");
|
||||
roll.category = "misc";
|
||||
roll.helpText = "Roll a dice";
|
||||
roll.usage = "<sides>";
|
||||
roll.addAlias("img");
|
||||
roll.callback = function (msg, line) {
|
||||
line = Number(line);
|
||||
if (!line || line == "" || Number.isNaN(line)) line = 6;
|
||||
if (line < 0) line = Math.abs(line);
|
||||
|
||||
if (line == 0) return ":hole:";
|
||||
if (line == 1) return ":one:";
|
||||
|
||||
const res = Math.floor(Math.random() * line);
|
||||
|
||||
if (line == 2) {
|
||||
return `:coin:: ${res == 1 ? "Heads" : "Tails"}`;
|
||||
}
|
||||
|
||||
return `:game_die: (d${line}): ${1 + res}`;
|
||||
};
|
||||
hf.registerCommand(roll);
|
Loading…
Add table
Add a link
Reference in a new issue