diff --git a/README.md b/README.md index f0992f76..1813f767 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/commands/random/draw-cards.js b/commands/random/draw-cards.js new file mode 100644 index 00000000..38f378a5 --- /dev/null +++ b/commands/random/draw-cards.js @@ -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; + } +}; diff --git a/package.json b/package.json index 19ffc7fe..00aad4f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "85.4.1", + "version": "85.5.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {