1 |
import { Message } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import MessageEmbed from '../../client/MessageEmbed'; |
6 |
import { clearTimeoutv2, getTimeout, getTimeouts } from '../../utils/setTimeout'; |
7 |
|
8 |
export default class DelQueueCommand extends BaseCommand { |
9 |
constructor() { |
10 |
super('delqueue', 'automation', []); |
11 |
} |
12 |
|
13 |
async run(client: DiscordClient, msg: Message, options: CommandOptions) { |
14 |
if (options.args[0] === undefined) { |
15 |
await msg.reply({ |
16 |
embeds: [ |
17 |
new MessageEmbed() |
18 |
.setColor('#f14a60') |
19 |
.setDescription(`This command requires at least one argument.`) |
20 |
] |
21 |
}); |
22 |
|
23 |
return; |
24 |
} |
25 |
|
26 |
const timeout = await getTimeout(parseInt(options.args[0])); |
27 |
console.log(getTimeouts()); |
28 |
|
29 |
if (!timeout || timeout.row.guild_id !== msg.guild!.id) { |
30 |
await msg.reply({ |
31 |
embeds: [ |
32 |
new MessageEmbed() |
33 |
.setColor('#f14a60') |
34 |
.setDescription(`Invalid queue ID given.`) |
35 |
] |
36 |
}); |
37 |
|
38 |
return; |
39 |
} |
40 |
|
41 |
await clearTimeoutv2(timeout); |
42 |
|
43 |
await msg.reply({ |
44 |
embeds: [ |
45 |
new MessageEmbed() |
46 |
.setColor('#f14a60') |
47 |
.setDescription(`The queue has been deleted.`) |
48 |
.addField('Command', `\`${timeout.row.cmd}\``) |
49 |
.setFooter({ |
50 |
text: 'ID: ' + timeout.row.id |
51 |
}) |
52 |
] |
53 |
}); |
54 |
} |
55 |
} |