/[sudobot]/trunk/src/queues/ExpireScheduleMessageQueue.ts
ViewVC logotype

Contents of /trunk/src/queues/ExpireScheduleMessageQueue.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 430 - (show annotations)
Mon Jul 29 17:30:12 2024 UTC (8 months ago) by rakin
File MIME type: application/typescript
File size: 1168 byte(s)
refactor: use new queue handler
1 import { TextChannel } from "discord.js";
2 import { fetchEmoji } from "../utils/Emoji";
3 import Queue from "../utils/structures/Queue";
4 import ExpireMessageQueue from "./ExpireMessageQueue";
5
6 export default class ExpireScheduleMessageQueue extends Queue {
7 async execute({ channelID, guildID, content, expires }: { [key: string]: string }): Promise<any> {
8 const guild = this.client.guilds.cache.get(guildID);
9
10 if (!guild) {
11 return;
12 }
13
14 const channel = guild.channels.cache.get(channelID) as TextChannel;
15
16 if (!channel || !['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'].includes(channel.type)) {
17 return;
18 }
19
20 try {
21 const { id: messageID } = await channel.send({ content });
22
23 await this.client.queueManager.addQueue(ExpireMessageQueue, {
24 data: {
25 messageID,
26 guildID,
27 channelID,
28 },
29 runAt: new Date(Date.now() + expires)
30 });
31 }
32 catch (e) {
33 console.log(e);
34 }
35 }
36 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26