Client
EventEmitteropen in new window
Client extendsA Discord client
Properties
.application?
The client's application
type application = Application | undefined;
.guilds
The guilds the client is in
type guilds = Map<Snowflake, UnavailableGuild>;
- See Mapopen in new window
- See Snowflake
.heartbeatInfo
Data about an heartbeat
type heartbeatInfo = AdvancedHeartbeatInfo;
.intents
Intents used by this client
type intents = Intents;
- See Intents
.largeThreshold
Total number of members where the gateway will stop sending offline members in the guild member list
type largeThreshold = number;
.rest
The rest manager of this client
type rest = Rest;
.seq
The last sequence number received from the WebSocket server
type seq = number | null;
.sessionId
The session ID of this client
type sessionId = string | undefined;
.status
The status of the connection of this client
type status = ClientStatus;
- See ClientStatus
.token
The token used by this client
type = Token;
- See Token
.user
The client user
type = User | undefined;
.userAgent
The user agent to append to requests to the API
type = string | undefined;
.ws
The WebSocket of this client
type = WebSocket | undefined;
Constructor
new Client(options);
Parameter | Default | Description | Type | Required |
---|---|---|---|---|
options | - | Options for the client | ClientOptions | true |
options.token | p | The token of this client. This defaults to p if none is provided | Token | undefined | false |
options.largeThreshold | 50 | Total number of members where the gateway will stop sending offline members in the guild member list | number | undefined | false |
options.intents | - | Intents to use for this client | Intents | true |
options.userAgent | - | An optional user agent to add in the requests to the API. See Discord's referenceopen in new window | string | undefined | true |
Functions
connect()
Connect this client to the WebSocket.
Returns
Promise<void>
getGatewayUrl()
Get the gateway url.
Returns
Promise<string>
Events
channelCreate
Fired when a guild channel is created
Parameter | Description | Type |
---|---|---|
channel | The channel that got created | AnyGuildChannel |
- See AnyGuildChannel
channelDelete
Fired when a guild channel is deleted
Parameter | Description | Type |
---|---|---|
channel | The channel that got deleted | AnyGuildChannel |
channelUpdate
Fired when a guild channel is updated
Parameter | Description | Type |
---|---|---|
channel | The channel that got updated | AnyGuildChannel |
error
Fired when a server-side error occurs
Parameter | Description | Type |
---|---|---|
channel | The error encountered | Error open in new window |
ready
Fired when the client is ready
resumed
Fired when a resume payload is sent
unknownPayload
Fired when an unknown payload has been received
Parameter | Description | Type |
---|---|---|
data | The payload received | GatewayDispatchPayload open in new window |
warn
Fired when something wrong happens, but is not grave enough to kill the process
Parameter | Description | Type |
---|---|---|
message | The warn message | string open in new window |