summaryrefslogtreecommitdiff
path: root/server/src/commands/minigames/Coinflip.ts
blob: 1962b00f7709ed7ad045d5052524d874429651fd (plain) (blame)
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
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import { colour } from '../../Config';

export default class CoinflipMinigames extends Command {
    public constructor() {
        super('coinflip', {
            aliases: ['coinflip', 'flipcoin', 'coin-flip', 'flip-coin'],
            category: 'minigames',
            description: {
                content: 'Flip a coin.',
                usage: '',
                examples: [
                    ''
                ]
            },
            ratelimit: 3,
            args: [
                {
                    id: 'type',
                    type: 'string',
                    prompt: {
                        start: 'What type of coinflip would you like?',
                        retry: 'That is not a valid type',
                        optional: true
                    }
                }
            ]
        });
    }
    
    public exec(msg: Message, { type }): Promise<Message> {
        let outcomes;
        let quantum = false;
        if (type === 'quantum' || type === 'q') {
            outcomes = ['NaN', '0', 'null', 'undefined', ''];
            quantum = true;
        } else {
            outcomes = ['heads!', 'tails!'];
        }
        const side = outcomes[Math.floor(Math.random() * outcomes.length)];
        
        const embed = this.client.util.embed()
            .setColor(colour)
            .setAuthor(`The ${quantum ? 'quantum' : ''} coin landed on`,
                'https://i.imgur.com/pr7JCce.png')
            .setDescription(`\`${side}\``);
        return msg.channel.send(embed);
    }
}