mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Use flags
This commit is contained in:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user