import { Role , GuildMember , GuildAuditLogs , GuildAuditLogsEntry } from "discord.js" ; import { AntiRaid } from "../../Antiraid" ; import { Cooldown , AntiRaidEvent } from "../../interfaces" ; export const roleDelete = { name : "roleDelete" , run : async ( client , role ) => { let exempt = false , check = false ; const event = "roleCreate" , startAt = Date . now ( ) ; try { role . guild . fetchAuditLogs ( { type : client . actionType [ "roleDelete" ] . id , limit : 10 } ) . then ( ( audit ) => audit . entries . first ( ) ) . then ( async ( entry ) => { if ( role . id !== entry . target . id ) return undefined ; const member = role . guild . members . cache . get ( entry . executor . id ) , caseToCheck = await client . search ( member , event ) ; exempt = await client . checkExempt ( member , event ) ; if ( ! exempt ) { check = await client . punishable ( member , caseToCheck ) ; if ( check ) { return client . punish ( member ) ; } } await client . addCaseToCooldown ( member , event , caseToCheck , startAt ) ; } ) ; } catch ( e ) { console . error ( e ) ; } } } ;