mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 23:05:04 +02:00
Draw Cards Command
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "85.4.1",
|
||||
"version": "85.5.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user