diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/entities/Member.ts | 6 | ||||
-rw-r--r-- | src/util/entities/User.ts | 7 | ||||
-rw-r--r-- | src/util/util/BannedWords.ts | 30 | ||||
-rw-r--r-- | src/util/util/index.ts | 3 |
4 files changed, 2 insertions, 44 deletions
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 34089af2..d0d57b26 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -15,7 +15,7 @@ import { RelationId, } from "typeorm"; import { Guild } from "./Guild"; -import { Config, emitEvent, BannedWords, FieldErrors } from "../util"; +import { Config, emitEvent, FieldErrors } from "../util"; import { GuildCreateEvent, GuildDeleteEvent, @@ -126,10 +126,6 @@ export class Member extends BaseClassWithoutId { if (this.nick) { this.nick = this.nick.split("\n").join(""); this.nick = this.nick.split("\t").join(""); - if (BannedWords.find(this.nick)) - throw FieldErrors({ - nick: { message: "Bad nickname", code: "INVALID_NICKNAME" }, - }); } } diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index 585bd725..7790856a 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -16,7 +16,6 @@ import { FieldErrors, Snowflake, trimSpecial, - BannedWords, adjustEmail, } from ".."; import { Member, Session } from "."; @@ -242,12 +241,6 @@ export class User extends BaseClass { }); this.discriminator = discrim.toString().padStart(4, "0"); } - - if (/*!update ||*/ this.username) - if (BannedWords.find(this.username)) - throw FieldErrors({ - username: { message: "Bad username", code: "INVALID_USERNAME" }, - }); } toPublicUser() { diff --git a/src/util/util/BannedWords.ts b/src/util/util/BannedWords.ts deleted file mode 100644 index 28b03546..00000000 --- a/src/util/util/BannedWords.ts +++ /dev/null @@ -1,30 +0,0 @@ -import fs from "fs/promises"; -import path from "path"; -import { InvisibleCharacters } from "./InvisibleCharacters"; - -var words: string[]; - -export const BannedWords = { - init: async function init() { - if (words) return words; - const file = ( - await fs.readFile(path.join(process.cwd(), "bannedWords")) - ).toString(); - if (!file) { - words = []; - return []; - } - words = file.trim().split("\r").join("").split("\n"); - return words; - }, - - get: () => words, - - find: (val: string) => { - InvisibleCharacters.forEach(x => val = val.replaceAll(x, "")); - var normal = words.some((x) => val.indexOf(x) != -1); - val = val.split("").reverse().join(""); - var rtlOverride = words.some((x) => val.indexOf(x) != -1); - return normal || rtlOverride; - }, -}; diff --git a/src/util/util/index.ts b/src/util/util/index.ts index aa38e472..f7a273cb 100644 --- a/src/util/util/index.ts +++ b/src/util/util/index.ts @@ -19,5 +19,4 @@ export * from "./Snowflake"; export * from "./String"; export * from "./Array"; export * from "./TraverseDirectory"; -export * from "./InvisibleCharacters"; -export * from "./BannedWords"; +export * from "./InvisibleCharacters"; \ No newline at end of file |