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 ms from 'ms'; |
8 |
if (cm.args[1] === undefined) { |
import { timeSince } from '../../utils/util'; |
9 |
|
import { setTimeoutv2 } from '../../utils/setTimeout'; |
10 |
|
|
11 |
|
export default class AddQueueCommand extends BaseCommand { |
12 |
|
constructor() { |
13 |
|
super('addqueue', 'automation', []); |
14 |
|
} |
15 |
|
|
16 |
|
async run(client: DiscordClient, msg: Message, options: CommandOptions) { |
17 |
|
if (options.args[1] === undefined) { |
18 |
await msg.reply({ |
await msg.reply({ |
19 |
embeds: [ |
embeds: [ |
20 |
new MessageEmbed() |
new MessageEmbed() |
26 |
return; |
return; |
27 |
} |
} |
28 |
|
|
29 |
const time = await ms(cm.args[0]); |
const time = await ms(options.args[0]); |
30 |
|
let cmd: string[]; |
31 |
|
|
32 |
if (!time) { |
if (!time) { |
33 |
await msg.reply({ |
await msg.reply({ |
41 |
return; |
return; |
42 |
} |
} |
43 |
|
|
44 |
const args = [...cm.args]; |
cmd = [...options.args]; |
45 |
args.shift(); |
cmd.shift(); |
46 |
|
|
47 |
if (typeof cm.commands[args[0]] === 'undefined') { |
const cmdObj = client.commands.get(cmd[0]); |
48 |
|
|
49 |
|
if (!cmdObj) { |
50 |
await msg.reply({ |
await msg.reply({ |
51 |
embeds: [ |
embeds: [ |
52 |
new MessageEmbed() |
new MessageEmbed() |
58 |
return; |
return; |
59 |
} |
} |
60 |
|
|
61 |
const command = await args.join(' '); |
if (!cmdObj.supportsLegacy) { |
62 |
|
await msg.reply({ |
63 |
|
embeds: [ |
64 |
|
new MessageEmbed() |
65 |
|
.setColor('#f14a60') |
66 |
|
.setDescription(`This command conflicts with queued jobs.`) |
67 |
|
] |
68 |
|
}); |
69 |
|
|
70 |
|
return; |
71 |
|
} |
72 |
|
|
73 |
|
const command = await cmd.join(' '); |
74 |
|
|
75 |
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', time, msg.guild!.id, command, command, msg.id, msg.channel!.id, msg.guild!.id); |
76 |
|
|
77 |
await msg.reply({ |
await msg.reply({ |
78 |
embeds: [ |
embeds: [ |
96 |
] |
] |
97 |
}); |
}); |
98 |
} |
} |
|
}; |
|
99 |
|
} |