/[sudobot]/branches/2.x/src/events/guildBan/GuildBanAddEvent.ts
ViewVC logotype

Contents of /branches/2.x/src/events/guildBan/GuildBanAddEvent.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 973 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import BaseEvent from '../../utils/structures/BaseEvent';
2 import DiscordClient from '../../client/Client';
3 import { GuildBan } from 'discord.js';
4 import Punishment from '../../models/Punishment';
5 import PunishmentType from '../../types/PunishmentType';
6
7 export default class GuildBanAddEvent extends BaseEvent {
8 constructor() {
9 super('guildBanAdd');
10 }
11
12 async run(client: DiscordClient, ban: GuildBan) {
13 await client.logger.logBanned(ban);
14
15 const logs = (await ban.guild.fetchAuditLogs({
16 limit: 1,
17 type: 'MEMBER_BAN_ADD',
18 })).entries.first();
19
20 console.log(logs?.executor);
21
22 await Punishment.create({
23 type: PunishmentType.BAN,
24 user_id: ban.user.id,
25 guild_id: ban.guild!.id,
26 mod_id: logs?.executor?.id ?? client.user!.id,
27 mod_tag: logs?.executor?.tag ?? 'Unknown',
28 reason: ban.reason ?? undefined
29 });
30 }
31 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26