2024-06-30 15:41:22 -04:00
/ *
* Vencord , a modification for Discord ' s desktop app
2024-06-30 15:51:24 -04:00
* Copyright ( c ) 2024 nin0dev
2024-06-30 15:41:22 -04:00
*
* 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 < https : //www.gnu.org/licenses/>.
* /
import { addPreSendListener , removePreSendListener } from "@api/MessageEvents" ;
import definePlugin from "@utils/types" ;
2024-06-30 15:51:24 -04:00
import { Devs } from "@utils/constants" ;
2024-06-30 15:41:22 -04:00
2024-08-31 15:28:00 -04:00
const badVerbs = [ "fuck" , " cum" , "kill" , "destroy" , "orgasm" , "orgasming" ] ;
const badNouns = [ "fag" , "fucking" , "dickhead" , "motherfucker" , "sigma" , "asshole" , "cunt" , "shit" , "bullshit" , "ass" , "bitch" , "nigga" , "hell" , "whore" , "dick" , "piss" , "pussy" , "slut" , "tit" , "cum" , "cock" , "retard" , "blowjob" , "bastard" , "kotlin" , "die" , "sex" , "nigger" , "brainless" , "mant" , "mew" , "skibidi" , "gyat" , "rizzler" , "avast" , "yuri" , "faggot" ] ;
const badVerbsReplacements = [ "move" , "draw" , "deconstruct" , "fly" , "fart" , "teach" , "display" , "plug" , "explode" , "run" , "walk" , "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" , "cheese" , "wheat" , "good" , "keyboard" , "NVIDIA RTX 3090 Graphics Card" , "storm" , "queen" , "single" , "umbrella" , "mosque" , "physics" , "desk" , "virus" , "bathroom" , "corn" , "owner" , "airport" , "Avast Antivirus Free" ] ;
2024-06-30 15:41:22 -04:00
2024-08-31 15:28:00 -04:00
function replaceBadNouns ( content : string ) : string {
const regex = new RegExp ( '\\b(' + badNouns . join ( '|' ) + ')(s)?\\b' , 'gi' ) ;
2024-06-30 15:41:22 -04:00
2024-08-31 15:28:00 -04:00
return content . replace ( regex , function ( match , p1 , p2 ) {
2024-06-30 15:41:22 -04:00
const randomIndex = Math . floor ( Math . random ( ) * badNounsReplacements . length ) ;
2024-08-31 15:28:00 -04:00
let replacement = badNounsReplacements [ randomIndex ] ;
if ( p2 ) {
replacement += 's' ; // Keep the plural 's' if the match was plural
}
return replacement ;
2024-06-30 15:41:22 -04:00
} ) ;
}
2024-08-31 15:28:00 -04:00
function replaceBadVerbs ( content : string ) : string {
const regex = new RegExp ( '\\b(' + badVerbs . join ( '|' ) + ')(s)?\\b' , 'gi' ) ;
2024-06-30 15:41:22 -04:00
2024-08-31 15:28:00 -04:00
return content . replace ( regex , function ( match , p1 , p2 ) {
2024-06-30 15:41:22 -04:00
const randomIndex = Math . floor ( Math . random ( ) * badVerbsReplacements . length ) ;
2024-08-31 15:28:00 -04:00
let replacement = badVerbsReplacements [ randomIndex ] ;
if ( p2 ) {
replacement += 's' ; // Keep the plural 's' if the match was plural
}
return replacement ;
2024-06-30 15:41:22 -04:00
} ) ;
}
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 ) ;
}
2024-08-31 15:28:00 -04:00
} ) ;