Client
Main Fluxer bot client. Connects to the gateway, emits events, and provides REST access.
Extends EventEmitter
Constructor
(options: ClientOptions)| Param | Type | Description |
|---|---|---|
| options | ClientOptions |
Properties
: CacheController (readonly)Cache limits, stats, sweeps, and cascade entry points.
: ChannelManager (readonly)Channel cache and manager.
: ClientEventMethods (readonly)Typed event handlers. Prefer `client.events.*` or `client.on(Events.*, ...)`.
: GuildManager (readonly)Guild cache and manager.
: ResolvedInstance (readonly)Resolved instance endpoints (API, CDN, invite, …) for this client. Isolated per client — safe for multi-instance processes.
: Logger (readonly)Structured logger (zero-dep).
: ClientOptions (readonly)Resolved client options (cache defaults applied).
: PackManager (readonly)Emoji/sticker pack REST wrappers (`/packs/*`).
: Date | nullTimestamp when the client became ready. Null until READY is received.
: REST (readonly)REST client for making API requests.
: any (readonly): ClientUser | nullThe authenticated bot user. Null until READY is received.
: UserManager (readonly)User cache and manager.
: WebSocketManager (readonly)The underlying WebSocketManager (throws if not logged in).
Methods
(): voidAssertion that client is ready (throws if not).
(requests: BulkFetchMessagesRequest[], options?: BulkFetchMessagesOptions & { hydrate?: true }): Promise<BulkFetchMessagesResult>| Param | Type | Description |
|---|---|---|
| requests | BulkFetchMessagesRequest[] | |
| options? | BulkFetchMessagesOptions & { hydrate?: true } |
(requests: BulkFetchMessagesRequest[], options: BulkFetchMessagesOptions & { hydrate: false }): Promise<APIBulkMessageFetchResponse>| Param | Type | Description |
|---|---|---|
| requests | BulkFetchMessagesRequest[] | |
| options | BulkFetchMessagesOptions & { hydrate: false } |
(requests: BulkFetchMessagesRequest[], options: BulkFetchMessagesOptions): Promise<BulkFetchMessagesResult | APIBulkMessageFetchResponse>| Param | Type | Description |
|---|---|---|
| requests | BulkFetchMessagesRequest[] | |
| options | BulkFetchMessagesOptions |
(username: string, discriminator: string): Promise<APIUserTagCheck>Check username#discriminator availability.
| Param | Type | Description |
|---|---|---|
| username | string | Username to check |
| discriminator | string | Discriminator to check |
(): Promise<void>Disconnect from gateway, clear all caches, and reset state.
Safe to call login again after destroy.
(event: , args: ClientEvents[]): booleanEmit an event with typed arguments.
| Param | Type | Description |
|---|---|---|
| event | K | |
| args | ClientEvents[] |
(event: string | symbol, args: unknown[]): boolean| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| args | unknown[] |
(event: string | symbol, args: unknown[]): boolean| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| args | unknown[] |
(): Promise<APIApplicationMe>Fetch the current application (`/applications/@me`).
(emojiId: string): Promise<APIEmojiMetadata>Fetch emoji metadata by ID.
| Param | Type | Description |
|---|---|---|
| emojiId | string | Emoji snowflake |
(): Promise<APIGatewayBotResponse>Fetch gateway connection info (`/gateway`).
(): Promise<APIInstance>Fetch instance discovery document (`/.well-known/fluxer`).
(): Promise<APIOAuthApplication[]>Fetch OAuth2 applications owned by this bot.
(stickerId: string): Promise<APIStickerMetadata>Fetch sticker metadata by ID.
| Param | Type | Description |
|---|---|---|
| stickerId | string | Sticker snowflake |
(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.
| Param | Type | Description |
|---|---|---|
| origin | DiscoveryOrigin | API 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 |
(data: APIUserPartial): UserGet or create a User from partial API data (hydrates cache).
| Param | Type | Description |
|---|---|---|
| data | APIUserPartial | Partial user data from API |
(): booleanType guard for ready state (narrows `client.user` to non-null).
(token: string, options?: { signal?: AbortSignal; }): Promise<string>Connect to the gateway with a bot token.
| Param | Type | Description |
|---|---|---|
| token | string | Bot token from the developer portal |
| options? | { signal?: AbortSignal; } | Optional abort signal for cancellation |
(event: , listener: ClientEventListener<>): thisRemove an event listener for a specific event type.
| Param | Type | Description |
|---|---|---|
| event | K | |
| listener | ClientEventListener<> |
(event: string | symbol, listener: (...args: unknown[]) => void): this| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| listener | (...args: unknown[]) => void |
(event: string | symbol, listener: (...args: unknown[]) => void): this| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| listener | (...args: unknown[]) => void |
(event: , listener: ClientEventListener<>): thisRegister an event listener for a specific event type.
| Param | Type | Description |
|---|---|---|
| event | K | |
| listener | ClientEventListener<> |
(event: string | symbol, listener: (...args: unknown[]) => void): this| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| listener | (...args: unknown[]) => void |
(event: string | symbol, listener: (...args: unknown[]) => void): this| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| listener | (...args: unknown[]) => void |
(event: , listener: ClientEventListener<>): thisRegister a one-time event listener for a specific event type.
| Param | Type | Description |
|---|---|---|
| event | K | |
| listener | ClientEventListener<> |
(event: string | symbol, listener: (...args: unknown[]) => void): this| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| listener | (...args: unknown[]) => void |
(event: string | symbol, listener: (...args: unknown[]) => void): this| Param | Type | Description |
|---|---|---|
| event | string | symbol | |
| listener | (...args: unknown[]) => void |
(channelIds: string[]): Promise<APIPreloadMessagesResponse>Preload recent messages for multiple channels (batch endpoint).
| Param | Type | Description |
|---|---|---|
| channelIds | string[] | Array of channel IDs to preload |
(channelIds: string[]): Promise<APIPreloadMessagesResponse>Preload recent messages (alternate endpoint).
| Param | Type | Description |
|---|---|---|
| channelIds | string[] | Array of channel IDs to preload |
(options: { guildId?: string; guildIds?: string[]; query?: string; limit?: number; userIds?: string[]; presences?: boolean; nonce?: string; }): voidRequest guild members via gateway opcode 8 (`GUILD_MEMBERS_CHUNK` responses). Provide `guildId` and/or `guildIds`.
| Param | Type | Description |
|---|---|---|
| options | { guildId?: string; guildIds?: string[]; query?: string; limit?: number; userIds?: string[]; presences?: boolean; nonce?: string; } |
(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).
| Param | Type | Description |
|---|---|---|
| emoji | string | { name: string; id?: string; animated?: boolean } | Emoji string or object with name/id/animated |
| guildId? | string | null | Guild ID for custom emoji lookup (optional) |
(shardId: number, payload: GatewaySendPayload): voidSend a gateway payload to a specific shard.
| Param | Type | Description |
|---|---|---|
| shardId | number | Shard ID (0-indexed) |
| payload | GatewaySendPayload | Gateway send payload (opcode + data) |
(filter?: (member: GuildMember, guildId: string) => boolean): numberSweep cached members across all guilds (remove entries matching filter). Prefer CacheController (`client.cache.sweepMembers`).
| Param | Type | Description |
|---|---|---|
| filter? | (member: GuildMember, guildId: string) => boolean | Predicate to test each member (return true to remove) |
(filter?: (message: APIMessage, channelId: string) => boolean, channelId?: string): numberSweep cached messages (remove entries matching filter). Prefer CacheController (`client.cache.sweepMessages`).
| Param | Type | Description |
|---|---|---|
| filter? | (message: APIMessage, channelId: string) => boolean | Predicate to test each message (return true to remove) |
| channelId? | string | Optional channel ID to scope sweep |