Skip to content
This repository was archived by the owner on Oct 10, 2024. It is now read-only.
Merged
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/alexjs/checkBannedWords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export const checkBannedWords = async (
): Promise<EmbedBuilder[]> => {
const embeds: EmbedBuilder[] = [];
try {
const urlPattern = /https?:\/\/[^\s]+/g;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the existing link regex check from the other file? Maybe move to the config?

const urlPattern =
/[Hh][Tt][Tt][Pp][Ss]?:\/\/([\w-]+(\.[\w-]+)+)(\/[\w-./?%&=]*)?/g;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving it to a reusable config, so we don't have duplication? urlRegex.js

https://github.com/EddieHubCommunity/EddieBot/tree/9fc6b257c48b594fb3a48b421cccfabbef6a7a08/src/config

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