file description import type { Guild , Member , Message , TextChannel } from "eris" ; import { PrivateChannel } from "eris" ; import { Event } from "../classes/Event" ; import { automodAntiInvite } from "./automod/antiInvite" ; import { automodAntiNewLine } from "./automod/antiNewLines" ; import { automodAntiRaid } from "./automod/antiRaid" ; import { automodAntiSpam } from "./automod/antiSpam" ; import { automodAntiMassMention } from "./automod/antiMassMention" ; export class AutomodEvent extends Event { events = [ "messageCreate" , "guildMemberAdd" ] ; async run ( event , msg , member ) { switch ( event ) { case "messageCreate" : { if ( ! msg || ! msg . channel || msg ?. channel instanceof PrivateChannel || msg ?. author ?. bot ) return ; let member = msg . member ; if ( ! member ?. roles ) { member = await msg . channel . guild . fetchMembers ( { userIDs : [ msg . author . id ] } ) [ 0 ] ; } const guildconfig = await this . bot . db . getGuildConfig ( msg . channel . guild . id ) ; if ( ! guildconfig ) return ; if ( ( member ?. roles && member . roles ?. includes ?. ( guildconfig ?. staffRole ) ) || member ?. permissions ?. has ( "administrator" ) || member ?. permissions ?. has ( "manageGuild" ) || member ?. permissions ?. has ( "manageMessages" ) ) return ; if ( guildconfig . antiSpam ) await automodAntiSpam ( msg , this . bot , guildconfig ) ; if ( guildconfig . antiInvite ) await automodAntiInvite ( msg , this . bot , guildconfig ) ; if ( guildconfig . antiNewLines ) await automodAntiNewLine ( msg , this . bot , guildconfig ) ; if ( guildconfig . antiMassMention ) await automodAntiMassMention ( msg , this . bot , guildconfig ) ; break ; } case "guildMemberAdd" : { const guild = ( msg as unknown ) as Guild ; const guildconfig = await this . bot . db . getGuildConfig ( guild . id ) ; if ( ! guildconfig ) return ; if ( guildconfig ?. antiRaid && guildconfig ?. raidPunishments ) await automodAntiRaid ( guild , member , this . bot , guildconfig ) ; break ; } } } }