From 00de6ce70cdbe0cbd4bfeb8a5529d06ba3b75718 Mon Sep 17 00:00:00 2001 From: nin0 Date: Sun, 30 Jun 2024 15:41:22 -0400 Subject: [PATCH] Add index.ts --- index.ts | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 index.ts diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..10a77c7 --- /dev/null +++ b/index.ts @@ -0,0 +1,63 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { addPreSendListener, removePreSendListener } from "@api/MessageEvents"; +import definePlugin from "@utils/types"; + +const badVerbs = ["fuck", " cum", "kill", "destroy"]; +const badNouns = ["cunt", "shit", "bullshit", "ass", "bitch", "nigga", "hell", "whore", "dick", "piss", "pussy", "slut", "tit", " fag", "cum", "cock", "retard", "blowjob", "bastard", "men", "man", "kotlin", "die", "sex", "nigger", "gay", "brainrot", "brainless", "mant", "manti", "mantik", "mantika", "mantikaf", "mantikafa", "mantikafas", "mantikafasi", "boykisser", "mewing", "mew", "skibidi", "gyat", "gyatt", "rizzler", "avast"]; +const badVerbsReplacements = ["love", "eat", "deconstruct", "marry", "fart", "teach", "display", "plug", "explode", "undress", "finish", "freeze", "beat", "free", "brush", "allocate", "date", "melt", "breed", "educate", "injure", "change"]; +const badNounsReplacements = ["pasta", "kebab", "cake", "potato", "woman", "computer", "java", "hamburger", "monster truck", "osu!", "Ukrainian ball in search of gas game", "Anime", "Anime girl", "good", "keyboard", "NVIDIA RTX 3090 Graphics Card", "storm", "queen", "single", "umbrella", "mosque", "physics", "bath", "virus", "bathroom", "mom", "owner", "airport", "Avast Antivirus Free", "<@289556910426816513>"]; + +function replaceBadNouns(content) { + // eslint-disable-next-line quotes + const regex = new RegExp('\\b(' + badNouns.join('|') + ')\\b', 'gi'); + + return content.replace(regex, function (match) { + const randomIndex = Math.floor(Math.random() * badNounsReplacements.length); + return badNounsReplacements[randomIndex]; + }); +} + +function replaceBadVerbs(content) { + // eslint-disable-next-line quotes + const regex = new RegExp('\\b(' + badVerbs.join('|') + ')\\b', 'gi'); + + return content.replace(regex, function (match) { + const randomIndex = Math.floor(Math.random() * badVerbsReplacements.length); + return badVerbsReplacements[randomIndex]; + }); +} + +export default definePlugin({ + name: "GoodPerson", + description: "Makes you a good person", + authors: [Devs.nin0dev], + dependencies: ["MessageEventsAPI"], + + async start() { + this.preSend = addPreSendListener((channelId, msg) => { + const newContent = replaceBadVerbs(replaceBadNouns(msg.content)); + msg.content = newContent; + }); + }, + + stop() { + removePreSendListener(this.preSend); + } +}); \ No newline at end of file