首页 > 解决方案 > Nodejs如何将多个id放入if

问题描述

当我尝试将多个 id 放入一个 if 它只注册第一个时。

if (message.author.id != '196568585202565121' || '110324497353052160') return message.reply("You don't have the perms")

它只会回复第一个 id 而不是第二个。第二个会得到你没有烫发的消息。

标签: javascriptnode.jsdiscord

解决方案


您可以将数组与.includes()方法一起使用。

if(!['196568585202565121','110324497353052160'].includes(message.author.id)) {
  // to the things...
}

阅读更多:Array.prototype.includes()


推荐阅读