Use flags

This commit is contained in:
Dragon Fire
2024-03-30 00:11:31 -04:00
parent 0b807767d1
commit 4674fc8d45
5 changed files with 72 additions and 40 deletions
+12 -8
View File
@@ -9,6 +9,16 @@ module.exports = class DrawCardsCommand extends Command {
group: 'random-res',
memberName: 'draw-cards',
description: 'Draws a random hand of playing cards.',
flags: [
{
key: 'jokers',
description: 'Includes jokers in the deck.'
},
{
key: 'j',
description: 'Alias for bot.'
}
],
args: [
{
key: 'amount',
@@ -17,19 +27,13 @@ module.exports = class DrawCardsCommand extends Command {
type: 'integer',
max: 10,
min: 1
},
{
key: 'jokers',
prompt: 'Do you want the deck to include jokers?',
type: 'boolean',
default: false
}
]
});
}
run(msg, { amount, jokers }) {
const deck = new Deck({ includeJokers: jokers });
run(msg, { amount, flags }) {
const deck = new Deck({ includeJokers: Boolean(flags.jokers || flags.j) });
const cards = deck.draw(amount);
const display = Array.isArray(cards) ? cards.map(c => c.display).join('\n') : cards.display;
return msg.reply(`${amount === 1 ? '' : '\n'}${display}`);