file description module import type { Guild , Message , TextChannel } from "eris" ; import type { HibikiClient } from "../../classes/Client" ; import { Member } from "eris" ; import { generateSnowflake } from "../../utils/snowflake" ; export const punishMute = async ( msg , bot , cfg , reason , g = undefined ) => { const member = msg instanceof Member ? msg : msg . member ; const guild = msg instanceof Member ? g : msg . channel . guild ; if ( member ?. roles ?. includes ?. ( cfg . mutedRole ) ) return ; const roles = [ ] ; member . roles . forEach ( async ( role ) => { roles . push ( role ) ; await guild . removeMemberRole ( member . id , role , "Automod" ) . catch ( ( ) => { } ) ; } ) ; await bot . db . insertMuteCache ( { roles : roles , member : member . id , guild : guild . id } ) ; await member . addRole ( cfg . mutedRole , "Automod" ) . catch ( ( ) => { } ) ; if ( reason ) bot . emit ( "automodMemberMute" , guild , member . user , undefined , reason ) ; } ; export const punishPurge = async ( msg , msgs ) => { if ( Array . isArray ( msgs ) ) msg . channel . deleteMessages ( msgs ) . catch ( ( ) => { } ) ; else msg . channel . deleteMessage ( msgs ) . catch ( ( ) => { } ) ; } ; export const punishWarn = async ( msg , bot , reason ) => { const id = generateSnowflake ( ) ; await bot . db . insertUserWarning ( { giver : bot . user . id , receiver : msg . author . id , guild : msg . channel . guild . id , id : id , reason : reason || "Automod" , } ) ; return id ; } ;