Routes.guildMembers only returns 1 member

Running into a strange issue with discord.js REST where I am only getting a single result for Routes.guildMembers(guildId) despite the server I am testing clearly having over 5k members.

Server Members Intent is enabled in discord dev portal.

    let lastId = '0';


// Fetch 1000 members at a time (Discord API limit)
    const response = await rest.get(
      Routes.guildMembers(guildId),
      { query: { limit: 1000, after: lastId } }
    );

    console.log(response); // for debugging....

    // The response should be an array of member objects
    const members = Array.isArray(response) ? response : [];

    console.log({
      message: 'Response from Discord API',
      isArray: Array.isArray(response),
      responseType: typeof response,
      memberCount: members.length,
      firstMember: members.length > 0 ? JSON.stringify(members[0]).substring(0, 100) + '...' : 'none'
    });


when this runs the response returns an array with a single user in it.

[
  {
    avatar: null,
    banner: null,
    communication_disabled_until: null,
    flags: <sanitized>,
    joined_at: '<sanitized>',
    nick: null,
    pending: false,
    premium_since: null,
    roles: [ '<sanitized>' ],
    unusual_dm_activity_until: null,
    user: {
      id: '<sanitized>',
      username: '<sanitized>',
      avatar: '<sanitized>',
      discriminator: '0',
      public_flags: <sanitized>,
      flags: <sanitized>,
      banner: null,
      accent_color: null,
      global_name: '<sanitized>',
      avatar_decoration_data: null,
      collectibles: null,
      banner_color: null,
      clan: null,
      primary_guild: null
    },
    mute: false,
    deaf: false
  }
]


If anyone has any insights into where I migth be going wrong here, please let me know.
Was this page helpful?