summaryrefslogtreecommitdiff
path: root/src/commands/server/poll.ts
blob: 6230f8630d90d61ca57291df0c4c392330a260d5 (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
import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando';
import { MessageEmbed } from 'discord.js';
//@ts-ignore no types
import emoji from 'emoji-random'

module.exports = class PollServer extends Command {
    constructor(client: CommandoClient) {
        super(client, {
            name: 'poll',
            group: 'server',
            memberName: 'poll',
            description: 'Make a poll.',
            examples: ['uwu!poll am i cool?'],
            throttling: {
                usages: 5,
                duration: 30
            },
            userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'],
            clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
            guildOnly: true
        });
    }
    //@ts-ignore this is not async
    run(msg: CommandoMessage) {
        let messageArray = msg.content.split(' ')
        let args = messageArray.slice(1)

        if (!args || args.length < 1) {
            return msg.reply(`No poll content was specified. ${emoji.random()}`)
        } else {
            let emb = new MessageEmbed()
                .setColor(0xFFCC4D)
                .setFooter('React to vote.')
                .setDescription(args.join(' '))
                .setTitle(`Poll Created by ${msg.author.username} ${emoji.random()}`)
            return msg.say(emb).then(fMsg => {
                //@ts-ignore yes these exist
                fMsg.react('✅')
                //@ts-ignore yes these exist
                fMsg.react('❎')
                //@ts-ignore yes these exist
                msg.delete({ timeout: 1000 })
            })
        }
    }
};