Represents the application client, enabling you to perform actions, detect events, get data that is automatically managed for you, configure internal properties, and way more.

It is the root of the creation of your application.

That's where everything begins.

Hierarchy (View Summary)

Constructors

Properties

application: ClientApplication

Client Application

guilds: typedCollection<
    string,
    {
        about?: string;
        avatar?: string;
        banner?: string;
        createdAt: string;
        defaultChannelId?: string;
        id: string;
        isVerified?: boolean;
        name: string;
        ownerId: string;
        timezone?: string;
        type?: ServerType;
        url?: string;
    },
    Guild,
>

Cached guilds.

lastCheckForUpdate: null | number

Timestamp at which the last check for update happened.

Client's params, including app's token & rest options.

REST methods.

startTime: number

Time at which the connection started in ms.

user?: AppUser

Application/Client User.

users: typedCollection<
    string,
    {
        avatar?: string;
        banner?: string;
        createdAt: string;
        id: string;
        name: string;
        status?: { content?: string; emoteId: number };
        type?: UserType;
    },
    User,
>

Cached users.

util: Util

Utils

Websocket Manager.

captureRejections: boolean

Value: boolean

Change the default captureRejections option on all new EventEmitter objects.

v13.4.0, v12.16.0

captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

See how to write a custom rejection handler.

v13.4.0, v12.16.0

defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single event. This limit can be changed for individual EventEmitter instances using the emitter.setMaxListeners(n) method. To change the default for allEventEmitter instances, the events.defaultMaxListeners property can be used. If this value is not a positive number, a RangeError is thrown.

Take caution when setting the events.defaultMaxListeners because the change affects all EventEmitter instances, including those created before the change is made. However, calling emitter.setMaxListeners(n) still has precedence over events.defaultMaxListeners.

This is not a hard limit. The EventEmitter instance will allow more listeners to be added but will output a trace warning to stderr indicating that a "possible EventEmitter memory leak" has been detected. For any single EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to temporarily avoid this warning:

import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(