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