Javascript 如何发出命令来回复某个用户ID?

Javascript 如何发出命令来回复某个用户ID?,javascript,discord,discord.js,Javascript,Discord,Discord.js,我正在设置一个白名单,我想使用discord用户ID作为白名单。我想知道是否有一种方法可以使命令只对某些用户ID有效 我尝试了许多不同的方法,从我自己的知识和其他帮助论坛没有运气 const userId = message.guild.members.find(m => m.id === "212277222248022016"); if(!message.author === userId) { message.author.send("Whitelisted") }else{

我正在设置一个白名单,我想使用discord用户ID作为白名单。我想知道是否有一种方法可以使命令只对某些用户ID有效

我尝试了许多不同的方法,从我自己的知识和其他帮助论坛没有运气

const userId = message.guild.members.find(m => m.id === "212277222248022016");
if(!message.author === userId) {
    message.author.send("Whitelisted")
}else{
    message.author.send("Not whitelisted")
}
我想让用户ID
21227722248020016
得到一个dm,上面写着“白名单”,但我总是得到dm“未白名单”


我找到了解决此问题的方法,以防有人遇到此线程并想知道:

const userId = client.users.get("id here");
if (message.author === userId) {
    message.author.send("Whitelisted")
} else {
    message.author.send("Not whitelisted")
}

删除

const userId = message.guild.members.find(m => m.id === "212277222248022016");
if (message.author === userId) {
message.author.send("Whitelisted")
} else {
message.author.send("Not whitelisted")
}

试着去掉“!”把它去掉!在if语句中删除!没有修复它。与其编辑问题以包含解决方案,不如发布答案(这完全可以)。您将能够在两天内接受它,但不会因此获得声誉。这并没有解决它-我仍然得到“未列入白名单”的DM.console.log(message.author)和console.log(userId);你看到了什么?它们都显示了关于我的个人资料的信息——甚至console.log(userId)
userId
都是一个<代码>消息。作者是一位。因此,这两个对象并不相等。