Reputation: 79
Let's say someone wants to use my bot in another server. I want to make it so the command only works if you are in my discord server. They can use it in the other server if they are in my discord server. If they are not, I don't want them to be able to use it.
I've tried many things such like if (guild.member(USER_ID)
with no luck.
let guild2 = client.guilds.get('598974868779958282'),
user_id = message.author.id;
if (guild2.member(user_id)) {
message.author.send("you are in the support server!")
}else{
message.author.send("you are not in the support server!")
}
I expected it to return the direct message "you are not in the support server!" because I am not in that guild but it always returns "you are in the support server" even if I'm not in the guild.
Upvotes: 0
Views: 85
Reputation: 1003
let guild2 = client.guilds.get('598974868779958282'),
user_id = message.author.id;
if (guild2.members.has(user_id)) {
message.author.send("you are in the support server!")
}else{
message.author.send("you are not in the support server!")
}
The method guild.member
doesn't exist try guild.members
instead.
Upvotes: 0