mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
Draw Cards Command
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { shuffle } = require('../../util/Util');
|
||||
const suits = ['♣', '♥', '♦', '♠'];
|
||||
const faces = ['Jack', 'Queen', 'King'];
|
||||
|
||||
module.exports = class DrawCardsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'draw-cards',
|
||||
aliases: ['card-hand', 'draw-hand'],
|
||||
group: 'random',
|
||||
memberName: 'draw-cards',
|
||||
description: 'Draws a random hand of playing cards.',
|
||||
args: [
|
||||
{
|
||||
key: 'amount',
|
||||
label: 'hand size',
|
||||
prompt: 'How many cards do you want to draw?',
|
||||
max: 20,
|
||||
min: 1
|
||||
},
|
||||
{
|
||||
key: 'jokers',
|
||||
prompt: 'Do you want the deck to include jokers?',
|
||||
type: 'boolean',
|
||||
default: false
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.deck = null;
|
||||
}
|
||||
|
||||
run(msg, { jokers }) {
|
||||
if (!this.deck) this.deck = this.generateDeck();
|
||||
let cards = this.deck;
|
||||
if (!jokers) cards = cards.filter(card => !card.includes('Joker'));
|
||||
return msg.reply(shuffle(cards).join(', '));
|
||||
}
|
||||
|
||||
generateDeck() {
|
||||
const deck = [];
|
||||
for (const suit of suits) {
|
||||
deck.push(`${suit} Ace`);
|
||||
for (let i = 2; i <= 10; i++) deck.push(`${suit} ${i}`);
|
||||
for (const face of faces) deck.push(`${suit} ${face}`);
|
||||
}
|
||||
deck.push('⭐ Joker');
|
||||
deck.push('⭐ Joker');
|
||||
return deck;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user