Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 关键字消息删除事件未触发_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript 关键字消息删除事件未触发

Javascript 关键字消息删除事件未触发,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我试图写一个事件,将删除任何与特定关键字的消息,但它没有做任何事情 client.on(“message”,(message)=>{ if(message.author.bot)返回; if(message.member.roles.some(r=>[“DEAN!”].includes(r.name)))返回; let words=[“破解”、“破解”、“破解”、“修补”、“修补”、“破解”] if(message.content.includes(words)){ message.chann

我试图写一个事件,将删除任何与特定关键字的消息,但它没有做任何事情

client.on(“message”,(message)=>{
if(message.author.bot)返回;
if(message.member.roles.some(r=>[“DEAN!”].includes(r.name)))返回;
let words=[“破解”、“破解”、“破解”、“修补”、“修补”、“破解”]
if(message.content.includes(words)){
message.channel.send(`message.author}你不能说这样的话!`);
message.delete();
log(chalk.bgYellow(“INFO”)+(`message包含${message.author}限制的单词的消息已被删除`);
}

});
数组.prototype.includes
方法不接受数组作为参数。应该使用值对数组调用此方法,并且作为第一个参数-值,您希望知道它是否存在于数组中

若要识别包含禁用关键字的邮件,您应该检查此邮件中的所有关键字。像这样:

函数isMessageContainBannedWord(msg){
const bannedWords=['香蕉','柠檬水']
const words=msg.split(“”)
返回单词。一些((单词)=>横幅单词。包括(单词))
}
log(isMessageContainBannedWord('I like apples'))
log(isMessageContainBannedWord(“我想让你感受我的香蕉力量!”)