Skip to content
Advertisement

Discord JS Client only has itself in guild members cache

So I was trying to access a member from a guild via

client.guilds.cache.find((guild) => guild.id === id).members.cache.find((member) => member.user.username === name)

but when the bot starts up the guild only contains itself until a user sends a message.

Advertisement

Answer

You need to enable member fetch When creating the client client = new Client({fetchAllMembers: true}}

Do note that calling Fetch() on a guild Will Overwrite the internal cached guild.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement