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 |
|
|
} |