Interface GatewayOptions

Gateway options.

Hierarchy

  • GatewayOptions

Properties

customGatewaySocketURL?: null | string

A custom socket URL to connect to. Useful if you use a proxy to connect to the Discord gateway. If customGatewayBotEndpoint is defined, its response's url parameter is overwritten by this. Note that gateway URL query parameters will still be sent.

Default

null
customGatewaySocketURLOverwrittenByResumeURL?: null | boolean

If customGatewaySocketURL is defined and this is true, the resume_gateway_url field in the READY dispatch is used instead of the customGatewaySocketURL. Otherwise, if customGatewaySocketURL is defined, it's used for connecting and resuming.

Default

null
customGetGatewayBotURL?: null | string

A custom URL to use as a substitute for GET /gateway/bot. Useful if you use a proxy to connect to the Discord gateway, and it handles bot instances / sharding. This should be the full URL, not just a route (Example: https://api.example.com/gateway, not /gateway). It is expected that making a request to this URL returns the same response that Discord normally would. If the response returns your system's socket URL as the url parameter, there is no need to specify customGatewaySocketURL. Additionally, if you use a custom base URL for the rest manager that returns custom information when GET /gateway/bot is called, this can be left undefined.

Default

null
disableBucketRatelimits?: boolean

If the rate limit on buckets (used for shard spawning) should be disabled. Only disable spawning rate limits if you are using a separate application to manage rate limits (customGatewaySocketURL and/or customGatewayBotEndpoint can be used to do so). Note that shards are still spawned in the order that they would with rate limiting enabled, just without a pause between bucket spawn calls.

Default

false
guildsReadyTimeout?: number

The time to wait in milliseconds after the last GUILD_CREATE event to consider that guilds are ready.

Default

15000
intents?: number | bigint | "all" | ("GUILDS" | "GUILD_MEMBERS" | "GUILD_BANS" | "GUILD_EMOJIS_AND_STICKERS" | "GUILD_INTEGRATIONS" | "GUILD_WEBHOOKS" | "GUILD_INVITES" | "GUILD_VOICE_STATES" | "GUILD_PRESENCES" | "GUILD_MESSAGES" | "GUILD_MESSAGE_REACTIONS" | "GUILD_MESSAGE_TYPING" | "DIRECT_MESSAGES" | "DIRECT_MESSAGE_REACTIONS" | "DIRECT_MESSAGE_TYPING" | "MESSAGE_CONTENT" | "GUILD_SCHEDULED_EVENTS" | "AUTO_MODERATION_CONFIGURATION" | "AUTO_MODERATION_EXECUTION")[] | "nonPrivileged"

Gateway intents. A numerical value is simply passed to the identify payload. An array of intent names will only enable the specified intents. all enables all intents, including privileged intents. nonPrivileged enables all non-privileged intents.

See

Discord API Reference

Default

nonPrivileged

largeGuildThreshold?: number

The number of members in a guild to reach before the gateway stops sending offline members in the guild member list. Must be between 50 and 250.

Default

50
presence?: null | GatewayPresenceUpdateData | GatewayPresenceUpdateData

The initial presence for the bot to use.

See

Discord API Reference

Default

null
sharding?: {
    offset?: number;
    shards?: number;
    totalBotShards?: number | "auto";
}

Gateway sharding. Unless you are using a custom scaling solution (for example, running your bot across numerous servers or processes), it is recommended that you leave all of these options undefined. If you wish to manually specify the number of shards to spawn across your bot, you only need to set GatewayOptions#sharding#totalBotShards.

When using a Client, specified options are passed directly to the gateway manager, without manipulation.

See

Discord API Reference

Default

{}

Type declaration

  • Optional offset?: number

    The number of shards to offset spawning by.

    For example, with the following configuration, the last 2 of the total 4 shards would be spawned.

    sharding: {
    totalBotShards: 4,
    shards: 2,
    offset: 2
    }

    This option should only be manually defined if you are using a custom scaling solution externally from the library and hosting multiple instances of your bot, to prevent unexpected behavior.

  • Optional shards?: number

    The amount of shards to spawn. By default, GatewayOptions#sharding#totalBotShards is used.

  • Optional totalBotShards?: number | "auto"

    The number of shards the bot will have in total. This value is used for the num_shards property sent in the identify payload. This is NOT the amount of shards the process will spawn. For that option, specify GatewayOptions#sharding#shards. auto will use the recommended number from Discord.

spawnAttemptDelay?: number

The number of milliseconds to wait between spawn and resume attempts.

Default

2500
version?: number

The Gateway version to use.

See

Discord API Reference

Default

10
wsOptions?: ClientOptions

Advanced WebSocket options.

See

WebSocket API Reference

Default

{}

Generated using TypeDoc