1.0.8 • Published 1 year ago

chat-censoring v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

A tiny & simple package for your chat application that allows you to remove or censor bad words in chat.

Installation

npm:

npm i chat-censoring

Features

  • Check, if a message includes bad words
  • Check and censor (if needed) a message

Check message

This function takes your message as argument and checks, if it includes a bad word. As result it returns either true or false.

Parameters:

ParameterUsage
messageThe message you want to check

Example:

const censoring = require('chat-censoring');

const isInsult = censoring.check('You are great!');
console.log(isInsult); // Prints false
const censoring = require('chat-censoring');

const isInsult = censoring.check('You are fucking stupid!');
console.log(isInsult); // Prints true

Censor message

This function checks if there is a bad word in your provided message and replaces this word(s) with the character of your choise.

Parameter:

ParameterUsage
messageThe message you want to check and censor if needed
censoringCharThe char you want to use to censor bad words

Example:

const censoring = require('chat-censoring');

const friendlyMessage = censoring.censorMessage('This is fucking cool!', '*');
console.log(friendlyMessage); // Prints 'This is ******* cool!'

Discord.js example

This package was created with the motivation to censor chat messages in Discord. Of course it can be used in other applications as well

Here is an example how you can use it for your Discord bot:

if(message.author.bot) return;

	if(!content.startsWith(prefix)) {

		if(censor.checkMessage(content)) {
			message.delete()
				.then(() => message.channel.send(`${message.author} said: ${censor.censorMessage(content, '#')}`))
				.catch(err => {
					console.log('An error occurred while censoring a message: ' + err);
					return message.channel.send('Unfortunately an error has occurred :(');
				});
		}
		return;
	}
1.0.8

1 year ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago