Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/theramann/discord-censor

Use this npm package to censor member's messages and keep your discord server friendly for all ages
https://github.com/theramann/discord-censor

bot censor censorify discord family friendly members node nodejs npm npm-package npmjs server

Last synced: about 20 hours ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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

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

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

```js
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

```js
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

```js
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

```js
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

```js
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

```js
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