Discord.js如何让我的机器人阅读被禁词的整个句子?

时间:2020-07-28 21:14:02

标签: javascript node.js discord.js

我是编码的新手,我只是想不通如何使我的不和谐机器人阅读人们不和谐编写的句子并扫描被禁止的单词。基本上,我需要它来删除带有禁止词的邮件。到目前为止,这是我的代码。感谢您抽出宝贵的时间阅读本文!

//Banned words


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

1 个答案:

答案 0 :(得分:0)

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.`)};
});