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

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

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

revision 393 by rakin, Mon Jul 29 17:29:59 2024 UTC revision 444 by rakin, Mon Jul 29 17:30:16 2024 UTC
# Line 24  import CommandOptions from '../../types/ Line 24  import CommandOptions from '../../types/
24  import InteractionOptions from '../../types/InteractionOptions';  import InteractionOptions from '../../types/InteractionOptions';
25  import MessageEmbed from '../../client/MessageEmbed';  import MessageEmbed from '../../client/MessageEmbed';
26  import ms from 'ms';  import ms from 'ms';
27  import { setTimeoutv2 } from '../../utils/setTimeout';  import ScheduleMessageQueue from '../../queues/ScheduleMessageQueue';
28    
29  export default class ScheduleCommand extends BaseCommand {  export default class ScheduleCommand extends BaseCommand {
30      supportsInteractions = true;      supportsInteractions = true;
# Line 61  export default class ScheduleCommand ext Line 61  export default class ScheduleCommand ext
61          }            }  
62    
63          let channel: TextChannel = <TextChannel> msg.channel;          let channel: TextChannel = <TextChannel> msg.channel;
64          let text: string;          let text: string = '';
65                    
66          if (options.isInteraction) {          if (options.isInteraction) {
67              if (options.options.getChannel('channel')) {              if (options.options.getChannel('channel')) {
# Line 92  export default class ScheduleCommand ext Line 92  export default class ScheduleCommand ext
92          }          }
93    
94          try {          try {
95              const timeout = await setTimeoutv2('send', time, msg.guild!.id, `schedule ${time} ${text!} #${channel.name}`, text!, channel.id, msg.guild!.id);              // const timeout = await setTimeoutv2('send', time, msg.guild!.id, `schedule ${time} ${text!} #${channel.name}`, text!, channel.id, msg.guild!.id);
96    
97                const { id } = await client.queueManager.addQueue(ScheduleMessageQueue, {
98                    data: {
99                        guildID: msg.guild!.id,
100                        channelID: msg.channel!.id,
101                        content: text
102                    },
103                    runAt: new Date(Date.now() + time),
104                    guild: msg.guild!.id,
105                });
106    
107              await msg.reply({              await msg.reply({
108                  embeds: [                  embeds: [
109                      new MessageEmbed()                      new MessageEmbed()
110                      .setDescription('A queue job has been added.')                      .setDescription('A queue job has been added.')
111                      .setFooter({                      .setFooter({
112                          text: 'ID: ' + timeout.row.id                          text: 'ID: ' + id // timeout.row.id
113                      })                      })
114                  ],                  ],
115                  ephemeral: true                  ephemeral: true

Legend:
Removed from v.393  
changed lines
  Added in v.444

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26