distype - v3.0.1
    Preparing search index...

    Class GatewayShard

    A gateway shard. Handles the low level ws communication with Discord.

    Hierarchy

    Index

    Constructors

    • Create a gateway shard.

      Parameters

      • token: string

        The bot's token.

      • id: number

        The shard's ID.

      • numShards: number

        The value to pass to num_shards in the identify payload.

      • url: string

        The URL being used to connect to the gateway.

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

        Gateway shard options.

      • logCallback: LogCallback = ...

        A callback to be used for logging events internally in the gateway shard.

      • OptionallogThisArg: any

        A value to use as this in the logCallback.

      Returns GatewayShard

    Properties

    guilds: Set<string> = ...

    Guilds that belong to the shard. This is populated as the shard is receiving GUILD_CREATE payloads, and is accurate after the shard is in a guilds ready state.

    heartbeatPing: number = 0

    The shard's heartbeat ping in milliseconds.

    id: number

    The shard's ID.

    lastSequence: null | number = null

    The last sequence number received.

    numShards: number

    The value to pass to num_shards in the identify payload.

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

    Options for the gateway shard.

    resumeURL: null | string = null

    The URL used for reconnecting and resuming sessions.

    sessionId: null | string = null

    The shard's session ID.

    state: GatewayShardState = GatewayShardState.IDLE

    The shard's state.

    system: `Gateway Shard ${number}`

    The system string used for logging.

    url: string

    The URL being used.

    waitingForGuilds: null | Set<string> = null

    Guilds expected to receive a GUILD_CREATE from.

    ws: null | WebSocket = null

    The WebSocket used by the shard.

    Methods

    • Kills the shard.

      Parameters

      • reason: string = ...

        The reason the shard is being killed. Defaults to "Manual kill".

      • code: number = 1000

        A socket close code to send if the connection is still open. Defaults to 1000.

      Returns void

    • Sends a payload to the gateway.

      Parameters

      • payload: GatewaySendPayload

      Returns Promise<void>