From ce0192df395a5a0321a60589db67f283e5de9d6f Mon Sep 17 00:00:00 2001 From: bashamega Date: Wed, 24 Jul 2024 11:11:03 +0300 Subject: [PATCH] fix: remove URLs from content before checking for banned words --- src/alexjs/checkBannedWords.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/alexjs/checkBannedWords.ts b/src/alexjs/checkBannedWords.ts index 6c738a65..d68bffc5 100644 --- a/src/alexjs/checkBannedWords.ts +++ b/src/alexjs/checkBannedWords.ts @@ -12,11 +12,13 @@ export const checkBannedWords = async ( ): Promise => { const embeds: EmbedBuilder[] = []; try { + const urlPattern = /https?:\/\/[^\s]+/g; + const text: string = content.replace(urlPattern, ''); const config = await getBannedWordConfig(bot, serverId); const checkWords = config?.bannedWordConfig ? config.bannedWordConfig : BannedWordsOptions; - content.split(' ').forEach((word) => { + text.split(' ').forEach((word) => { if (checkWords.includes(word.toLowerCase())) { const embed = new EmbedBuilder(); embed.setTitle(`You used the word "${word}"`);