/[sudobot]/trunk/src/commands/automation/AddQueueCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/automation/AddQueueCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.46  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26