file description import type { Guild , Invite } from "eris" ; import { Event } from "../classes/Event" ; export class InviteUpdateEvent extends Event { events = [ "inviteCreate" , "inviteDelete" ] ; async run ( event , guild , invite ) { if ( ! guild || ! invite || this . bot . config . inviteLogs === false ) return ; const guildconfig = await this . bot . db . getGuildConfig ( guild . id ) ; if ( guildconfig ?. inviteOptOut === true ) return ; if ( ! this . bot . inviteHandler . inviteCache [ guild . id ] ?. length ) { this . bot . inviteHandler . inviteCache [ guild . id ] = [ ] ; } /**
         * Adds new invites on creation
         */ switch ( event ) { case "inviteCreate" : { this . bot . inviteHandler . inviteCache [ guild . id ] . push ( invite ) ; break ; } case "inviteDelete" : { const deletedInvite = this . bot . inviteHandler . inviteCache [ guild . id ] . find ( ( i ) => i . code === invite . code ) ; const index = this . bot . inviteHandler . inviteCache [ guild . id ] . indexOf ( deletedInvite ) ; if ( deletedInvite ) { this . bot . inviteHandler . inviteCache [ guild . id ] . splice ( index , 1 ) ; } } } } }