Supported 1d6 dice input.
This commit is contained in:
parent
c63f05fcf5
commit
313b473aba
|
@ -8,9 +8,21 @@ const style = require('../utils/style');
|
|||
const dieFaces = ['⚀', '⚁', '⚂', '⚃', '⚄', '⚅'];
|
||||
|
||||
function onCommand(args, context) {
|
||||
const pattern = args[0]?.match(/(\d+)?d(\d+)?/i);
|
||||
|
||||
if (pattern) {
|
||||
onCommand(pattern.slice(1), context);
|
||||
return;
|
||||
}
|
||||
|
||||
const rolls = Number(args[0]) || 1;
|
||||
const faces = Number(args[1]) || 6;
|
||||
|
||||
if (rolls < 1 || faces < 1) {
|
||||
context.sendMessage('The dice must exist in the physical universe.', context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rolls > config.dice.maxRolls) {
|
||||
context.sendMessage(`You can only roll ${config.dice.maxRolls} dice at one time`, context.room.id);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue