Draw Cards Command

This commit is contained in:
Dragon Fire
2018-07-26 21:38:42 -04:00
parent d5aa3d4ab0
commit 2819cb4add
3 changed files with 55 additions and 2 deletions
+2 -1
View File
@@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with
The bot is no longer available for invite. You can self-host the bot, or use her
on the [home server](https://discord.gg/sbMe32W).
## Commands (293)
## Commands (294)
### Utility:
* **eval**: Executes JavaScript code.
@@ -53,6 +53,7 @@ on the [home server](https://discord.gg/sbMe32W).
* **discord-email-fun-fact**: Responds with a random fun fact from the Discord emails.
* **dog-fact**: Responds with a random dog fact.
* **dog**: Responds with a random dog image.
* **draw-cards**: Draws a random hand of playing cards.
* **fact-core**: Responds with a random Fact Core quote.
* **fact**: Responds with a random fact.
* **fidget**: Responds with a random image of Fidget.
+52
View File
@@ -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;
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "85.4.1",
"version": "85.5.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {