Class

Client

Main Fluxer bot client. Connects to the gateway, emits events, and provides REST access.

Extends EventEmitter

Constructor

new Client(options: ClientOptions)

Properties

NameTypeDescription
cacheread-onlyCacheControllerCache limits, stats, sweeps, and cascade entry points.
channelsread-onlyChannelManagerChannel cache and manager.
eventsread-onlyClientEventMethodsTyped event handlers. Prefer client.events.* or client.on(Events.*, ...).
guildsread-onlyGuildManagerGuild cache and manager.
instanceread-onlyResolvedInstanceResolved instance endpoints (API, CDN, invite, …) for this client. Isolated per client — safe for multi-instance processes.
loggerread-onlyLoggerStructured logger (zero-dep).
optionsread-onlyClientOptionsResolved client options (cache defaults applied).
packsread-onlyPackManagerEmoji/sticker pack REST wrappers (/packs/*).
readyAtDate | nullTimestamp when the client became ready. Null until READY is received.
restread-onlyRESTREST client for making API requests.
Routesstaticread-onlytypeof Routes
userClientUser | nullThe authenticated bot user. Null until READY is received.
usersread-onlyUserManagerUser cache and manager.
wsread-onlyWebSocketManagerThe underlying WebSocketManager (throws if not logged in).

Methods

.assertReady()

→ void

Assertion that client is ready (throws if not).

client.assertReady();

.destroy()

→ Promise<void>

Disconnect from gateway, clear all caches, and reset state. Safe to call login again after destroy.

await client.destroy();

.emit(event, args)

event: K, args: ClientEvents[K] → boolean

event: string | symbol, args: unknown[] → boolean

Emit an event with typed arguments.

client.emit(event, args);

static fromDiscovery(origin, options, connectOptions?)

origin: DiscoveryOrigin, options: Omit<ClientOptions, 'instance'>, connectOptions?: { signal?: AbortSignal; } → Promise<Client>

Create a client from instance discovery (GET /.well-known/fluxer). Does not log in — call login with a token afterward.

origin
DiscoveryOriginAPI origin used only to fetch discovery (e.g. https://api.example.com)
options
Omit<ClientOptions, 'instance'>Client options (must not conflict with discovered endpoints.api)
connectOptions?
{ signal?: AbortSignal; }Optional abort signal for the discovery request
await Client.fromDiscovery(origin, options);

.isReady()

→ boolean

Type guard for ready state (narrows client.user to non-null).

client.isReady();

.login(token, options?)

token: string, options?: { signal?: AbortSignal; } → Promise<string>

Connect to the gateway with a bot token.

token
stringBot token from the developer portal
options?
{ signal?: AbortSignal; }Optional abort signal for cancellation
await client.login(token);

.off(event, listener)

event: K, listener: ClientEventListener<K> → this

event: string | symbol, listener: (...args: unknown[]) => void → this

Remove an event listener for a specific event type.

client.off(event, listener);

.on(event, listener)

event: K, listener: ClientEventListener<K> → this

event: string | symbol, listener: (...args: unknown[]) => void → this

Register an event listener for a specific event type.

client.on(event, listener);

.once(event, listener)

event: K, listener: ClientEventListener<K> → this

event: string | symbol, listener: (...args: unknown[]) => void → this

Register a one-time event listener for a specific event type.

client.once(event, listener);

.requestGuildMembers(options)

options: { guildId?: string; guildIds?: string[]; query?: string; limit?: number; userIds?: string[]; presences?: boolean; nonce?: string; } → void

Request guild members via gateway opcode 8 (GUILD_MEMBERS_CHUNK responses). Provide guildId and/or guildIds.

client.requestGuildMembers(options);

.resolveEmoji(emoji, guildId?)

emoji: string | { name: string; id?: string; animated?: boolean }, guildId?: string | null → Promise<string>

Resolve emoji input to API format (e.g., name:id or Unicode).

emoji
string | { name: string; id?: string; animated?: boolean }Emoji string or object with name/id/animated
guildId?
string | nullGuild ID for custom emoji lookup (optional)
await client.resolveEmoji(emoji);

.sweepMessages(filter?, channelId?)

filter?: (message: APIMessage, channelId: string) => boolean, channelId?: string → number

Sweep cached messages (remove entries matching filter). Prefer CacheController.sweepMessages (client.cache.sweepMessages).

filter?
(message: APIMessage, channelId: string) => booleanPredicate to test each message (return true to remove)
channelId?
stringOptional channel ID to scope sweep
client.sweepMessages();