Skip to content

Use this npm package to censor member's messages and keep your discord server friendly for all ages

License

Notifications You must be signed in to change notification settings

TheRamann/Discord-Censor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Discord-Censor

People curse too much in your discord server?
Use this npm package to censor their messages and keep your discord server friendly for all ages (unless you wanted to ....)

Installation πŸ–₯

npm:

npm i discord-censor

yarn:

yarn add discord-censor

Features 😌

The package has total 3 features (just click on any of them to know more)

πŸ’œ Β  A function to check for those words in messages (check)
πŸ’œ Β  A function to replace bad words from messages (censor)
πŸ’œ Β  An array for bad words (badwords)

This package is tailored to be used with discord.js

Usage ✏

Check

It is a very handy function and returns value as true or false
To understand it better, see the code example below

const censor = require('discord-censor');

const CurseOrNot = censor.check("Is it a curse?")
console.log(CurseOrNot) //Prints False
const censor = require('discord-censor');

const CurseOrNot = censor.check("Is it a fuckin curse?")
console.log(CurseOrNot) //Prints true

Censor

This function will check for curses and replaces them by itself
It has two parameters

const censor = require('discord-censor');

censor.censor('The string you want to censor', 'censored word will be replaced by this (This parameter is optional)')

For more information, let's see the example code below

const censor = require('discord-censor');

const censored = censor.censor('I am fuckin cursing right now')
console.log(censored) //prints "I am f***in cursing right now"

Or if you want to completely remove the word, you can use 2nd parameter of this function

const censor = require('discord-censor');

const censored = censor.censor('I am fuckin cursing right now', '**curse**')
console.log(censored) //prints "I am **curse** cursing right now"

Badwords (array)

You might want to interact with the badwords array to change it's content if needed.
By default, it has 500 about bad words stored in it
To interact with the array, see the code example below

const censor = require('discord-censor');

console.log(censor.badwords) //prints all the badwords in the array

const index = censor.badwords.indexOf('Word'); // Replace word with any word you would like to remove from array
censor.badwords.splice(index, 1); //Removes 'Word' from array

Usage in Discord.Js ✏

Just combine the codes above and use the module in your discord bot.
For more information, let's see the example code below

const censor = require('discord-censor');

const Discord = require('discord.js');
const client = new Discord.Client();

client.once('ready', () => {
	console.log('Ready!');
});
client.on('message', message => {
    if(censor.check(message.content) == true){				      //Check if message has curses or not
        const censored = censor.censor(message.content)   	             //Censor the message if they have curses
        message.channel.send(`${message.author.username} said ${censored}`) //Send the censored version of message
        message.delete()						   //Delete the original of message version which has curses
    }                           					  //That's all you have to do to censor messages in discord πŸ’œ
});

client.login('your-token-goes-here');

Like the package? ✏

Support the creator here

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •