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({