Interface GatewayOptions

interface GatewayOptions {
    autoReconnect?: boolean;
    compress?: boolean;
    concurrency?: number | "auto";
    connectionProperties?: {
        browser?: string;
        device?: string;
        os?: string;
    };
    connectionTimeout?: number;
    firstShardID?: number;
    getAllUsers?: boolean;
    guildCreateTimeout?: number;
    intents?: number | (number | "GUILDS" | "GUILD_MEMBERS" | "GUILD_MODERATION" | "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" | "GUILD_MESSAGE_POLLS" | "DIRECT_MESSAGE_POLLS" | "ALL" | "ALL_NON_PRIVILEGED")[];
    largeThreshold?: number;
    lastShardID?: number;
    lookupDisallowedIntents?: boolean;
    maxReconnectAttempts?: number;
    maxResumeAttempts?: number;
    maxShards?: number | "auto";
    override?: OverrideOptions;
    presence?: UpdatePresenceOptions;
    reconnectDelay?: ReconnectDelayFunction;
    removeDisallowedIntents?: boolean;
    seedVoiceConnections?: boolean;
    shardIDs?: number[];
    useDefaultDispatchHandlers?: boolean;
    ws?: ClientOptions;
}

Properties

autoReconnect?: boolean

If dropped connections should be automatically reconnected.

Default Value

true
compress?: boolean

If packets to and from Discord should be compressed.

Default Value

false
concurrency?: number | "auto"

The concurrency for shard connections. If you don't know what this is, don't mess with it. Only bots in >150,000 servers can use any non-default value.

Default Value

1
connectionProperties?: {
    browser?: string;
    device?: string;
    os?: string;
}

The properties used when identifying.

Type declaration

  • Optional browser?: string

    The browser of the client. For example, "Discord Android" or "Discord iOS" to show as mobile.

    Default Value

    Oceanic
    
  • Optional device?: string

    The device of the client.

    Default Value

    Oceanic
    
  • Optional os?: string

    The operating system of the client.

    Default Value

    process.platform()

connectionTimeout?: number

The maximum amount of time in milliseconds to wait for a connection to be established.

Default Value

30000
firstShardID?: number

The ID of the first shard to run for this client. Mutually exclusive with shardIDs.

Default Value

0
getAllUsers?: boolean

If the members of all guilds should be requested. Requires the GUILD_MEMBERS intent.

Default Value

false
guildCreateTimeout?: number

The time in milliseconds after which the client will consider all guilds to have been received.

Default Value

2000
intents?: number | (number | "GUILDS" | "GUILD_MEMBERS" | "GUILD_MODERATION" | "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" | "GUILD_MESSAGE_POLLS" | "DIRECT_MESSAGE_POLLS" | "ALL" | "ALL_NON_PRIVILEGED")[]

The intents to use. Either a number, array of intent names, array of numbers, or "ALL"/"ALL_NON_PRIVILEGED". All non privileged intents are used by default.

Default Value

{@link Constants~AllNonPrivilegedIntents | All Non Privileged Intents}
largeThreshold?: number

The threshold at which guilds are considered "large" (after which offline members will not be loaded).

Default Value

250
lastShardID?: number

The ID of the last shard to run for this client. Mutually exclusive with shardIDs.

Default Value

maxShards - 1
lookupDisallowedIntents?: boolean

If upon recieving a disconnect for disallowed intents, we should request the application's flags and list the privileged intents that are missing in the error. This requires making a request to /applications/@me.

Default Value

false
maxReconnectAttempts?: number

The maximum number of attempts to reconnect.

Default Value

Infinity
maxResumeAttempts?: number

The maximum number of attempts to resume a lost connection.

Default Value

10
maxShards?: number | "auto"

The total number of shards across all running clients. Limit the number of shards per client via firstShardID & lastShardID.

Default Value

1
override?: OverrideOptions

Options for overriding default gateway behavior.

The initial presence to use when connecting.

reconnectDelay?: ReconnectDelayFunction

A function to calculate the delay between reconnect attempts.

Default Value

(lastDelay, attempts) => Math.pow(attempts + 1, 0.7) * 20000
removeDisallowedIntents?: boolean

If a check should be made before connecting, which will remove any disallowed intents. This requires making a request to /applications/@me. Any removed intents will be emitted via the warn event.

Default Value

false
seedVoiceConnections?: boolean

If existing voice connections should be populated. This will disconnect connections from other sessions.

Default Value

false
shardIDs?: number[]

An array of shard IDs to run for this client. Mutually exclusive with firstShardID & lastShardID.

Default Value

based on firstShardID & lastShardID

useDefaultDispatchHandlers?: boolean

If the built-in dispatch handlers should be used. Disabling this will result in no dispatch packets being handled by the client. Handlers for READY and RESUMED will always be registered. You must handle everything else manually.

Default Value

true
ws?: ClientOptions

The options to pass to constructed websockets.