KlangDocs

    Open Klang

    Bot API reference

    View as Markdown

    Servers

    Reading a server the bot is in. The server with its roles, emojis and stickers, the channels and threads the bot can see, its roles, its members and one member.

    Before you read

    Discord’s API calls a server a guild, and so do the routes and fields. All of these routes need the bot to be in the server: for any other server, one that doesn’t exist or one that’s suspended, they answer 404 with 10004. They read the server the way the bot sees it, so channels it can’t see never appear.

    Reading a server, its channels or its roles shares the read-guild bucket, 10 every 10 seconds per bot. The member list has its own, read-members, 10 every 10 seconds per bot, and one member counts in read-users, 20 every 5 seconds. Each bucket goes per bot, whichever server it reads.

    A server

    HTTP
    GET /guilds/{guild.id}

    The server, with its roles, emojis and stickers. approximate_member_count is always there.

    Query Type Notes
    with_counts true or false Adds approximate_presence_count: people online now.
    Status Code When
    404 10004 The bot isn’t in it, or there’s no such server.

    This example has its lists shortened to one item each:

    JSON
    {
      "id": "1571350333212610560",
      "name": "Harbor",
      "icon": null,
      "splash": null,
      "discovery_splash": null,
      "banner": null,
      "description": null,
      "owner_id": "1571350324312297472",
      "afk_channel_id": null,
      "afk_timeout": 300,
      "widget_enabled": false,
      "widget_channel_id": null,
      "verification_level": 0,
      "default_message_notifications": 1,
      "explicit_content_filter": 0,
      "roles": [
        {
          "id": "1571350334990995456",
          "name": "Lighthouse",
          "color": 0,
          "colors": { "primary_color": 0, "secondary_color": null, "tertiary_color": null },
          "hoist": false,
          "icon": null,
          "unicode_emoji": null,
          "position": 1,
          "permissions": "85056",
          "managed": true,
          "mentionable": false,
          "flags": 0,
          "tags": { "bot_id": "1571350332965146624" }
        }
      ],
      "emojis": [
        {
          "id": "1571350334105997312",
          "name": "anchor",
          "animated": false,
          "roles": [],
          "require_colons": true,
          "managed": false,
          "available": true
        }
      ],
      "stickers": [
        {
          "id": "1571350334407987200",
          "name": "Wave",
          "description": null,
          "tags": "🌊",
          "type": 2,
          "format_type": 1,
          "available": true,
          "guild_id": "1571350333212610560"
        }
      ],
      "features": ["PIN_PERMISSION_MIGRATION_COMPLETE"],
      "mfa_level": 0,
      "application_id": null,
      "system_channel_id": "1571350333212610562",
      "system_channel_flags": 0,
      "rules_channel_id": null,
      "max_presences": null,
      "max_members": 500000,
      "vanity_url_code": null,
      "premium_tier": 0,
      "premium_subscription_count": 0,
      "preferred_locale": "en-US",
      "public_updates_channel_id": null,
      "max_video_channel_users": 25,
      "max_stage_video_channel_users": 0,
      "approximate_member_count": 3,
      "nsfw_level": 0,
      "premium_progress_bar_enabled": false,
      "hub_type": null,
      "safety_alerts_channel_id": null,
      "incidents_data": null,
      "approximate_presence_count": 1
    }

    Its channels

    HTTP
    GET /guilds/{guild.id}/channels

    A list of channels: first the text channels, voice channels and categories the bot can see, then the active threads in those text channels, the most recently active first, up to 500. A category appears when the bot can see it or any channel in it. Each channel’s permission_overwrites come flattened: its category’s and its own in one list.

    Status Code When
    404 10004 The bot isn’t in it, or there’s no such server.

    In this server, #rules stops @everyone from writing, and the bot can’t see #staff, so it’s not in the list:

    JSON
    [
      {
        "id": "1571350333212610562",
        "guild_id": "1571350333212610560",
        "name": "general",
        "position": 0,
        "permission_overwrites": [],
        "nsfw": false,
        "flags": 0,
        "parent_id": null,
        "last_message_id": "1571350339420180482",
        "rate_limit_per_user": 0,
        "type": 0,
        "topic": null,
        "default_auto_archive_duration": 10080
      },
      {
        "id": "1571350333724315648",
        "guild_id": "1571350333212610560",
        "name": "rules",
        "position": 2,
        "permission_overwrites": [
          { "id": "1571350333212610560", "type": 0, "allow": "0", "deny": "562952100923392" }
        ],
        "nsfw": false,
        "flags": 0,
        "parent_id": null,
        "last_message_id": null,
        "rate_limit_per_user": 0,
        "type": 0,
        "topic": "Read before posting.",
        "default_auto_archive_duration": 10080
      },
      {
        "id": "1571350339420180480",
        "type": 11,
        "guild_id": "1571350333212610560",
        "parent_id": "1571350333212610562",
        "name": "Saturday plans",
        "last_message_id": "1571350339550203904",
        "rate_limit_per_user": 0,
        "message_count": 1,
        "total_message_sent": 1,
        "member_count": 0,
        "flags": 0,
        "thread_metadata": {
          "archived": false,
          "auto_archive_duration": 10080,
          "archive_timestamp": "2026-11-15T02:25:15.195Z",
          "locked": false,
          "create_timestamp": "2026-11-15T02:25:15.195Z"
        },
        "owner_id": "1571350324312297472"
      }
    ]

    The deny of #rules is more than Send messages alone: Klang also denies the bits it derives from it, such as EMBED_LINKS and SEND_POLLS, so the result is the same in Klang and in your library.

    Its roles

    HTTP
    GET /guilds/{guild.id}/roles

    Every role of the server, from the lowest position to the highest. @everyone comes first, with the server’s ID as its own. The bot’s role is managed, with the bot’s ID in tags.bot_id.

    Status Code When
    404 10004 The bot isn’t in it, or there’s no such server.
    JSON
    [
      {
        "id": "1571350333212610560",
        "name": "@everyone",
        "color": 0,
        "colors": { "primary_color": 0, "secondary_color": null, "tertiary_color": null },
        "hoist": false,
        "icon": null,
        "unicode_emoji": null,
        "position": 0,
        "permissions": "563261442739777",
        "managed": false,
        "mentionable": false,
        "flags": 0
      },
      {
        "id": "1571350334701588480",
        "name": "Crew",
        "color": 3113197,
        "colors": { "primary_color": 3113197, "secondary_color": null, "tertiary_color": null },
        "hoist": true,
        "icon": null,
        "unicode_emoji": null,
        "position": 2,
        "permissions": "0",
        "managed": false,
        "mentionable": true,
        "flags": 0
      }
    ]

    Its members

    HTTP
    GET /guilds/{guild.id}/members

    A page of members, in ascending order of user ID. The app needs the Server members intent switched on in the developer portal; without it, the route answers 403 with 50001. Whether the bot asked for the intent in its gateway connection doesn’t matter here.

    Query Type Notes
    limit integer, 1 to 1000 1 by default, so send it.
    after ID A user ID: only members with a bigger one. To page, send the last one you got.
    Status Code When
    403 50001 The Server members intent isn’t switched on.
    404 10004 The bot isn’t in it, or there’s no such server.

    GET /guilds/1571350333212610560/members?limit=2&after=1571350324312297472:

    JSON
    [
      {
        "nick": null,
        "avatar": null,
        "banner": null,
        "roles": ["1571350334701588480"],
        "joined_at": "2026-11-15T02:25:13.778Z",
        "premium_since": null,
        "deaf": false,
        "mute": false,
        "flags": 0,
        "pending": false,
        "communication_disabled_until": null,
        "user": {
          "id": "1571350327143452672",
          "username": "leo",
          "discriminator": "0",
          "global_name": "Leo",
          "avatar": null,
          "banner": null,
          "accent_color": null,
          "public_flags": 0
        }
      },
      {
        "nick": null,
        "avatar": null,
        "banner": null,
        "roles": ["1571350334990995456"],
        "joined_at": "2026-11-15T02:25:14.129Z",
        "premium_since": null,
        "deaf": false,
        "mute": false,
        "flags": 4,
        "pending": false,
        "communication_disabled_until": null,
        "user": {
          "id": "1571350332965146624",
          "username": "lighthouse",
          "discriminator": "0",
          "global_name": "Lighthouse",
          "avatar": null,
          "banner": null,
          "accent_color": null,
          "public_flags": 0,
          "bot": true
        }
      }
    ]

    One member

    HTTP
    GET /guilds/{guild.id}/members/{user.id}

    One member of the server. It doesn’t need any intent.

    Status Code When
    404 10007 That user isn’t a member of the server.
    404 10004 The bot isn’t in it, or there’s no such server.
    JSON
    {
      "nick": null,
      "avatar": null,
      "banner": null,
      "roles": ["1571350334701588480"],
      "joined_at": "2026-11-15T02:25:13.778Z",
      "premium_since": null,
      "deaf": false,
      "mute": false,
      "flags": 0,
      "pending": false,
      "communication_disabled_until": null,
      "user": {
        "id": "1571350327143452672",
        "username": "leo",
        "discriminator": "0",
        "global_name": "Leo",
        "avatar": null,
        "banner": null,
        "accent_color": null,
        "public_flags": 0
      }
    }