Make all properties in T optional

interface CreateWebSocketManagerOptions {
    buildIdentifyThrottler?: (
        manager: WebSocketManager,
    ) => Awaitable<IIdentifyThrottler>;
    buildStrategy?: (manager: WebSocketManager) => IShardingStrategy;
    compression?: null | ZlibStream;
    encoding?: JSON;
    handshakeTimeout?: null | number;
    helloTimeout?: null | number;
    identifyProperties?: GatewayIdentifyProperties;
    initialPresence?: null | GatewayPresenceUpdateData;
    intents: 0 | GatewayIntentBits;
    largeThreshold?: null | number;
    readyTimeout?: null | number;
    rest: REST;
    retrieveSessionInfo?: (shardId: number) => Awaitable<null | SessionInfo>;
    shardCount?: null | number;
    shardIds?: null | number[] | ShardRange;
    token: string;
    updateSessionInfo?: (
        shardId: number,
        sessionInfo: null | SessionInfo,
    ) => Awaitable<void>;
    version?: string;
}

Hierarchy (View Summary)

Properties

buildIdentifyThrottler?: (
    manager: WebSocketManager,
) => Awaitable<IIdentifyThrottler>

Type declaration

buildStrategy?: (manager: WebSocketManager) => IShardingStrategy

Type declaration

    • (manager: WebSocketManager): IShardingStrategy
    • Builds the strategy to use for sharding

      Parameters

      Returns IShardingStrategy

      const manager = new WebSocketManager({
      token: process.env.DISCORD_TOKEN,
      intents: 0, // for no intents
      rest,
      buildStrategy: (manager) => new WorkerShardingStrategy(manager, { shardsPerWorker: 2 }),
      });
compression?: null | ZlibStream

The compression method to use

null (no compression)

encoding?: JSON

The encoding to use

'json'

handshakeTimeout?: null | number

How long to wait for a shard to connect before giving up

helloTimeout?: null | number

How long to wait for a shard's HELLO packet before giving up

identifyProperties?: GatewayIdentifyProperties

Properties to send to the gateway when identifying

initialPresence?: null | GatewayPresenceUpdateData

Initial presence data to send to the gateway when identifying

intents: 0 | GatewayIntentBits

The intents to request

largeThreshold?: null | number

Value between 50 and 250, total number of members where the gateway will stop sending offline members in the guild member list

readyTimeout?: null | number

How long to wait for a shard's READY packet before giving up

rest: REST

The REST instance to use for fetching gateway information

retrieveSessionInfo?: (shardId: number) => Awaitable<null | SessionInfo>

Type declaration

    • (shardId: number): Awaitable<null | SessionInfo>
    • Function used to retrieve session information (and attempt to resume) for a given shard

      Parameters

      • shardId: number

      Returns Awaitable<null | SessionInfo>

      const manager = new WebSocketManager({
      async retrieveSessionInfo(shardId): Awaitable<SessionInfo | null> {
      // Fetch this info from redis or similar
      return { sessionId: string, sequence: number };
      // Return null if no information is found
      },
      });
shardCount?: null | number

The total number of shards across all WebsocketManagers you intend to instantiate. Use null to use Discord's recommended shard count

shardIds?: null | number[] | ShardRange

The ids of the shards this WebSocketManager should manage. Use null to simply spawn 0 through shardCount - 1

const manager = new WebSocketManager({
shardIds: [1, 3, 7], // spawns shard 1, 3, and 7, nothing else
});
const manager = new WebSocketManager({
shardIds: {
start: 3,
end: 6,
}, // spawns shards 3, 4, 5, and 6
});
token: string

The token to use for identifying with the gateway

updateSessionInfo?: (
    shardId: number,
    sessionInfo: null | SessionInfo,
) => Awaitable<void>

Type declaration

    • (shardId: number, sessionInfo: null | SessionInfo): Awaitable<void>
    • Function used to store session information for a given shard

      Parameters

      Returns Awaitable<void>

version?: string

The gateway version to use

'10'