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.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).
readyAtDate | nullTimestamp when the client became ready. Null until READY is received.
restread-onlyRESTREST client for making API requests.
Routesstaticread-onlytypeof RoutesREST path helpers (Routes). Pass the path to client.rest. Prefer high-level helpers (channel.send(), guild.members.fetch()) when they exist.
const channel = await client.rest.get(Client.Routes.channel(channelId));
await client.rest.post(Client.Routes.channelMessages(channelId), {
  body: { content: 'hello' },
});
uptimeread-onlynumber | nullMilliseconds since readyAt, or null if the client is not ready.
client.on(Events.Ready, () => {
  console.log(client.uptime);
});
userClientUser | nullThe authenticated bot user. Null until READY is received.
usersread-onlyUserManagerUser cache and manager.
wsread-onlyWebSocketManagerThe underlying WebSocketManager (throws if not logged in). Gateway heartbeat ACK latency: client.ws.ping (ms, or -1 before the first ACK).
console.log(client.ws.ping);

Methods

.assertReady()

void

Assertion that client is ready (throws if not).

client.assertReady();

.bulkFetchMessages(requests, options?)

requests: BulkFetchMessagesRequest[], options?: BulkFetchMessagesOptions & { hydrate?: true }Promise<BulkFetchMessagesResult>

requests: BulkFetchMessagesRequest[], options: BulkFetchMessagesOptions & { hydrate: false }Promise<APIBulkMessageFetchResponse>

Multi-channel message fetch (POST /channels/messages/bulk). User-account only (DefaultUserOnly); bots receive AccessDeniedError. Bots should use preloadMessages or channel.messages.fetch instead.

client.bulkFetchMessages(requests);

.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);

.fetchOAuthApplications()

Promise<APIOAuthApplication[]>

Fetch OAuth2 applications (GET /oauth2/applications/@me). A bot token returns the bot application object (normalized to a one-element array). A user token returns the owner's application list.

client.fetchOAuthApplications();

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<this>

Connect to the gateway with a bot token.

token
stringBot token from the developer portal
options?
{ signal?: AbortSignal; }Optional abort signal for cancellation
const client = new Client();
client.on(Events.Ready, () => console.log('Ready!'));
await client.login(process.env.FLUXER_BOT_TOKEN);

.off(event, listener)

event: K, listener: ClientEventListener<K>this

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

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[]) => voidthis

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[]) => voidthis

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

client.once(event, listener);

.requestChannelMemberCounts(options)

options: { guildId: string; channelId?: string; channelIds?: string[]; nonce?: string; }void

Request per-channel member counts via gateway opcode 16. Event-only: listen for channelMemberCountsUpdate. There is no channel.memberCount field.

client.requestChannelMemberCounts(options);

.requestGuildCounts(options)

options: { guildIds: string[]; nonce?: string; }void

Request guild member/online counts via gateway opcode 15. Listen for guildCountsUpdate. Cached guild.memberCount / guild.onlineCount update when that event arrives.

client.requestGuildCounts(options);

.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 | nullPromise<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);

.searchMessages(options?)

options?: MessageSearchOptionsPromise<MessageSearchResponse>

Search messages in the current bot scope (POST /search/messages, scope: current). Other scopes are denied for bots (BOT_SEARCH_SCOPE_UNAVAILABLE). Returns camelCase results (hitsPerPage) or { indexing: true } while channels are indexed.

client.searchMessages();

.sweepMessages(filter?, channelId?)

filter?: (message: Message, channelId: string) => boolean, channelId?: stringnumber

Sweep cached messages (remove entries matching filter). Prefer CacheController.sweepMessages (client.cache.sweepMessages). The filter receives a hydrated Message (createdAt), not the stored wire payload.

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