Class

Client

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

Extends EventEmitter

Constructor

new Client(options: ClientOptions)
ParamTypeDescription
optionsClientOptions

Properties

cache: CacheController (readonly)

Cache limits, stats, sweeps, and cascade entry points.

channels: ChannelManager (readonly)

Channel cache and manager.

events: ClientEventMethods (readonly)

Typed event handlers. Prefer `client.events.*` or `client.on(Events.*, ...)`.

guilds: GuildManager (readonly)

Guild cache and manager.

instance: ResolvedInstance (readonly)

Resolved instance endpoints (API, CDN, invite, …) for this client. Isolated per client — safe for multi-instance processes.

logger: Logger (readonly)

Structured logger (zero-dep).

options: ClientOptions (readonly)

Resolved client options (cache defaults applied).

packs: PackManager (readonly)

Emoji/sticker pack REST wrappers (`/packs/*`).

readyAt: Date | null

Timestamp when the client became ready. Null until READY is received.

rest: REST (readonly)

REST client for making API requests.

Routes: any (readonly)
user: ClientUser | null

The authenticated bot user. Null until READY is received.

users: UserManager (readonly)

User cache and manager.

ws: WebSocketManager (readonly)

The underlying WebSocketManager (throws if not logged in).

Methods

assertReady(): void

Assertion that client is ready (throws if not).

bulkFetchMessages(requests: BulkFetchMessagesRequest[], options?: BulkFetchMessagesOptions & { hydrate?: true }): Promise<BulkFetchMessagesResult>
ParamTypeDescription
requestsBulkFetchMessagesRequest[]
options?BulkFetchMessagesOptions & { hydrate?: true }
bulkFetchMessages(requests: BulkFetchMessagesRequest[], options: BulkFetchMessagesOptions & { hydrate: false }): Promise<APIBulkMessageFetchResponse>
ParamTypeDescription
requestsBulkFetchMessagesRequest[]
optionsBulkFetchMessagesOptions & { hydrate: false }
checkUsernameTag(username: string, discriminator: string): Promise<APIUserTagCheck>

Check username#discriminator availability.

ParamTypeDescription
usernamestring

Username to check

discriminatorstring

Discriminator to check

destroy(): Promise<void>

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

emit(event: , args: ClientEvents[]): boolean

Emit an event with typed arguments.

ParamTypeDescription
eventK
argsClientEvents[]
emit(event: string | symbol, args: unknown[]): boolean
ParamTypeDescription
eventstring | symbol
argsunknown[]
emit(event: string | symbol, args: unknown[]): boolean
ParamTypeDescription
eventstring | symbol
argsunknown[]
fetchApplication(): Promise<APIApplicationMe>

Fetch the current application (`/applications/@me`).

fetchEmojiMetadata(emojiId: string): Promise<APIEmojiMetadata>

Fetch emoji metadata by ID.

ParamTypeDescription
emojiIdstring

Emoji snowflake

fetchGatewayInfo(): Promise<APIGatewayBotResponse>

Fetch gateway connection info (`/gateway`).

fetchInstance(): Promise<APIInstance>

Fetch instance discovery document (`/.well-known/fluxer`).

fetchOAuthApplications(): Promise<APIOAuthApplication[]>

Fetch OAuth2 applications owned by this bot.

fetchStickerMetadata(stickerId: string): Promise<APIStickerMetadata>

Fetch sticker metadata by ID.

ParamTypeDescription
stickerIdstring

Sticker snowflake

fromDiscovery(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.

ParamTypeDescription
originDiscoveryOrigin

API origin used only to fetch discovery (e.g. `https://api.example.com`)

optionsOmit<ClientOptions, 'instance'>

Client options (must not conflict with discovered `endpoints.api`)

connectOptions?{ signal?: AbortSignal; }

Optional abort signal for the discovery request

getOrCreateUser(data: APIUserPartial): User

Get or create a User from partial API data (hydrates cache).

ParamTypeDescription
dataAPIUserPartial

Partial user data from API

isReady(): boolean

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

login(token: string, options?: { signal?: AbortSignal; }): Promise<string>

Connect to the gateway with a bot token.

ParamTypeDescription
tokenstring

Bot token from the developer portal

options?{ signal?: AbortSignal; }

Optional abort signal for cancellation

off(event: , listener: ClientEventListener<>): this

Remove an event listener for a specific event type.

ParamTypeDescription
eventK
listenerClientEventListener<>
off(event: string | symbol, listener: (...args: unknown[]) => void): this
ParamTypeDescription
eventstring | symbol
listener(...args: unknown[]) => void
off(event: string | symbol, listener: (...args: unknown[]) => void): this
ParamTypeDescription
eventstring | symbol
listener(...args: unknown[]) => void
on(event: , listener: ClientEventListener<>): this

Register an event listener for a specific event type.

ParamTypeDescription
eventK
listenerClientEventListener<>
on(event: string | symbol, listener: (...args: unknown[]) => void): this
ParamTypeDescription
eventstring | symbol
listener(...args: unknown[]) => void
on(event: string | symbol, listener: (...args: unknown[]) => void): this
ParamTypeDescription
eventstring | symbol
listener(...args: unknown[]) => void
once(event: , listener: ClientEventListener<>): this

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

ParamTypeDescription
eventK
listenerClientEventListener<>
once(event: string | symbol, listener: (...args: unknown[]) => void): this
ParamTypeDescription
eventstring | symbol
listener(...args: unknown[]) => void
once(event: string | symbol, listener: (...args: unknown[]) => void): this
ParamTypeDescription
eventstring | symbol
listener(...args: unknown[]) => void
preloadMessages(channelIds: string[]): Promise<APIPreloadMessagesResponse>

Preload recent messages for multiple channels (batch endpoint).

ParamTypeDescription
channelIdsstring[]

Array of channel IDs to preload

preloadMessagesAlt(channelIds: string[]): Promise<APIPreloadMessagesResponse>

Preload recent messages (alternate endpoint).

ParamTypeDescription
channelIdsstring[]

Array of channel IDs to preload

requestGuildMembers(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`.

ParamTypeDescription
options{ guildId?: string; guildIds?: string[]; query?: string; limit?: number; userIds?: string[]; presences?: boolean; nonce?: string; }
resolveEmoji(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).

ParamTypeDescription
emojistring | { name: string; id?: string; animated?: boolean }

Emoji string or object with name/id/animated

guildId?string | null

Guild ID for custom emoji lookup (optional)

sendToGateway(shardId: number, payload: GatewaySendPayload): void

Send a gateway payload to a specific shard.

ParamTypeDescription
shardIdnumber

Shard ID (0-indexed)

payloadGatewaySendPayload

Gateway send payload (opcode + data)

sweepMembers(filter?: (member: GuildMember, guildId: string) => boolean): number

Sweep cached members across all guilds (remove entries matching filter). Prefer CacheController (`client.cache.sweepMembers`).

ParamTypeDescription
filter?(member: GuildMember, guildId: string) => boolean

Predicate to test each member (return true to remove)

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

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

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

Predicate to test each message (return true to remove)

channelId?string

Optional channel ID to scope sweep