1 |
const { MessageEmbed } = require("discord.js"); |
import { CommandInteraction, GuildMember, Interaction, Message } from 'discord.js'; |
2 |
const ms = require("ms"); |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
const { clearTimeoutv2, getTimeout, setTimeoutv2 } = require("../src/setTimeout"); |
import DiscordClient from '../../client/Client'; |
4 |
const { timeSince } = require("../src/util"); |
import CommandOptions from '../../types/CommandOptions'; |
5 |
|
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
module.exports = { |
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
async handle(msg, cm) { |
import Help from '../../utils/help'; |
8 |
if (cm.args[1] === undefined) { |
import ms from 'ms'; |
9 |
|
import { timeSince } from '../../utils/util'; |
10 |
|
import { setTimeoutv2 } from '../../utils/setTimeout'; |
11 |
|
|
12 |
|
export default class AddQueueCommand extends BaseCommand { |
13 |
|
constructor() { |
14 |
|
super('addqueue', 'automation', []); |
15 |
|
} |
16 |
|
|
17 |
|
async run(client: DiscordClient, msg: Message, options: CommandOptions) { |
18 |
|
if (options.args[1] === undefined) { |
19 |
await msg.reply({ |
await msg.reply({ |
20 |
embeds: [ |
embeds: [ |
21 |
new MessageEmbed() |
new MessageEmbed() |
27 |
return; |
return; |
28 |
} |
} |
29 |
|
|
30 |
const time = await ms(cm.args[0]); |
const time = await ms(options.args[0]); |
31 |
|
let cmd: string[]; |
32 |
|
|
33 |
if (!time) { |
if (!time) { |
34 |
await msg.reply({ |
await msg.reply({ |
42 |
return; |
return; |
43 |
} |
} |
44 |
|
|
45 |
const args = [...cm.args]; |
cmd = [...options.args]; |
46 |
args.shift(); |
cmd.shift(); |
47 |
|
|
48 |
if (typeof cm.commands[args[0]] === 'undefined') { |
const cmdObj = client.commands.get(cmd[0]); |
49 |
|
|
50 |
|
if (!cmdObj) { |
51 |
await msg.reply({ |
await msg.reply({ |
52 |
embeds: [ |
embeds: [ |
53 |
new MessageEmbed() |
new MessageEmbed() |
59 |
return; |
return; |
60 |
} |
} |
61 |
|
|
62 |
const command = await args.join(' '); |
if (!cmdObj.supportsLegacy) { |
63 |
|
await msg.reply({ |
64 |
|
embeds: [ |
65 |
|
new MessageEmbed() |
66 |
|
.setColor('#f14a60') |
67 |
|
.setDescription(`This command conflicts with queued jobs.`) |
68 |
|
] |
69 |
|
}); |
70 |
|
|
71 |
|
return; |
72 |
|
} |
73 |
|
|
74 |
|
const command = await cmd.join(' '); |
75 |
|
|
76 |
const queue = await setTimeoutv2('queue.js', time, msg.guild.id, command, command, msg.id, msg.channel.id, msg.guild.id); |
const queue = await setTimeoutv2('queue.ts', time, msg.guild!.id, command, command, msg.id, msg.channel!.id, msg.guild!.id); |
77 |
|
|
78 |
await msg.reply({ |
await msg.reply({ |
79 |
embeds: [ |
embeds: [ |
97 |
] |
] |
98 |
}); |
}); |
99 |
} |
} |
|
}; |
|
100 |
|
} |