From dd41baad97f0d05ac552e130a3c8a523a76c0885 Mon Sep 17 00:00:00 2001 From: Ali Hammoud Date: Mon, 10 Nov 2025 17:33:09 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20adjust=20message=20lookba?= =?UTF-8?q?ck=20timeframe=20for=20spam=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/spam-detection/rules.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/events/spam-detection/rules.ts b/src/events/spam-detection/rules.ts index a14ae10..3e7fedf 100644 --- a/src/events/spam-detection/rules.ts +++ b/src/events/spam-detection/rules.ts @@ -13,8 +13,9 @@ type CheckRuleOptions = { }; export async function checkRules(newMessage: Message): Promise { - const startTime = Date.now() - MAX_RULE_TIMEFRAME * 1.5; // Slightly extend timeframe to ensure we catch all relevant messages; - const userMessages = cachedMessages.getMessagesInTimeRange(newMessage.author.id, startTime); + const startTime = Date.now(); + const maxLookback = startTime - MAX_RULE_TIMEFRAME * 1.5; + const userMessages = cachedMessages.getMessagesInTimeRange(newMessage.author.id, maxLookback); for (const rule of rules) { const result = checkRule({