interface WebSocketManagerOptions extends OptionalWebSocketManagerOptions, RequiredWebSocketManagerOptionsexternalcompression : CompressionMethod | null = null (no transport compression)
The transport compression method to use - mutually exclusive with useIdentifyCompression
Inherited from: OptionalWebSocketManagerOptions
externalencoding : Encoding = 'json'
The encoding to use
Inherited from: OptionalWebSocketManagerOptions
How long to wait for a shard to connect before giving up
Inherited from: OptionalWebSocketManagerOptions
How long to wait for a shard's HELLO packet before giving up
Inherited from: OptionalWebSocketManagerOptions
externalidentifyProperties : GatewayIdentifyProperties
Properties to send to the gateway when identifying
Inherited from: OptionalWebSocketManagerOptions
externalinitialPresence : GatewayPresenceUpdateData | null
Initial presence data to send to the gateway when identifying
Inherited from: OptionalWebSocketManagerOptions
externalintents : GatewayIntentBits | 0
The intents to request
Inherited from: RequiredWebSocketManagerOptions
Value between 50 and 250, total number of members where the gateway will stop sending offline members in the guild member list
Inherited from: OptionalWebSocketManagerOptions
How long to wait for a shard's READY packet before giving up
Inherited from: OptionalWebSocketManagerOptions
The total number of shards across all WebsocketManagers you intend to instantiate. Use null to use Discord's recommended shard count
Inherited from: OptionalWebSocketManagerOptions
externalshardIds : number[] | ShardRange | null
The ids of the shards this WebSocketManager should manage. Use null to simply spawn 0 through shardCount - 1
Inherited from: OptionalWebSocketManagerOptions
externaltoken : string
The token to use for identifying with the gatewayIf not provided, the token must be set using setToken
Inherited from: OptionalWebSocketManagerOptions
externaluseIdentifyCompression : boolean = false
Whether to use the compress option when identifying
Inherited from: OptionalWebSocketManagerOptions
externalversion : string = '10'
The gateway version to use
Inherited from: OptionalWebSocketManagerOptions
external buildIdentifyThrottler(manager: WebSocketManager) : Awaitable<IIdentifyThrottler>
Builds an identify throttler to use for this manager's shards
Inherited from: OptionalWebSocketManagerOptions
external buildStrategy(manager: WebSocketManager) : IShardingStrategy
Builds the strategy to use for sharding
const rest = new REST().setToken(process.env.DISCORD_TOKEN);
const manager = new WebSocketManager({
token: process.env.DISCORD_TOKEN,
intents: 0, // for no intents
fetchGatewayInformation() {
return rest.get(Routes.gatewayBot()) as Promise<RESTGetAPIGatewayBotResult>;
},
buildStrategy: (manager) => new WorkerShardingStrategy(manager, { shardsPerWorker: 2 }),
});Inherited from: OptionalWebSocketManagerOptions
external fetchGatewayInformation() : Awaitable<RESTGetAPIGatewayBotResult>
Function for retrieving the information returned by the /gateway/bot endpoint. We recommend using a REST client that respects Discord's rate limits, such as @discordjs/rest.
const rest = new REST().setToken(process.env.DISCORD_TOKEN);
const manager = new WebSocketManager({
token: process.env.DISCORD_TOKEN,
fetchGatewayInformation() {
return rest.get(Routes.gatewayBot()) as Promise<RESTGetAPIGatewayBotResult>;
},
});Inherited from: RequiredWebSocketManagerOptions
external retrieveSessionInfo(shardId: number) : Awaitable<SessionInfo | null>
Function used to retrieve session information (and attempt to resume) for a given shard
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
},
});Inherited from: OptionalWebSocketManagerOptions
external updateSessionInfo(shardId: numbersessionInfo: SessionInfo | null) : Awaitable<void>
Function used to store session information for a given shard
Inherited from: OptionalWebSocketManagerOptions