#Censor failing to detect words containing regex symbols

1 messages · Page 1 of 1 (latest)

quiet swan

I have a censor event that pulls the list of banned words, which may be preceded and/or followed by an * to mimic the Discord censor behavior. However, while I am escaping regex symbols before testing the word, my censor is failing to pick up words that contain regex symbols, and I can't for the life of me figure out why.

        // Fetch all banned words from the database for the current server
        const bannedWords = await Database.BannedWord.findAll({
            include: [{
                model: Database.Server,
                where: { ServerId: message.guild.id }
            }]
        });

        // Check if the message includes any banned word
        for (const bannedWord of bannedWords) {
            let word = bannedWord.Word;
            let regex;