diff --git a/src/alexjs/checkBannedWords.ts b/src/alexjs/checkBannedWords.ts index 6c738a65..a88bfaae 100644 --- a/src/alexjs/checkBannedWords.ts +++ b/src/alexjs/checkBannedWords.ts @@ -4,6 +4,7 @@ import type { ExtendedClient } from '../interfaces/ExtendedClient.js'; import { errorHandler } from '../utils/errorHandler.js'; import { BannedWordsOptions } from '../config/BannedWordsOptions.js'; import { getBannedWordConfig } from '../utils/getBannedWordConfig.js'; +import { urlPattern } from '../config/UrlRegex.js'; export const checkBannedWords = async ( bot: ExtendedClient, @@ -12,11 +13,13 @@ export const checkBannedWords = async ( ): Promise => { const embeds: EmbedBuilder[] = []; try { + 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}"`); diff --git a/src/config/UrlRegex.ts b/src/config/UrlRegex.ts new file mode 100644 index 00000000..97c04615 --- /dev/null +++ b/src/config/UrlRegex.ts @@ -0,0 +1,2 @@ +export const urlPattern = + /[Hh][Tt][Tt][Pp][Ss]?:\/\/([\w-]+(\.[\w-]+)+)(\/[\w-./?%&=]*)?/g; diff --git a/src/links/checkLinks.ts b/src/links/checkLinks.ts index ab3ab8ba..b9845075 100644 --- a/src/links/checkLinks.ts +++ b/src/links/checkLinks.ts @@ -2,10 +2,9 @@ import { EmbedBuilder, Message, type PartialMessage } from 'discord.js'; import type { ExtendedClient } from '../interfaces/ExtendedClient.js'; import { errorHandler } from '../utils/errorHandler.js'; +import { urlPattern } from '../config/UrlRegex.js'; const allowedLinks = ['github.com', 'eddiejaoude.io', 'gitlab.com']; -const urlPattern = - /[Hh][Tt][Tt][Pp][Ss]?:\/\/([\w-]+(\.[\w-]+)+)(\/[\w-./?%&=]*)?/g; export const checkLinks = async ( bot: ExtendedClient,