Client

Client extends EventEmitteropen in new window

A Discord client

Properties

.application?

The client's application

type application = Application | undefined;

.guilds

The guilds the client is in

type guilds = Map<Snowflake, UnavailableGuild>;

.heartbeatInfo

Data about an heartbeat

type heartbeatInfo = AdvancedHeartbeatInfo;

.intents

Intents used by this client

type intents = 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;

.token

The token used by this client

type = 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);
ParameterDefaultDescriptionTypeRequired
options-Options for the clientClientOptionstrue
options.tokenprocess.env.DISCORD_TOKENThe token of this client. This defaults to process.env.DISCORD_TOKEN if none is providedToken | undefinedfalse
options.largeThreshold50Total number of members where the gateway will stop sending offline members in the guild member listnumber | undefinedfalse
options.intents-Intents to use for this clientIntentstrue
options.userAgent-An optional user agent to add in the requests to the API. See Discord's referenceopen in new windowstring | undefinedtrue

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

ParameterDescriptionType
channelThe channel that got createdAnyGuildChannel

channelDelete

Fired when a guild channel is deleted

ParameterDescriptionType
channelThe channel that got deletedAnyGuildChannel

channelUpdate

Fired when a guild channel is updated

ParameterDescriptionType
channelThe channel that got updatedAnyGuildChannel

error

Fired when a server-side error occurs

ParameterDescriptionType
channelThe error encounteredErroropen 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

ParameterDescriptionType
dataThe payload receivedGatewayDispatchPayloadopen in new window

warn

Fired when something wrong happens, but is not grave enough to kill the process

ParameterDescriptionType
messageThe warn messagestringopen in new window
Last Updated:
Contributors: NotReallyEight