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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26