Skip to content Skip to sidebar Skip to footer

Check If An User Is In A Specific Guild Discord.js

I don't know if it's possible, but I'm trying to make my bot returning all the servers it shares with an user. So I got all the ids from the guilds' where the bot is, and the id fr

Solution 1:

It is very much possible...

We can use the Collector#filter method for this since we would want to filter the guild(s) the bot and the author is.

const mutualGuilds = client.guilds.cache.filter((guild) => {
   return guild.members.cache.has(message.author.id);
});

    // This will log the mutual guild(s) the bot and the author is in, of course you can change it however you'd like.
console.log(mutualGuilds);

It is as easy as this.


Post a Comment for "Check If An User Is In A Specific Guild Discord.js"