Skip to content
This repository was archived by the owner on Oct 10, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/alexjs/checkBannedWords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,11 +13,13 @@ export const checkBannedWords = async (
): Promise<EmbedBuilder[]> => {
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}"`);
Expand Down
2 changes: 2 additions & 0 deletions src/config/UrlRegex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const urlPattern =
/[Hh][Tt][Tt][Pp][Ss]?:\/\/([\w-]+(\.[\w-]+)+)(\/[\w-./?%&=]*)?/g;
3 changes: 1 addition & 2 deletions src/links/checkLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down