Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

filter - How can I add some bad words as whitelist on JavaScript

The blacklisted words are bad words but the words that appear on whitelisted are really clean words but the bot detects them too as a bad word. How can I solve this?

Thanks in advance.

const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
  console.log('Bot is online!');
});
const prefix = '&';
client.on('message', message => {
  let blacklisted = ['bad words'];
  let whitelisted = ['clean words'];
  let foundInText = false;
  for (var i in blacklisted) {
    
    if(message.content.toLowerCase().includes(blacklisted[i].toLowerCase())) foundInText = true;
  }
    if(foundInText){
      message.delete();
      const embed = new Discord.MessageEmbed()
      .setTitle('W A R N')
      .setDescription(message.author.toString() + ' we don't allow to write this here.')
      .setThumbnail('logo link')
      .setAuthor(client.user.username)
      .setColor('RANDOM')
      .addFields(
        {name: 'Explain' , value: 'explainv2.' + '
' + 'The bad word: ' + '**' + message.toString() + '**'},
        )
        message.channel.send(embed)
          .then(message => message.delete({ timeout: 15000}))
    }
});

client.login('discord bot id');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...