简体   繁体   中英

Discord.js How do I make my bot read an entire sentence for banned words?

I am new to coding and I just can not figure out how to make my discord bot read sentences that people write in discord and scan for banned words. Basically I need it to delete messages with banned words. Here is my code so far for it. Thank you for taking the time to read this!

//Banned words


var badwords = ("swearword1", "swearword2")
badwords.search(bot.on('message', message => {
    switch(message.content.toLowerCase()) {
        case badwords:
            message.delete()
    }
}));
const BannedWords = ["swearword1", "swearword2"]

client.on("message", message => {
    if (BannedWords.some(word => message.toString().toLowerCase().includes(word))) {message.delete().catch(e => console.error("Couldn't delete message.")); message.reply(`Please do not swear.`)};
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM