`Cannot read properties of undefined (reading 'send')` when fetching guild members

Hi! I got some weird error while fetching the members list of my guild. I believe this is a lib bug, but I want to make sure I didn't miss anything on my side
My code:
const guild = await this.getClient().guilds.fetch(guildId);
const members = await guild.members.fetch();

the error:
[ERROR] TypeError: Cannot read properties of undefined (reading 'send')
    at .../node_modules/discord.js/src/managers/GuildMemberManager.js:237:24
    at new Promise (<anonymous>)
    at GuildMemberManager._fetchMany (.../node_modules/discord.js/src/managers/GuildMemberManager.js:235:12)
    at GuildMemberManager.fetch (.../node_modules/discord.js/src/managers/GuildMemberManager.js:207:31)
    ...

and the d.js code leading to this error:
      this.guild.shard.send({
        op: GatewayOpcodes.RequestGuildMembers,
        d: {
          guild_id: this.guild.id,
          presences,
          user_ids: users,
          query,
          nonce,
          limit,
        },
      });
(guild.shard is indeed undefined when printed on console)
Was this page helpful?