From c6d7f8e04c953a3d5cef35238d3d8dd4665dbbc7 Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Mon, 1 Apr 2024 23:09:23 +1100 Subject: [PATCH] Fucking hell, stop breaking yourself, you piece of shit. --- src/components/Automod.ts | 2 +- src/models/prohibitedWords.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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}})