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
|
import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando';
import { MessageEmbed } from 'discord.js';
//@ts-ignore no types
import emoji from 'emoji-random'
import config from '../../config.json'
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'],
clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
guildOnly: true
});
}
//@ts-ignore this is not async
run(msg: CommandoMessage) {
if (config['validUsers'].includes(msg.author.id)) {
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 })
})
}
} else {
msg.delete()
//@ts-ignore
return msg.reply(`Insufficent permissions! ${emoji.random()}`).then(m => m.delete({ timeout: 3000 }))
}
}
};
|