/[sudobot]/trunk/commands/addqueue.js
ViewVC logotype

Annotation of /trunk/commands/addqueue.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (hide annotations)
Mon Jul 29 17:28:21 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 2150 byte(s)
Added clearTimeoutv2() function
1 rakin 46 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     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26