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