Anti Swear Or Bad Words System For Discord Bot

If you want anyone not to swear or send bad words in your server then you will be needing a anti swear system but if you do not have idea how to start or create this thing then this post will be very helpful for you.

Create a new file with name data.json where will be storing badwords


Now Define the badwords in main file

const { badwords } = require("./data.json") 

Now go to message event and we will make permission statement in it so that owner or moderation can swear words :D, So for that we will check if author have permission or not.

 if(!message.member.hasPermission("ADMINISTRATOR")) {

Now we will let a variable with name confirm and value false, then add for loop and check if message content contains any bad word or not and if contains any bad word then change confirm variable to true.

    let confirm = false;
    var i;
    for(i = 0;i < badwords.length; i++) {
        confirm = true;

Now outside the loop we will check confirm value and if it get true then delete the author message and send warn message by bot.

  if(confirm) {
      return"You are not allowed to send badwords here")

Video Tutorial

Source Code

Here is the resulted code – HERE

Related Posts

Written by Senpai

"This may be a virtual world,but I feel more alive here then in the real world"

Leave a Reply