Skip to content

Manager

Manages the connection and communication with the Discord Gateway using multiple shards.

This serves as the primary class for developers wanting to interact with the Discord Gateway, this class is responsible for creating the required shards sending messages asynchronously through each shard.

Properties

token

Manager.token  :: Secret

intents

Manager.intents  :: number

webSocketVersion

Manager.webSocketVersion  :: number

largeThreshold

Manager.largeThreshold  :: number?

shouldReconnect

Manager.shouldReconnect  :: boolean

ready

Manager.ready  :: boolean

shardIds

Manager.shardIds  :: { ShardId }

shards

Manager.shards  :: {
      {… [ShardId]: WebSocket.Shard …}    }

logger

Manager.logger  :: Logger.Logger

onDisconnected

Manager.onDisconnected  :: Emitter<ShardPayload<{ errorCode: number? }>

onReconnected

Manager.onReconnected  :: Emitter<ShardPayload<{}>

onConnected

Manager.onConnected  :: Emitter<ShardPayload<{}>

onHeartbeat

Manager.onHeartbeat  :: Emitter<ShardPayload<{ latency: number }>

onDispatch

onAllShardsReady

Methods

The Manager instance has no set methods!

Functions

connectAsync

Manager . connectAsync (

     self: Manager
     gatewayInformation: apiTypes.GetGatewayBotResponse
)  -> ()

Will create, as well as connect all of the shards this application requires in order to communicate back and fourth between discords WebSocket

sendAsync

Manager . sendAsync (

     self: Manager
     operation: apiTypes.Opcode
     data: T
)  -> ()

Will send a message through all shards this Manager is currently responsible for. This message is sent to the discord WebSocket.

new

Manager . new (

     settings: { token: secret.Secret<string>
)  -> ()

Will instantiate a new Manager class.