I want to check if a member is or not in a server.
This is my current code:
function CheckIfManagerIsInServer(client, server_id, member) {
let isIn = { isIn: true, isNotIn: [] };
if (CheckIfIsInChain(server_id)) {
database.chains.forEach(chain => {
if(chain.membersID.includes(server_id)) {
chain.members.forEach(server => {
const guild = client.guilds.cache.get(server)
// check if member is in the server
})
}
})
}
return isIn;
}
member
parameter is the id of the member.
How i can check if the member is or not in the server ( guild
)? I'm using v13.5.0.
My bot is verified and it has GUILD_MEMBERS
enabled.
I have tried multiple methods but they doesn't works.
How I can do?
Thank you in advance and sorry for bad english!
For checking that you can do like this
if (guild.members.cache.find(m => m.id === member)?.id) {
// true
} else {
// false
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.