npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-censor

v1.0.9

Published

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

Downloads

7

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:

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?