distype - v3.0.1
    Preparing search index...

    Class Gateway

    The gateway manager. Manages shards, handles incoming payloads, and sends commands to the Discord gateway.

    All events are emitted with their entire payload; Discord API Reference. Dispatched events are emitted under the * event prior to being passed through the cache event handler. After being handled by the cache manager, they are emitted again under their individual event name (example: GUILD_CREATE).

    Hierarchy

    Index

    Constructors

    Properties

    managingShards:
        | null
        | { offset: number; shards: number; totalBotShards: number } = null

    The shard counts the manager is controlling.

    options: Required<GatewayOptions> & { intents: number }

    Options for the gateway manager. Note that any options not specified are set to a default value.

    shards: ExtendedMap<number, GatewayShard> = ...

    Gateway shards. Modifying this map externally may result in unexpected behavior.

    system: "Gateway" = ...

    The system string used for logging.

    user: null | APIUser = null

    The latest self user received from the gateway.

    API_VERSION: 10

    The default gateway API version used.

    REQUEST_GUILD_MEMBERS_MAX_NONCE_LENGTH: 32

    The maximum length in bytes allowed for the nonce property in a request guild members payload.

    SHARD_SPAWN_COOLDOWN: 5000

    The cooldown between spawning shards from the same bucket in milliseconds.

    Accessors

    • get averageHeartbeatPing(): number

      The average heartbeat ping in milliseconds across all shards.

      Returns number

    Methods

    • Connect to the gateway.

      Parameters

      • OptionalgatewayBot: APIGatewayBotInfo

        A pre-fetched GET /gateway/bot. Not required, as this method will fetch it if not specified.

      Returns Promise<[number, number]>

      The results from shard spawns; [success, failed].

    • Get the average ping across all shards.

      Returns Promise<number>

    • Get members from a guild.

      Parameters

      • guildId: string

        The ID of the guild to get members from.

      • options: Partial<Omit<GatewayRequestGuildMembersDataWithQuery, "guild_id" | "presences">> & {
            user_ids?: string | string[];
        } = {}

        Guild member request options. By default, all members in the guild will be fetched.

      Returns Promise<
          {
              members: ExtendedMap<string, APIGuildMember>;
              notFound?: string[];
              presences?: ExtendedMap<string, GatewayPresenceUpdate>;
          },
      >

      Received members, presences, and missing members.

    • Get a guild's shard.

      Type Parameters

      • T extends boolean

      Parameters

      • guildId: string

        The guild's ID.

      • Optionalensure: T

        If true, an error is thrown if a GatewayShard is not found.

      Returns T extends true ? GatewayShard : number | GatewayShard

      The guild's shard, or a shard ID if the shard is not in this manager.

      [Discord API Reference]

    • Update the bot's presence.

      Parameters

      • presence: GatewayPresenceUpdateData | GatewayPresenceUpdateData

        Presence data.

      • shard: number | number[] | "all" = ...

        A shard or shards to set the presence on. A number will set the presence on a single shard with a matching ID, a number array will set the presence on all shards matching am ID in the array, and all will set the presence on all shards.

      Returns Promise<void>

    • Update the bot's voice state.

      Parameters

      • guildId: string

        The guild to set the voice state in.

      • channelId: null | string

        The channel to join. nulldisconnects the bot.

      • mute: boolean = false

        If the bot should self mute.

      • deafen: boolean = false

        If the bot should self deafen.

      Returns Promise<void>