简体   繁体   English

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

[英]How do I make a command to reply to a certain user ID?

I'm setting up a whitelist and I want to use discord user IDs to use as a whitelist.我正在设置白名单,我想使用不和谐的用户 ID 作为白名单。 I'm wondering if there is a way to make a command only work for certain user IDs?我想知道是否有办法让命令只对某些用户 ID 有效?

I've tried many different methods from my own knowledge and other help forums with no luck.我已经根据自己的知识和其他帮助论坛尝试了许多不同的方法,但都没有成功。

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

I wanted the user ID 212277222248022016 to get a dm saying "Whitelisted" but I always end up getting the dm "Not whitelisted".我希望用户 ID 212277222248022016得到一个 dm 说“列入白名单”,但我总是最终得到 dm“未列入白名单”。


I figured out the fix for this issue in case anyone comes across this thread and wants to know:我想出了解决此问题的方法,以防万一有人遇到此线程并想知道:

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

Remove the ! 删除!

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

Your number is too large to be 'held' correctly: 您的电话号码太大,无法正确“保留”:

console.log(212277222248022016); console.log(212277222248022016); --> 212277222248022000 -> 212277222248022000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM