import { Message } from 'discord.js' ; import { Bot } from '..' ; export enum filterActions { nothing , delete , send } ; export interface export interface filterAction { type { filterActions } memberof type : filterActions ; type { number } memberof delay ? : number ; type { * } memberof message ? : any ; } ; export param { Message } message param { filterAction } action returns export async function executeAction ( message , action ) { try { switch ( action . type ) { case filterActions . nothing : return true ; case filterActions . delete : await message . delete ( action . delay ) ; return true ; case filterActions . send : await message . reply ( action . message ) ; Bot . mStats . logMessageSend ( ) ; return true ; default : console . warn ( 'unknown action:' + action ) ; Bot . mStats . logError ( new Error ( 'unknown action:' + action ) ) ; return false ; } } catch ( e ) { Bot . mStats . logError ( e ) ; return false ; } } export param { Message } message param { filterAction [ ] } actions export function executeActions ( message , actions ) { for ( var i = 0 ; i < actions . length ; i ++ ) { executeAction ( message , actions [ i ] ) ; } }