From 1547512a1c7a809ca19aabf82dc70183267d3dce Mon Sep 17 00:00:00 2001 From: janderedev Date: Sun, 16 Jan 2022 16:34:30 +0100 Subject: [PATCH] allow custom rules on message update --- src/bot/modules/command_handler.ts | 4 ++++ src/bot/modules/custom_rules/custom_rules.ts | 1 + src/struct/antispam/CustomRuleTrigger.ts | 1 - 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bot/modules/command_handler.ts b/src/bot/modules/command_handler.ts index 1ff387e..9c4a5f8 100644 --- a/src/bot/modules/command_handler.ts +++ b/src/bot/modules/command_handler.ts @@ -31,6 +31,10 @@ let commands: Command[]; .map(async file => await import(path.join(dirname, '..', 'commands', file)) as Command) )).map(c => (c as any).default) + client.on('message/update', async msg => { + checkCustomRules(msg, true); + }); + client.on('message', async msg => { logger.debug(`Message -> ${msg.content}`); diff --git a/src/bot/modules/custom_rules/custom_rules.ts b/src/bot/modules/custom_rules/custom_rules.ts index f004078..b39aaad 100644 --- a/src/bot/modules/custom_rules/custom_rules.ts +++ b/src/bot/modules/custom_rules/custom_rules.ts @@ -16,6 +16,7 @@ async function checkCustomRules(message: Message, isEdit: boolean = false) { if (!rules) return; for (let rule of rules) { + if (!rule?.trigger?.on) continue; let onEdit = rule.trigger.on.includes('message/update'); let onNew = rule.trigger.on.includes('message/create'); diff --git a/src/struct/antispam/CustomRuleTrigger.ts b/src/struct/antispam/CustomRuleTrigger.ts index 6e84e4f..a245c6d 100644 --- a/src/struct/antispam/CustomRuleTrigger.ts +++ b/src/struct/antispam/CustomRuleTrigger.ts @@ -2,7 +2,6 @@ class CustomRuleTrigger { _id: string; // Which events this rule should apply to - // todo: message/update is not implemented on: ('message/create' | 'message/update')[]; // Regex or string to match the content of the message against. If omitted, rule applies to every message