Remove bad banned words implementation
This commit is contained in:
@@ -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" },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
};
|
||||
@@ -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";
|
||||
Reference in New Issue
Block a user