/[sudobot]/branches/5.x/src/events/message/MessageDeleteBulkEvent.ts
ViewVC logotype

Annotation of /branches/5.x/src/events/message/MessageDeleteBulkEvent.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1427 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 import {
2     AuditLogEvent,
3     ClientEvents,
4     Collection,
5     GuildTextBasedChannel,
6     Message,
7     PartialMessage,
8     Snowflake,
9     TextChannel
10     } from "discord.js";
11     import Event from "../../core/Event";
12     import { logError } from "../../utils/logger";
13    
14     export default class MessageDeleteBulkEvent extends Event {
15     public readonly name: keyof ClientEvents = "messageDeleteBulk";
16    
17     async execute(messages: Collection<Snowflake, Message | PartialMessage>, channel: GuildTextBasedChannel) {
18     setTimeout(async () => {
19     try {
20     const auditLog = (
21     await channel.guild.fetchAuditLogs({
22     limit: 1,
23     type: AuditLogEvent.MessageBulkDelete
24     })
25     ).entries.first();
26    
27     if (auditLog?.executor?.id && auditLog.executor.id !== this.client.user?.id) {
28     await this.client.infractionManager.bulkDeleteMessages({
29     logOnly: true,
30     sendLog: true,
31     guild: channel.guild,
32     moderator: auditLog.executor,
33     messageChannel: channel as TextChannel,
34     messagesToDelete: [...messages.values()] as Message[]
35     });
36     }
37     } catch (e) {
38     logError(e);
39     }
40     }, 2000);
41     }
42     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26