Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.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
Node.js Discord.js Discord API错误未知消息_Node.js_Discord_Discord.js - Fatal编程技术网

Node.js Discord.js Discord API错误未知消息

Node.js Discord.js Discord API错误未知消息,node.js,discord,discord.js,Node.js,Discord,Discord.js,我使用Discord.jsv12.0.2,我尝试阻止Discord邀请链接, 我使用这个代码 client.on('message', (message) => { if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) { message.delete() .then(message.channel.send('**Invite links are not permitted

我使用Discord.jsv12.0.2,我尝试阻止Discord邀请链接, 我使用这个代码

client.on('message', (message) => { 
  if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) { 
    message.delete()
      .then(message.channel.send('**Invite links are not permitted on this server**'))
  }
})
我得到了这个错误

DiscordAPIError: Unknown Message

有人能帮我吗?

我不熟悉discord API,但您的代码中有一个严重的错误,可能会导致错误

问题是

'discord.gg/'| |'discordapp.com/invite/'
等于
true
。因为非空字符串是真实值,并且具有
true | | true
会导致
true
。如果将代码重构为以下内容,会产生什么结果:

client.on('message',(message)=>{
const content=message.content;
if(content.includes('discord.gg/')| | content.includes('discordapp.com/invite/')){
消息
1.删除()
.then(message.channel.send('**此服务器上不允许使用邀请链接**'))
}
})

不幸的是,还是同样的错误