1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import { Command, CommandoMessage } from 'discord.js-commando';
import { shuffle } from '../../utils/Util.js'
const suits = ['♣', '♥', '♦', '♠']
const faces = ['Jack', 'Queen', 'King']
module.exports = class DrawCardsFun extends Command {
constructor(client) {
super(client, {
name: 'drawcards',
aliases: [
'draw-cards',
'drawhand',
'draw-hand'
],
group: 'fun',
memberName: 'drawcards',
description: 'Draw a hand of playing cards.',
examples: ['uwu!drawcards 5'],
throttling: {
usages: 5,
duration: 30
},
userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
args: [
{
key: 'aAmount',
label: 'hand size',
prompt: 'How many cards would you like to draw?',
type: 'integer',
max: 10,
min: 1
},
{
key: 'aJokers',
prompt: 'Do you want to include jokers in the draw?',
type: 'boolean',
default: false
}
],
});
this.deck = null
}
run(msg: CommandoMessage, { aAmount, aJokers }) {
if (!this.deck) this.deck = this.generateDeck()
let cards = this.deck
if (!aJokers) cards = cards.filter(card => !card.includes('Joker'))
return msg.reply(`${aAmount === 1 ? '' : '\n'}${shuffle(cards).slice(0, aAmount).join('\n')}`)
}
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
}
};
|