From b504edae92542003a4137c1ecaab8a9a66b995cb Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sun, 11 Sep 2022 23:19:55 +1000 Subject: Primitive banned words blocking --- util/src/entities/Message.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'util/src/entities/Message.ts') diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts index 38242152..78888e17 100644 --- a/util/src/entities/Message.ts +++ b/util/src/entities/Message.ts @@ -8,7 +8,6 @@ import { Column, CreateDateColumn, Entity, - FindConditions, Index, JoinColumn, JoinTable, @@ -16,14 +15,14 @@ import { ManyToOne, OneToMany, RelationId, - RemoveOptions, - UpdateDateColumn, } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { Webhook } from "./Webhook"; import { Sticker } from "./Sticker"; import { Attachment } from "./Attachment"; +import { BannedWords } from "../util"; +import { HTTPError } from "lambert-server"; export enum MessageType { DEFAULT = 0, @@ -117,6 +116,11 @@ export class Message extends BaseClass { @Column({ nullable: true, type: process.env.PRODUCTION ? "longtext" : undefined }) content?: string; + setContent(val: string) { + if (BannedWords.find(val)) throw new HTTPError("Message was blocked by automatic moderation", 200000); + this.content = val; + } + @Column() @CreateDateColumn() timestamp: Date; -- cgit 1.5.1