diff --git a/src/components/Automod.ts b/src/components/Automod.ts index 45b5077..c428c9b 100644 --- a/src/components/Automod.ts +++ b/src/components/Automod.ts @@ -4,7 +4,7 @@ import Logger from '../helpers/Logger.js'; export default class Automoderator { private static logPrefix:string = 'Automod'; private static lockQuery:Set = new Set(); - static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|ing\b|ed\b|es\b|er\b|$/g, '').split(' ').join(''); + static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|ing\b|ed\b|es\b|er\b/g, '').split('').join(''); static async repeatedMessages(client:TClient, message:Discord.Message, action:'mute'|'ban'|'softban', thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) { const now = Date.now(); diff --git a/src/models/prohibitedWords.ts b/src/models/prohibitedWords.ts index 10f1969..494ad84 100644 --- a/src/models/prohibitedWords.ts +++ b/src/models/prohibitedWords.ts @@ -1,5 +1,5 @@ import DatabaseServer from '../components/DatabaseServer.js'; -import {Model, DataTypes} from '@sequelize/core'; +import {Model, DataTypes, Op} from '@sequelize/core'; class prohibitedWords extends Model { declare public word: string; @@ -25,7 +25,13 @@ export class ProhibitedWordsSvc { }) this.model.sync(); } - findWord = async(word:string)=>await this.model.findByPk(word); + findWord = async(word:string)=>{ + const words = word.split(' '); + for (const w of words) { + const found = await this.model.findOne({where: {word: {[Op.eq]: w}}}); + if (found) return true; + } + } getAllWords = async()=>await this.model.findAll(); insertWord = async(word:string)=>await this.model.create({word}); removeWord = async(word:string)=>await this.model.destroy({where: {word}})