mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
40 lines
933 B
JavaScript
40 lines
933 B
JavaScript
const Command = require('../../framework/Command');
|
|
const { randomRange, formatNumber } = require('../../util/Util');
|
|
|
|
module.exports = class RollCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'roll',
|
|
aliases: ['dice'],
|
|
group: 'random-res',
|
|
memberName: 'roll',
|
|
description: 'Rolls a dice with a minimum/maximum value of your choice.',
|
|
args: [
|
|
{
|
|
key: 'maxValue',
|
|
label: 'highest number',
|
|
type: 'integer',
|
|
default: 6,
|
|
min: 1,
|
|
max: Number.MAX_SAFE_INTEGER
|
|
},
|
|
{
|
|
key: 'minValue',
|
|
label: 'lowest number',
|
|
type: 'integer',
|
|
default: 0,
|
|
min: 0,
|
|
max: Number.MAX_SAFE_INTEGER
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
run(msg, { maxValue, minValue }) {
|
|
let result;
|
|
if (minValue) result = randomRange(minValue, maxValue);
|
|
else result = Math.floor(Math.random() * maxValue) + 1;
|
|
return msg.say(`You rolled a ${formatNumber(result)}.`);
|
|
}
|
|
};
|