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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 430 - (show annotations)
Mon Jul 29 17:30:12 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 808 byte(s)
refactor: use new queue handler
1 import { TextChannel } from "discord.js";
2 import Queue from "../utils/structures/Queue";
3
4 export default class ExpireMessageQueue extends Queue {
5 async execute({ messageID, channelID, guildID }: { [key: string]: string }): Promise<any> {
6 const guild = this.client.guilds.cache.get(guildID);
7
8 if (!guild) {
9 return;
10 }
11
12 const channel = guild.channels.cache.get(channelID) as TextChannel;
13
14 if (!channel || !['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'].includes(channel.type)) {
15 return;
16 }
17
18 try {
19 const message = await channel.messages.fetch(messageID);
20 await message?.delete();
21 }
22 catch (e) {
23 console.log(e);
24 }
25 }
26 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26