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; |
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')) { |
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 |