I am running into an issue trying to fetch a list of all users in a Server (Guild)
Just set up a new simple Discord Bot and installed the latest Discord.js in a new project. I'm just trying to fetch a list of all users in a Server (guild):
const Discord = require('discord.js')
const client = new Discord.Client()
client.login(process.env.DISCORD_BOT_TOKEN)
const server = await client.guilds.fetch(process.env.DISCORD_SERVER_ID)
const members = await server.members.fetch()
Results in an error message of:
Cannot read property 'send' of undefined
Referencing src/managers/GuildMemberManager.js:276:24, which is calling
this.guild.shard.send
And of course this.guild.shard is undefined.
Further details:
Any updates on this? I am getting the exact same error
These operations need to be executed after the client has logged in. To ensure this place the code in any client event callback as any boilerplate or guide suggests. If you want to do this regardless of message context the Client event "ready" is available which emits after the client has become fully ready.
If you need help with discord.js installation or usage, please go to the discord.js Discord server instead:
https://discord.gg/bRCvFy9
This issue tracker is only for bug reports and enhancement suggestions. You won't receive any basic help here.
These operations need to be executed after the client has logged in. To ensure this place the code in any client event callback as any boilerplate or guide suggests. If you want to do this regardless of message context the Client event "ready" is available which emits after the client has become fully ready.
If you need help with discord.js installation or usage, please go to the discord.js Discord server instead:
https://discord.gg/bRCvFy9
This issue tracker is only for bug reports and enhancement suggestions. You won't receive any basic help here.
waited for the "ready" event and it worked after. Thank you so much!
Most helpful comment
These operations need to be executed after the client has logged in. To ensure this place the code in any client event callback as any boilerplate or guide suggests. If you want to do this regardless of message context the Client event "ready" is available which emits after the client has become fully ready.
If you need help with discord.js installation or usage, please go to the discord.js Discord server instead:
https://discord.gg/bRCvFy9
This issue tracker is only for bug reports and enhancement suggestions. You won't receive any basic help here.