.assertReady()
→ void
Assertion that client is ready (throws if not).
client.assertReady();Class
Main Fluxer bot client. Connects to the gateway, emits events, and provides REST access.
Extends EventEmitter
new Client(options: ClientOptions)ClientOptions| Name | Type | Description |
|---|---|---|
| cacheread-only | CacheController | Cache limits, stats, sweeps, and cascade entry points. |
| channelsread-only | ChannelManager | Channel cache and manager. |
| eventsread-only | ClientEventMethods | Typed event handlers. Prefer client.on(Events.*, ...). |
| guildsread-only | GuildManager | Guild cache and manager. |
| instanceread-only | ResolvedInstance | Resolved instance endpoints (API, CDN, invite, …) for this client. Isolated per client — safe for multi-instance processes. |
| loggerread-only | Logger | Structured logger (zero-dep). |
| optionsread-only | ClientOptions | Resolved client options (cache defaults applied). |
| readyAt | Date | null | Timestamp when the client became ready. Null until READY is received. |
| restread-only | REST | REST client for making API requests. |
| Routesstaticread-only | typeof Routes | REST path helpers (Routes). Pass the path to client.rest. Prefer high-level helpers (channel.send(), guild.members.fetch()) when they exist. |
| uptimeread-only | number | null | Milliseconds since readyAt, or null if the client is not ready. |
| user | ClientUser | null | The authenticated bot user. Null until READY is received. |
| usersread-only | UserManager | User cache and manager. |
| wsread-only | WebSocketManager | The underlying WebSocketManager (throws if not logged in). Gateway heartbeat ACK latency: client.ws.ping (ms, or -1 before the first ACK). |
→ void
Assertion that client is ready (throws if not).
client.assertReady();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);→ Promise<void>
Disconnect from gateway, clear all caches, and reset state. Safe to call login again after destroy.
await client.destroy();event: K, args: ClientEvents[K] → boolean
event: string | symbol, args: unknown[] → boolean
Emit an event with typed arguments.
client.emit(event, args);→ Promise<APIApplicationMe>
Fetch the current application (/applications/@me).
client.fetchApplication();emojiId: string → Promise<APIEmojiMetadata>
Fetch emoji metadata by ID.
stringEmoji snowflakeclient.fetchEmojiMetadata(emojiId);→ Promise<APIGatewayBotResponse>
Fetch gateway connection info (/gateway).
client.fetchGatewayInfo();→ Promise<APIInstance>
Fetch instance discovery document (/.well-known/fluxer).
client.fetchInstance();→ 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();stickerId: string → Promise<APIStickerMetadata>
Fetch sticker metadata by ID.
stringSticker snowflakeclient.fetchStickerMetadata(stickerId);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.
DiscoveryOriginAPI origin used only to fetch discovery (e.g. https://api.example.com)Omit<ClientOptions, 'instance'>Client options (must not conflict with discovered endpoints.api){ signal?: AbortSignal; }Optional abort signal for the discovery requestawait Client.fromDiscovery(origin, options);→ boolean
Type guard for ready state (narrows client.user to non-null).
client.isReady();token: string, options?: { signal?: AbortSignal; } → Promise<this>
Connect to the gateway with a bot token.
stringBot token from the developer portal{ signal?: AbortSignal; }Optional abort signal for cancellationconst client = new Client();
client.on(Events.Ready, () => console.log('Ready!'));
await client.login(process.env.FLUXER_BOT_TOKEN);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);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);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);channelIds: string[] → Promise<APIPreloadMessagesResponse>
Preload recent messages for multiple channels (batch endpoint). Prefer this over bulkFetchMessages for bots (bulkFetchMessages is user-account only).
client.preloadMessages(channelIds);channelIds: string[] → Promise<APIPreloadMessagesResponse>
Preload recent messages (alternate endpoint). Prefer this over bulkFetchMessages for bots.
client.preloadMessagesAlt(channelIds);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);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);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);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).
string | { name: string; id?: string; animated?: boolean }Emoji string or object with name/id/animatedstring | nullGuild ID for custom emoji lookup (optional)await client.resolveEmoji(emoji);options?: MessageSearchOptions → Promise<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();shardId: number, payload: GatewaySendPayload → void
Send a gateway payload to a specific shard.
numberShard ID (0-indexed)GatewaySendPayloadGateway send payload (opcode + data)client.sendToGateway(shardId, payload);filter?: (member: GuildMember, guildId: string) => boolean → number
Sweep cached members across all guilds (remove entries matching filter). Prefer CacheController.sweepMembers (client.cache.sweepMembers).
(member: GuildMember, guildId: string) => booleanPredicate to test each member (return true to remove)client.sweepMembers();filter?: (message: Message, channelId: string) => boolean, channelId?: string → number
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.
(message: Message, channelId: string) => booleanPredicate to test each message (return true to remove)stringOptional channel ID to scope sweepclient.sweepMessages();