1 |
const { MessageEmbed } = require("discord.js"); |
2 |
const ms = require("ms"); |
3 |
const { clearTimeoutv2, getTimeout, setTimeoutv2 } = require("../src/setTimeout"); |
4 |
const { timeSince } = require("../src/util"); |
5 |
|
6 |
module.exports = { |
7 |
async handle(msg, cm) { |
8 |
if (cm.args[1] === undefined) { |
9 |
await msg.reply({ |
10 |
embeds: [ |
11 |
new MessageEmbed() |
12 |
.setColor('#f14a60') |
13 |
.setDescription(`This command requires at least two arguments.`) |
14 |
] |
15 |
}); |
16 |
|
17 |
return; |
18 |
} |
19 |
|
20 |
const time = await ms(cm.args[0]); |
21 |
|
22 |
if (!time) { |
23 |
await msg.reply({ |
24 |
embeds: [ |
25 |
new MessageEmbed() |
26 |
.setColor('#f14a60') |
27 |
.setDescription(`Invalid time interval given.`) |
28 |
] |
29 |
}); |
30 |
|
31 |
return; |
32 |
} |
33 |
|
34 |
const args = [...cm.args]; |
35 |
args.shift(); |
36 |
|
37 |
if (typeof cm.commands[args[0]] === 'undefined') { |
38 |
await msg.reply({ |
39 |
embeds: [ |
40 |
new MessageEmbed() |
41 |
.setColor('#f14a60') |
42 |
.setDescription(`Invalid command given.`) |
43 |
] |
44 |
}); |
45 |
|
46 |
return; |
47 |
} |
48 |
|
49 |
const command = await args.join(' '); |
50 |
|
51 |
const queue = await setTimeoutv2('queue.js', time, command, msg.id, msg.channel.id, msg.guild.id); |
52 |
|
53 |
await msg.reply({ |
54 |
embeds: [ |
55 |
new MessageEmbed() |
56 |
.setColor('#007bff') |
57 |
.setDescription(`The queue has been added.`) |
58 |
.setFields([ |
59 |
{ |
60 |
name: "ID", |
61 |
value: queue.row.id + '', |
62 |
}, |
63 |
{ |
64 |
name: "Command", |
65 |
value: `\`${command}\`` |
66 |
}, |
67 |
{ |
68 |
name: "Time", |
69 |
value: "After " + timeSince(Date.now() - time).replace(' ago', '') |
70 |
} |
71 |
]) |
72 |
] |
73 |
}); |
74 |
} |
75 |
}; |