interface OptionalWebSocketManagerOptions
Optional additional configuration for the WebSocketManager
externalCompressionMethod | null = null (no transport compression) compression :
The transport compression method to use - mutually exclusive with useIdentifyCompression
externalEncoding = 'json' encoding :
The encoding to use
externalGatewayIdentifyProperties identifyProperties :
Properties to send to the gateway when identifying
externalGatewayPresenceUpdateData | null initialPresence :
Initial presence data to send to the gateway when identifying
Value between 50 and 250, total number of members where the gateway will stop sending offline members in the guild member list
deprecatedoptionalexternalREST rest? :
Providing a REST instance is deprecated. Provide the fetchGatewayInformation
function instead.
The REST instance to use for fetching gateway information
The total number of shards across all WebsocketManagers you intend to instantiate. Use null
to use Discord's recommended shard count
externalnumber[] | ShardRange | null shardIds :
The ids of the shards this WebSocketManager should manage. Use null
to simply spawn 0 through shardCount - 1
externalstring token :
The token to use for identifying with the gatewayIf not provided, the token must be set using setToken
externalboolean = false useIdentifyCompression :
Whether to use the compress
option when identifying
externalstring = '10' version :
The gateway version to use
external buildIdentifyThrottlermanager: WebSocketManager) : Awaitable<IIdentifyThrottler> (
Builds an identify throttler to use for this manager's shards
external buildStrategymanager: WebSocketManager) : IShardingStrategy (
Builds the strategy to use for sharding
const manager = new WebSocketManager({
token: process.env.DISCORD_TOKEN,
intents: 0, // for no intents
rest,
buildStrategy: (manager) => new WorkerShardingStrategy(manager, { shardsPerWorker: 2 }),
});
external fetchGatewayInformationAwaitable<RESTGetAPIGatewayBotResult> () :
Fetches the initial gateway URL used to connect to Discord. When missing, this will default to the gateway URL that Discord returns from the /gateway/bot
route.
const manager = new WebSocketManager({
token: process.env.DISCORD_TOKEN,
fetchGatewayInformation() {
return rest.get(Routes.gatewayBot());
},
})
external retrieveSessionInfoshardId: 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
},
});
external updateSessionInfoshardId: numbersessionInfo: SessionInfo | null) : Awaitable<void> (
Function used to store session information for a given shard