@fluxerjs/core 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { REST } from '@fluxerjs/rest';
3
3
  import { WebSocketManager } from '@fluxerjs/ws';
4
- import { APIEmbed, APIUserPartial, APIRole, RESTUpdateRoleBody, APIGuildMember, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIWebhookEditMessageRequest, APIBan, APIEmoji, APISticker, APIGuildPartial, APIChannelPartial, APIInvite, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIVanityURL, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIChannelOverwrite, APIChannel, ChannelType, GatewayPresenceUpdateData, APIProfileResponse, APIApplicationCommandInteraction, APIApplicationCommandOptionValue, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayGuildMembersChunkDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayInviteDeleteDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, APIInstance, APIGatewayBotResponse, GatewaySendPayload, Routes } from '@fluxerjs/types';
4
+ import { APIAllowedMentions, APIEmbed, APIMessageReference, APIUserPartial, APIRole, RESTUpdateRoleBody, APIGuildMember, APIGuildMemberSearchRequest, APIGuildMemberSearchResponse, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIWebhookEditMessageRequest, APIBan, APIEmoji, APISticker, APIGuildPartial, APIChannelPartial, APIInvite, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIVanityURL, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageSnapshot, APIMessageCall, APIMessage, APIChannelOverwrite, APIChannel, ChannelType, APIRtcRegion, APIChannelSlowmodeState, GatewayPresenceUpdateData, APIProfileResponse, APIApplicationCommandInteraction, APIApplicationCommandOptionValue, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayGuildMembersChunkDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayInviteDeleteDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, APIInstance, APIGatewayBotResponse, GatewaySendPayload, Routes } from '@fluxerjs/types';
5
5
  import { Collection } from '@fluxerjs/collection';
6
6
  import { EmbedBuilder } from '@fluxerjs/builders';
7
7
  import { PermissionsBitField, PermissionResolvable, BitField } from '@fluxerjs/util';
@@ -31,9 +31,44 @@ interface MessageAttachmentMeta {
31
31
  /** MessageAttachmentFlags: IS_SPOILER (8), CONTAINS_EXPLICIT_MEDIA (16), IS_ANIMATED (32) */
32
32
  flags?: number;
33
33
  }
34
- /** Options for sending a message (content, embeds, files). Used by Message.send, Channel.send, ChannelManager.send.
35
- * EmbedBuilder instances are auto-converted to API format—no need to call .toJSON().
34
+ /** SDK options for allowed mentions (camelCase). Converted to APIAllowedMentions on send. */
35
+ type AllowedMentionsOptions = {
36
+ parse?: APIAllowedMentions['parse'];
37
+ users?: string[];
38
+ roles?: string[];
39
+ /** Whether to @mention and notify the author of the replied-to message. */
40
+ repliedUser?: boolean;
41
+ };
42
+ /**
43
+ * Common allowed-mentions presets.
44
+ * Use with `message.send()`, `message.reply()`, or `channel.send()`.
45
+ *
46
+ * @example
47
+ * // Reply without pinging the original author (rare in JS SDKs — Fluxer supports this)
48
+ * await message.reply('Got it!', { ping: false });
49
+ * await message.reply({ content: 'Got it!', allowedMentions: AllowedMentions.suppressReplyPing });
36
50
  */
51
+ declare const AllowedMentions: {
52
+ /** Suppress the replied-to user's @mention notification. The reply thread still appears. */
53
+ readonly suppressReplyPing: {
54
+ repliedUser: false;
55
+ };
56
+ /** Parse no mentions from content — @user, @role, and @everyone will not notify. */
57
+ readonly none: {
58
+ parse: never[];
59
+ };
60
+ /** Parse user, role, and @everyone mentions (typical default when the field is omitted). */
61
+ readonly all: {
62
+ parse: ("users" | "roles" | "everyone")[];
63
+ };
64
+ };
65
+ /** Target message for `replyTo` on send options. */
66
+ type MessageReplyTarget = {
67
+ channelId: string;
68
+ messageId: string;
69
+ guildId?: string | null;
70
+ };
71
+ /** Options for sending a message. Used by Message.send, Channel.send, ChannelManager.send. */
37
72
  type MessageSendOptions = {
38
73
  content?: string;
39
74
  /** EmbedBuilder instances are auto-converted; raw APIEmbed also supported. */
@@ -42,10 +77,28 @@ type MessageSendOptions = {
42
77
  files?: MessageFileData[];
43
78
  /** Attachment metadata for files (id = index). Use when files are provided. */
44
79
  attachments?: MessageAttachmentMeta[];
45
- /** Message flags (e.g. MessageFlags.SuppressNotifications for reply without ping). */
80
+ /** Controls which mentions trigger notifications. */
81
+ allowedMentions?: AllowedMentionsOptions;
82
+ /** Reply to a message (shows as a reply thread). Use with `ping: false` to avoid notifying the author. */
83
+ replyTo?: MessageReplyTarget;
84
+ /**
85
+ * Whether to ping the replied-to user when using `replyTo` (default `true`).
86
+ * Set `false` to reply in-thread without an @mention notification — equivalent to
87
+ * `allowedMentions: AllowedMentions.suppressReplyPing`.
88
+ */
89
+ ping?: boolean;
90
+ /** Text-to-speech message. */
91
+ tts?: boolean;
92
+ /** Sticker IDs to include (max 3). */
93
+ stickerIds?: string[];
94
+ /** Client-generated identifier for the message. */
95
+ nonce?: string;
96
+ /** ID of a favorite meme to attach. */
97
+ favoriteMemeId?: string;
98
+ /** Message flags (e.g. MessageFlags.SuppressNotifications). */
46
99
  flags?: number;
47
100
  };
48
- /** API-ready body from MessageSendOptions or text content (serializes EmbedBuilder, includes attachments when files present). */
101
+ /** API-ready body from MessageSendOptions (serializes EmbedBuilder, includes attachments when files present). */
49
102
  interface SendBodyResult {
50
103
  content?: string;
51
104
  embeds?: APIEmbed[];
@@ -56,9 +109,24 @@ interface SendBodyResult {
56
109
  description?: string | null;
57
110
  flags?: number;
58
111
  }>;
59
- /** Message flags (e.g. SuppressNotifications for reply without ping). */
112
+ allowed_mentions?: APIAllowedMentions;
113
+ message_reference?: APIMessageReference;
114
+ sticker_ids?: string[];
115
+ nonce?: string;
116
+ favorite_meme_id?: string;
117
+ tts?: boolean;
60
118
  flags?: number;
61
119
  }
120
+ /** REST post payload for POST /channels/{id}/messages. */
121
+ interface MessagePostPayload {
122
+ body: SendBodyResult;
123
+ files?: ResolvedMessageFile[];
124
+ }
125
+ /**
126
+ * Build a full message POST payload (body + optional files) from send options.
127
+ * Handles replies, reply ping suppression, embed serialization, and file resolution.
128
+ */
129
+ declare function prepareMessagePostPayload(options: string | MessageSendOptions): Promise<MessagePostPayload>;
62
130
 
63
131
  /** Base class for all Fluxer structures. Provides the client reference. */
64
132
  declare abstract class Base {
@@ -404,6 +472,14 @@ declare class GuildMemberManager extends Collection<string, GuildMember> {
404
472
  limit?: number;
405
473
  after?: string;
406
474
  }): Promise<GuildMember[]>;
475
+ /**
476
+ * Search guild members. POST /guilds/{id}/members-search.
477
+ * @param options - Search query, filters, and pagination
478
+ * @returns Search results with matching members
479
+ * @example
480
+ * const { members } = await guild.members.search({ query: 'alex', limit: 25 });
481
+ */
482
+ search(options: APIGuildMemberSearchRequest): Promise<APIGuildMemberSearchResponse>;
407
483
  }
408
484
 
409
485
  /** File data for webhook attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
@@ -429,6 +505,8 @@ interface WebhookSendOptions {
429
505
  avatar_url?: string;
430
506
  /** Text-to-speech */
431
507
  tts?: boolean;
508
+ /** Controls which mentions trigger notifications. */
509
+ allowedMentions?: AllowedMentionsOptions;
432
510
  /** File attachments. When present, uses multipart/form-data (same as channel.send). */
433
511
  files?: WebhookFileData[];
434
512
  /** Attachment metadata for files (id = index). Use when files are provided. */
@@ -1007,23 +1085,20 @@ interface MessageEditOptions {
1007
1085
  content?: string;
1008
1086
  /** New embeds (replaces existing) */
1009
1087
  embeds?: (APIEmbed | EmbedBuilder)[];
1088
+ /** Controls which mentions trigger notifications on edit. */
1089
+ allowedMentions?: AllowedMentionsOptions;
1010
1090
  }
1011
- type MessagePayload = {
1012
- files?: ResolvedMessageFile[];
1013
- body: SendBodyResult & {
1014
- message_reference?: APIMessageReference;
1015
- flags?: number;
1016
- };
1017
- };
1091
+ type MessagePayload = Awaited<ReturnType<typeof prepareMessagePostPayload>>;
1018
1092
  /** Options for message.reply() — ping toggle and reply-to-different-message. */
1019
1093
  interface ReplyOptions {
1020
- /** Whether to ping the replied-to user (default true). Use false to suppress the mention notification. */
1094
+ /**
1095
+ * Whether to ping the replied-to user (default `true`).
1096
+ * Set `false` to reply in-thread without notifying the author — one of the few JS SDKs
1097
+ * that exposes this via `allowed_mentions.replied_user` under the hood.
1098
+ */
1021
1099
  ping?: boolean;
1022
1100
  /** Reply to a different message instead of this one. Default: this message. */
1023
- replyTo?: Message | {
1024
- channelId: string;
1025
- messageId: string;
1026
- };
1101
+ replyTo?: Message | MessageReplyTarget;
1027
1102
  }
1028
1103
 
1029
1104
  /** Represents a message in a channel. */
@@ -1102,10 +1177,11 @@ declare class Message extends Base {
1102
1177
  * await message.reply('Pong!');
1103
1178
  * await message.reply({ embeds: [embed] });
1104
1179
  * await message.reply('No ping!', { ping: false });
1180
+ * await message.reply({ content: 'Silent reply', allowedMentions: AllowedMentions.suppressReplyPing });
1105
1181
  * await message.reply({ content: 'Reply to other', replyTo: otherMessage });
1106
1182
  */
1107
1183
  reply(options: string | (MessageSendOptions & ReplyOptions), replyOptions?: ReplyOptions): Promise<Message>;
1108
- /** Exposed for testing purposes, use Message.reply() or send() for normal use */
1184
+ /** Exposed for testing — prefer `message.reply()` / `prepareMessagePostPayload()`. */
1109
1185
  static _createMessageBody(content: string | MessageSendOptions, referenced_message?: {
1110
1186
  channel_id: string;
1111
1187
  message_id: string;
@@ -1203,11 +1279,23 @@ declare class Message extends Base {
1203
1279
  }): Promise<User[]>;
1204
1280
  }
1205
1281
 
1282
+ /** Options for GET /channels/{id}/messages (list/paginate). */
1283
+ interface FetchMessagesOptions {
1284
+ /** Number of messages to return (1–100, default 50). */
1285
+ limit?: number;
1286
+ /** Return messages with IDs before this snowflake. */
1287
+ before?: string;
1288
+ /** Return messages with IDs after this snowflake. */
1289
+ after?: string;
1290
+ /** Return messages around this snowflake. */
1291
+ around?: string;
1292
+ }
1206
1293
  /**
1207
1294
  * Manages messages for a channel. Access via channel.messages.
1208
1295
  * @example
1209
1296
  * const message = channel.messages.get(messageId); // from cache (if enabled)
1210
1297
  * const message = await channel.messages.fetch(messageId); // from API
1298
+ * const messages = await channel.messages.fetch({ limit: 50, before: messageId });
1211
1299
  * if (message) await message.edit({ content: 'Updated!' });
1212
1300
  */
1213
1301
  declare class MessageManager {
@@ -1228,6 +1316,16 @@ declare class MessageManager {
1228
1316
  * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
1229
1317
  */
1230
1318
  fetch(messageId: string): Promise<Message>;
1319
+ /**
1320
+ * Fetch multiple messages from this channel.
1321
+ * GET /channels/{channel_id}/messages — supports limit, before, after, and around.
1322
+ * Returns messages in reverse chronological order (newest first).
1323
+ * @param options - Pagination options
1324
+ * @returns Collection of messages keyed by message ID
1325
+ */
1326
+ fetch(options: FetchMessagesOptions): Promise<Collection<string, Message>>;
1327
+ private fetchOne;
1328
+ private fetchMany;
1231
1329
  }
1232
1330
 
1233
1331
  interface MessageCollectorOptions {
@@ -1306,6 +1404,16 @@ declare abstract class Channel extends Base {
1306
1404
  * Send a typing indicator to the channel. Lasts ~10 seconds.
1307
1405
  */
1308
1406
  sendTyping(): Promise<void>;
1407
+ /**
1408
+ * Fetch available RTC regions for voice/video in this channel.
1409
+ * GET /channels/{id}/rtc-regions
1410
+ */
1411
+ fetchRtcRegions(): Promise<APIRtcRegion[]>;
1412
+ /**
1413
+ * Fetch the current user's slowmode state in this channel.
1414
+ * GET /channels/{id}/slowmode
1415
+ */
1416
+ fetchSlowmode(): Promise<APIChannelSlowmodeState>;
1309
1417
  /**
1310
1418
  * Whether the bot can send messages in this channel.
1311
1419
  * For DMs: always true (when the channel exists).
@@ -1371,7 +1479,7 @@ declare class GuildChannel extends Channel {
1371
1479
  * Send a message to this guild channel.
1372
1480
  * Works for text and announcement channels. Voice/category/link channels will fail at the API.
1373
1481
  */
1374
- send(options: MessageSendOptions): Promise<Message>;
1482
+ send(options: string | MessageSendOptions): Promise<Message>;
1375
1483
  /**
1376
1484
  * Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
1377
1485
  */
@@ -1414,7 +1522,7 @@ declare class TextChannel extends GuildChannel {
1414
1522
  * Send a message to this channel.
1415
1523
  * @param options - Text content or object with content, embeds, and/or files
1416
1524
  */
1417
- send(options: MessageSendOptions): Promise<Message>;
1525
+ send(options: string | MessageSendOptions): Promise<Message>;
1418
1526
  /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1419
1527
  get messages(): MessageManager;
1420
1528
  /**
@@ -1466,7 +1574,7 @@ declare class DMChannel extends Channel {
1466
1574
  * Send a message to this DM channel.
1467
1575
  * @param options - Text content or object with content, embeds, and/or files
1468
1576
  */
1469
- send(options: MessageSendOptions): Promise<Message>;
1577
+ send(options: string | MessageSendOptions): Promise<Message>;
1470
1578
  /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1471
1579
  get messages(): MessageManager;
1472
1580
  /**
@@ -1618,7 +1726,11 @@ interface ClientOptions {
1618
1726
  intents?: number;
1619
1727
  /** Suppress the warning when intents are set (Fluxer does not support intents yet). */
1620
1728
  suppressIntentWarning?: boolean;
1621
- /** When true, delay the Ready event until all guilds from READY (including unavailable) have been received via GUILD_CREATE. Default: false. */
1729
+ /**
1730
+ * When true, delay the Ready event until all guilds from READY (including unavailable) have been received via GUILD_CREATE.
1731
+ * Other gateway dispatches (e.g. MESSAGE_CREATE) are queued and delivered after Ready so handlers can rely on post-Ready setup.
1732
+ * GUILD_CREATE still runs during sync so the guild cache can finish loading. Default: false.
1733
+ */
1622
1734
  waitForGuilds?: boolean;
1623
1735
  /** Cache size limits (channels, guilds, users, messages). Omit or 0 = unbounded per field—see {@link CacheSizeLimits}. */
1624
1736
  cache?: CacheSizeLimits;
@@ -1918,6 +2030,11 @@ declare class Client extends EventEmitter {
1918
2030
  _pendingGuildIds: Set<string> | null;
1919
2031
  /** Timeout for guild stream when READY has no guilds (gateway sends only GUILD_CREATE). Cleared in finally. */
1920
2032
  private _guildStreamSettleTimeout;
2033
+ /**
2034
+ * When waitForGuilds delays Ready, gateway dispatches (except GUILD_CREATE) are queued and replayed after Ready.
2035
+ * Ensures user handlers that assume post-Ready setup (e.g. DB in Ready) do not run during the guild sync window.
2036
+ */
2037
+ private _deferredGatewayDispatches;
1921
2038
  /** Per-channel message cache (channelId -> messageId -> APIMessage). Used when options.cache.messages > 0. */
1922
2039
  private _messageCaches;
1923
2040
  /** @param options - Token, REST config, WebSocket, presence, etc. */
@@ -2016,11 +2133,18 @@ declare class Client extends EventEmitter {
2016
2133
  * @param payload - Gateway payload to send
2017
2134
  */
2018
2135
  sendToGateway(shardId: number, payload: GatewaySendPayload): void;
2136
+ /**
2137
+ * While {@link ClientOptions.waitForGuilds} delays Ready, defer user-facing dispatch handling until Ready fires.
2138
+ * GUILD_CREATE must still run immediately so guild cache and {@link Client._onGuildReceived} can finish the handshake.
2139
+ */
2140
+ private _shouldDeferGatewayDispatchUntilReady;
2019
2141
  /**
2020
2142
  * Run gateway event handlers. By default (see {@link ClientOptions.gatewayDeferHandlers}) work is deferred to the next
2021
2143
  * macrotask so user code does not block the WebSocket `message` callback.
2022
2144
  */
2023
2145
  private handleDispatch;
2146
+ private _dispatchGatewayPayload;
2147
+ private _flushDeferredGatewayDispatches;
2024
2148
  /**
2025
2149
  * Connect to the Fluxer gateway and authenticate.
2026
2150
  * @param token - Bot token (e.g. from FLUXER_BOT_TOKEN)
@@ -2052,4 +2176,4 @@ declare class Client extends EventEmitter {
2052
2176
  static get Routes(): typeof Routes;
2053
2177
  }
2054
2178
 
2055
- export { type AnyInteraction as A, Base as B, type CacheSizeLimits as C, DMChannel as D, Events as E, type FetchedUserWithProfile as F, Guild as G, type ReactionCollectorOptions as H, Invite as I, type ReplyOptions as J, Role as K, LinkChannel as L, Message as M, type RoleResolvable as N, UsersManager as O, type PartialMessage as P, type WebhookMessageEditOptions as Q, ReactionCollector as R, type WebhookSendOptions as S, TextChannel as T, User as U, VoiceChannel as V, Webhook as W, createInteraction as X, isChatInputCommandInteraction as Y, BaseInteraction as a, CategoryChannel as b, Channel as c, ChannelManager as d, ChatInputCommandInteraction as e, Client as f, type ClientEventMethods as g, type ClientEvents as h, type ClientOptions as i, ClientUser as j, type CollectedReaction as k, GuildBan as l, GuildChannel as m, GuildEmoji as n, GuildMember as o, GuildMemberManager as p, GuildMemberRoleManager as q, GuildSticker as r, MessageCollector as s, type MessageCollectorEndReason as t, type MessageCollectorOptions as u, type MessageEditOptions as v, MessageManager as w, MessageReaction as x, type MessageSendOptions as y, type ReactionCollectorEndReason as z };
2179
+ export { createInteraction as $, AllowedMentions as A, Base as B, type CacheSizeLimits as C, DMChannel as D, Events as E, type FetchMessagesOptions as F, Guild as G, MessageReaction as H, Invite as I, type MessageReplyTarget as J, type MessageSendOptions as K, LinkChannel as L, Message as M, type ReactionCollectorEndReason as N, type ReactionCollectorOptions as O, type PartialMessage as P, type ReplyOptions as Q, ReactionCollector as R, Role as S, type RoleResolvable as T, TextChannel as U, User as V, UsersManager as W, VoiceChannel as X, Webhook as Y, type WebhookMessageEditOptions as Z, type WebhookSendOptions as _, type AllowedMentionsOptions as a, isChatInputCommandInteraction as a0, type AnyInteraction as b, BaseInteraction as c, CategoryChannel as d, Channel as e, ChannelManager as f, ChatInputCommandInteraction as g, Client as h, type ClientEventMethods as i, type ClientEvents as j, type ClientOptions as k, ClientUser as l, type CollectedReaction as m, type FetchedUserWithProfile as n, GuildBan as o, GuildChannel as p, GuildEmoji as q, GuildMember as r, GuildMemberManager as s, GuildMemberRoleManager as t, GuildSticker as u, MessageCollector as v, type MessageCollectorEndReason as w, type MessageCollectorOptions as x, type MessageEditOptions as y, MessageManager as z };
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { REST } from '@fluxerjs/rest';
3
3
  import { WebSocketManager } from '@fluxerjs/ws';
4
- import { APIEmbed, APIUserPartial, APIRole, RESTUpdateRoleBody, APIGuildMember, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIWebhookEditMessageRequest, APIBan, APIEmoji, APISticker, APIGuildPartial, APIChannelPartial, APIInvite, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIVanityURL, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIChannelOverwrite, APIChannel, ChannelType, GatewayPresenceUpdateData, APIProfileResponse, APIApplicationCommandInteraction, APIApplicationCommandOptionValue, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayGuildMembersChunkDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayInviteDeleteDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, APIInstance, APIGatewayBotResponse, GatewaySendPayload, Routes } from '@fluxerjs/types';
4
+ import { APIAllowedMentions, APIEmbed, APIMessageReference, APIUserPartial, APIRole, RESTUpdateRoleBody, APIGuildMember, APIGuildMemberSearchRequest, APIGuildMemberSearchResponse, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIWebhookEditMessageRequest, APIBan, APIEmoji, APISticker, APIGuildPartial, APIChannelPartial, APIInvite, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIVanityURL, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageSnapshot, APIMessageCall, APIMessage, APIChannelOverwrite, APIChannel, ChannelType, APIRtcRegion, APIChannelSlowmodeState, GatewayPresenceUpdateData, APIProfileResponse, APIApplicationCommandInteraction, APIApplicationCommandOptionValue, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayGuildMembersChunkDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayInviteDeleteDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, APIInstance, APIGatewayBotResponse, GatewaySendPayload, Routes } from '@fluxerjs/types';
5
5
  import { Collection } from '@fluxerjs/collection';
6
6
  import { EmbedBuilder } from '@fluxerjs/builders';
7
7
  import { PermissionsBitField, PermissionResolvable, BitField } from '@fluxerjs/util';
@@ -31,9 +31,44 @@ interface MessageAttachmentMeta {
31
31
  /** MessageAttachmentFlags: IS_SPOILER (8), CONTAINS_EXPLICIT_MEDIA (16), IS_ANIMATED (32) */
32
32
  flags?: number;
33
33
  }
34
- /** Options for sending a message (content, embeds, files). Used by Message.send, Channel.send, ChannelManager.send.
35
- * EmbedBuilder instances are auto-converted to API format—no need to call .toJSON().
34
+ /** SDK options for allowed mentions (camelCase). Converted to APIAllowedMentions on send. */
35
+ type AllowedMentionsOptions = {
36
+ parse?: APIAllowedMentions['parse'];
37
+ users?: string[];
38
+ roles?: string[];
39
+ /** Whether to @mention and notify the author of the replied-to message. */
40
+ repliedUser?: boolean;
41
+ };
42
+ /**
43
+ * Common allowed-mentions presets.
44
+ * Use with `message.send()`, `message.reply()`, or `channel.send()`.
45
+ *
46
+ * @example
47
+ * // Reply without pinging the original author (rare in JS SDKs — Fluxer supports this)
48
+ * await message.reply('Got it!', { ping: false });
49
+ * await message.reply({ content: 'Got it!', allowedMentions: AllowedMentions.suppressReplyPing });
36
50
  */
51
+ declare const AllowedMentions: {
52
+ /** Suppress the replied-to user's @mention notification. The reply thread still appears. */
53
+ readonly suppressReplyPing: {
54
+ repliedUser: false;
55
+ };
56
+ /** Parse no mentions from content — @user, @role, and @everyone will not notify. */
57
+ readonly none: {
58
+ parse: never[];
59
+ };
60
+ /** Parse user, role, and @everyone mentions (typical default when the field is omitted). */
61
+ readonly all: {
62
+ parse: ("users" | "roles" | "everyone")[];
63
+ };
64
+ };
65
+ /** Target message for `replyTo` on send options. */
66
+ type MessageReplyTarget = {
67
+ channelId: string;
68
+ messageId: string;
69
+ guildId?: string | null;
70
+ };
71
+ /** Options for sending a message. Used by Message.send, Channel.send, ChannelManager.send. */
37
72
  type MessageSendOptions = {
38
73
  content?: string;
39
74
  /** EmbedBuilder instances are auto-converted; raw APIEmbed also supported. */
@@ -42,10 +77,28 @@ type MessageSendOptions = {
42
77
  files?: MessageFileData[];
43
78
  /** Attachment metadata for files (id = index). Use when files are provided. */
44
79
  attachments?: MessageAttachmentMeta[];
45
- /** Message flags (e.g. MessageFlags.SuppressNotifications for reply without ping). */
80
+ /** Controls which mentions trigger notifications. */
81
+ allowedMentions?: AllowedMentionsOptions;
82
+ /** Reply to a message (shows as a reply thread). Use with `ping: false` to avoid notifying the author. */
83
+ replyTo?: MessageReplyTarget;
84
+ /**
85
+ * Whether to ping the replied-to user when using `replyTo` (default `true`).
86
+ * Set `false` to reply in-thread without an @mention notification — equivalent to
87
+ * `allowedMentions: AllowedMentions.suppressReplyPing`.
88
+ */
89
+ ping?: boolean;
90
+ /** Text-to-speech message. */
91
+ tts?: boolean;
92
+ /** Sticker IDs to include (max 3). */
93
+ stickerIds?: string[];
94
+ /** Client-generated identifier for the message. */
95
+ nonce?: string;
96
+ /** ID of a favorite meme to attach. */
97
+ favoriteMemeId?: string;
98
+ /** Message flags (e.g. MessageFlags.SuppressNotifications). */
46
99
  flags?: number;
47
100
  };
48
- /** API-ready body from MessageSendOptions or text content (serializes EmbedBuilder, includes attachments when files present). */
101
+ /** API-ready body from MessageSendOptions (serializes EmbedBuilder, includes attachments when files present). */
49
102
  interface SendBodyResult {
50
103
  content?: string;
51
104
  embeds?: APIEmbed[];
@@ -56,9 +109,24 @@ interface SendBodyResult {
56
109
  description?: string | null;
57
110
  flags?: number;
58
111
  }>;
59
- /** Message flags (e.g. SuppressNotifications for reply without ping). */
112
+ allowed_mentions?: APIAllowedMentions;
113
+ message_reference?: APIMessageReference;
114
+ sticker_ids?: string[];
115
+ nonce?: string;
116
+ favorite_meme_id?: string;
117
+ tts?: boolean;
60
118
  flags?: number;
61
119
  }
120
+ /** REST post payload for POST /channels/{id}/messages. */
121
+ interface MessagePostPayload {
122
+ body: SendBodyResult;
123
+ files?: ResolvedMessageFile[];
124
+ }
125
+ /**
126
+ * Build a full message POST payload (body + optional files) from send options.
127
+ * Handles replies, reply ping suppression, embed serialization, and file resolution.
128
+ */
129
+ declare function prepareMessagePostPayload(options: string | MessageSendOptions): Promise<MessagePostPayload>;
62
130
 
63
131
  /** Base class for all Fluxer structures. Provides the client reference. */
64
132
  declare abstract class Base {
@@ -404,6 +472,14 @@ declare class GuildMemberManager extends Collection<string, GuildMember> {
404
472
  limit?: number;
405
473
  after?: string;
406
474
  }): Promise<GuildMember[]>;
475
+ /**
476
+ * Search guild members. POST /guilds/{id}/members-search.
477
+ * @param options - Search query, filters, and pagination
478
+ * @returns Search results with matching members
479
+ * @example
480
+ * const { members } = await guild.members.search({ query: 'alex', limit: 25 });
481
+ */
482
+ search(options: APIGuildMemberSearchRequest): Promise<APIGuildMemberSearchResponse>;
407
483
  }
408
484
 
409
485
  /** File data for webhook attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
@@ -429,6 +505,8 @@ interface WebhookSendOptions {
429
505
  avatar_url?: string;
430
506
  /** Text-to-speech */
431
507
  tts?: boolean;
508
+ /** Controls which mentions trigger notifications. */
509
+ allowedMentions?: AllowedMentionsOptions;
432
510
  /** File attachments. When present, uses multipart/form-data (same as channel.send). */
433
511
  files?: WebhookFileData[];
434
512
  /** Attachment metadata for files (id = index). Use when files are provided. */
@@ -1007,23 +1085,20 @@ interface MessageEditOptions {
1007
1085
  content?: string;
1008
1086
  /** New embeds (replaces existing) */
1009
1087
  embeds?: (APIEmbed | EmbedBuilder)[];
1088
+ /** Controls which mentions trigger notifications on edit. */
1089
+ allowedMentions?: AllowedMentionsOptions;
1010
1090
  }
1011
- type MessagePayload = {
1012
- files?: ResolvedMessageFile[];
1013
- body: SendBodyResult & {
1014
- message_reference?: APIMessageReference;
1015
- flags?: number;
1016
- };
1017
- };
1091
+ type MessagePayload = Awaited<ReturnType<typeof prepareMessagePostPayload>>;
1018
1092
  /** Options for message.reply() — ping toggle and reply-to-different-message. */
1019
1093
  interface ReplyOptions {
1020
- /** Whether to ping the replied-to user (default true). Use false to suppress the mention notification. */
1094
+ /**
1095
+ * Whether to ping the replied-to user (default `true`).
1096
+ * Set `false` to reply in-thread without notifying the author — one of the few JS SDKs
1097
+ * that exposes this via `allowed_mentions.replied_user` under the hood.
1098
+ */
1021
1099
  ping?: boolean;
1022
1100
  /** Reply to a different message instead of this one. Default: this message. */
1023
- replyTo?: Message | {
1024
- channelId: string;
1025
- messageId: string;
1026
- };
1101
+ replyTo?: Message | MessageReplyTarget;
1027
1102
  }
1028
1103
 
1029
1104
  /** Represents a message in a channel. */
@@ -1102,10 +1177,11 @@ declare class Message extends Base {
1102
1177
  * await message.reply('Pong!');
1103
1178
  * await message.reply({ embeds: [embed] });
1104
1179
  * await message.reply('No ping!', { ping: false });
1180
+ * await message.reply({ content: 'Silent reply', allowedMentions: AllowedMentions.suppressReplyPing });
1105
1181
  * await message.reply({ content: 'Reply to other', replyTo: otherMessage });
1106
1182
  */
1107
1183
  reply(options: string | (MessageSendOptions & ReplyOptions), replyOptions?: ReplyOptions): Promise<Message>;
1108
- /** Exposed for testing purposes, use Message.reply() or send() for normal use */
1184
+ /** Exposed for testing — prefer `message.reply()` / `prepareMessagePostPayload()`. */
1109
1185
  static _createMessageBody(content: string | MessageSendOptions, referenced_message?: {
1110
1186
  channel_id: string;
1111
1187
  message_id: string;
@@ -1203,11 +1279,23 @@ declare class Message extends Base {
1203
1279
  }): Promise<User[]>;
1204
1280
  }
1205
1281
 
1282
+ /** Options for GET /channels/{id}/messages (list/paginate). */
1283
+ interface FetchMessagesOptions {
1284
+ /** Number of messages to return (1–100, default 50). */
1285
+ limit?: number;
1286
+ /** Return messages with IDs before this snowflake. */
1287
+ before?: string;
1288
+ /** Return messages with IDs after this snowflake. */
1289
+ after?: string;
1290
+ /** Return messages around this snowflake. */
1291
+ around?: string;
1292
+ }
1206
1293
  /**
1207
1294
  * Manages messages for a channel. Access via channel.messages.
1208
1295
  * @example
1209
1296
  * const message = channel.messages.get(messageId); // from cache (if enabled)
1210
1297
  * const message = await channel.messages.fetch(messageId); // from API
1298
+ * const messages = await channel.messages.fetch({ limit: 50, before: messageId });
1211
1299
  * if (message) await message.edit({ content: 'Updated!' });
1212
1300
  */
1213
1301
  declare class MessageManager {
@@ -1228,6 +1316,16 @@ declare class MessageManager {
1228
1316
  * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
1229
1317
  */
1230
1318
  fetch(messageId: string): Promise<Message>;
1319
+ /**
1320
+ * Fetch multiple messages from this channel.
1321
+ * GET /channels/{channel_id}/messages — supports limit, before, after, and around.
1322
+ * Returns messages in reverse chronological order (newest first).
1323
+ * @param options - Pagination options
1324
+ * @returns Collection of messages keyed by message ID
1325
+ */
1326
+ fetch(options: FetchMessagesOptions): Promise<Collection<string, Message>>;
1327
+ private fetchOne;
1328
+ private fetchMany;
1231
1329
  }
1232
1330
 
1233
1331
  interface MessageCollectorOptions {
@@ -1306,6 +1404,16 @@ declare abstract class Channel extends Base {
1306
1404
  * Send a typing indicator to the channel. Lasts ~10 seconds.
1307
1405
  */
1308
1406
  sendTyping(): Promise<void>;
1407
+ /**
1408
+ * Fetch available RTC regions for voice/video in this channel.
1409
+ * GET /channels/{id}/rtc-regions
1410
+ */
1411
+ fetchRtcRegions(): Promise<APIRtcRegion[]>;
1412
+ /**
1413
+ * Fetch the current user's slowmode state in this channel.
1414
+ * GET /channels/{id}/slowmode
1415
+ */
1416
+ fetchSlowmode(): Promise<APIChannelSlowmodeState>;
1309
1417
  /**
1310
1418
  * Whether the bot can send messages in this channel.
1311
1419
  * For DMs: always true (when the channel exists).
@@ -1371,7 +1479,7 @@ declare class GuildChannel extends Channel {
1371
1479
  * Send a message to this guild channel.
1372
1480
  * Works for text and announcement channels. Voice/category/link channels will fail at the API.
1373
1481
  */
1374
- send(options: MessageSendOptions): Promise<Message>;
1482
+ send(options: string | MessageSendOptions): Promise<Message>;
1375
1483
  /**
1376
1484
  * Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
1377
1485
  */
@@ -1414,7 +1522,7 @@ declare class TextChannel extends GuildChannel {
1414
1522
  * Send a message to this channel.
1415
1523
  * @param options - Text content or object with content, embeds, and/or files
1416
1524
  */
1417
- send(options: MessageSendOptions): Promise<Message>;
1525
+ send(options: string | MessageSendOptions): Promise<Message>;
1418
1526
  /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1419
1527
  get messages(): MessageManager;
1420
1528
  /**
@@ -1466,7 +1574,7 @@ declare class DMChannel extends Channel {
1466
1574
  * Send a message to this DM channel.
1467
1575
  * @param options - Text content or object with content, embeds, and/or files
1468
1576
  */
1469
- send(options: MessageSendOptions): Promise<Message>;
1577
+ send(options: string | MessageSendOptions): Promise<Message>;
1470
1578
  /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1471
1579
  get messages(): MessageManager;
1472
1580
  /**
@@ -1618,7 +1726,11 @@ interface ClientOptions {
1618
1726
  intents?: number;
1619
1727
  /** Suppress the warning when intents are set (Fluxer does not support intents yet). */
1620
1728
  suppressIntentWarning?: boolean;
1621
- /** When true, delay the Ready event until all guilds from READY (including unavailable) have been received via GUILD_CREATE. Default: false. */
1729
+ /**
1730
+ * When true, delay the Ready event until all guilds from READY (including unavailable) have been received via GUILD_CREATE.
1731
+ * Other gateway dispatches (e.g. MESSAGE_CREATE) are queued and delivered after Ready so handlers can rely on post-Ready setup.
1732
+ * GUILD_CREATE still runs during sync so the guild cache can finish loading. Default: false.
1733
+ */
1622
1734
  waitForGuilds?: boolean;
1623
1735
  /** Cache size limits (channels, guilds, users, messages). Omit or 0 = unbounded per field—see {@link CacheSizeLimits}. */
1624
1736
  cache?: CacheSizeLimits;
@@ -1918,6 +2030,11 @@ declare class Client extends EventEmitter {
1918
2030
  _pendingGuildIds: Set<string> | null;
1919
2031
  /** Timeout for guild stream when READY has no guilds (gateway sends only GUILD_CREATE). Cleared in finally. */
1920
2032
  private _guildStreamSettleTimeout;
2033
+ /**
2034
+ * When waitForGuilds delays Ready, gateway dispatches (except GUILD_CREATE) are queued and replayed after Ready.
2035
+ * Ensures user handlers that assume post-Ready setup (e.g. DB in Ready) do not run during the guild sync window.
2036
+ */
2037
+ private _deferredGatewayDispatches;
1921
2038
  /** Per-channel message cache (channelId -> messageId -> APIMessage). Used when options.cache.messages > 0. */
1922
2039
  private _messageCaches;
1923
2040
  /** @param options - Token, REST config, WebSocket, presence, etc. */
@@ -2016,11 +2133,18 @@ declare class Client extends EventEmitter {
2016
2133
  * @param payload - Gateway payload to send
2017
2134
  */
2018
2135
  sendToGateway(shardId: number, payload: GatewaySendPayload): void;
2136
+ /**
2137
+ * While {@link ClientOptions.waitForGuilds} delays Ready, defer user-facing dispatch handling until Ready fires.
2138
+ * GUILD_CREATE must still run immediately so guild cache and {@link Client._onGuildReceived} can finish the handshake.
2139
+ */
2140
+ private _shouldDeferGatewayDispatchUntilReady;
2019
2141
  /**
2020
2142
  * Run gateway event handlers. By default (see {@link ClientOptions.gatewayDeferHandlers}) work is deferred to the next
2021
2143
  * macrotask so user code does not block the WebSocket `message` callback.
2022
2144
  */
2023
2145
  private handleDispatch;
2146
+ private _dispatchGatewayPayload;
2147
+ private _flushDeferredGatewayDispatches;
2024
2148
  /**
2025
2149
  * Connect to the Fluxer gateway and authenticate.
2026
2150
  * @param token - Bot token (e.g. from FLUXER_BOT_TOKEN)
@@ -2052,4 +2176,4 @@ declare class Client extends EventEmitter {
2052
2176
  static get Routes(): typeof Routes;
2053
2177
  }
2054
2178
 
2055
- export { type AnyInteraction as A, Base as B, type CacheSizeLimits as C, DMChannel as D, Events as E, type FetchedUserWithProfile as F, Guild as G, type ReactionCollectorOptions as H, Invite as I, type ReplyOptions as J, Role as K, LinkChannel as L, Message as M, type RoleResolvable as N, UsersManager as O, type PartialMessage as P, type WebhookMessageEditOptions as Q, ReactionCollector as R, type WebhookSendOptions as S, TextChannel as T, User as U, VoiceChannel as V, Webhook as W, createInteraction as X, isChatInputCommandInteraction as Y, BaseInteraction as a, CategoryChannel as b, Channel as c, ChannelManager as d, ChatInputCommandInteraction as e, Client as f, type ClientEventMethods as g, type ClientEvents as h, type ClientOptions as i, ClientUser as j, type CollectedReaction as k, GuildBan as l, GuildChannel as m, GuildEmoji as n, GuildMember as o, GuildMemberManager as p, GuildMemberRoleManager as q, GuildSticker as r, MessageCollector as s, type MessageCollectorEndReason as t, type MessageCollectorOptions as u, type MessageEditOptions as v, MessageManager as w, MessageReaction as x, type MessageSendOptions as y, type ReactionCollectorEndReason as z };
2179
+ export { createInteraction as $, AllowedMentions as A, Base as B, type CacheSizeLimits as C, DMChannel as D, Events as E, type FetchMessagesOptions as F, Guild as G, MessageReaction as H, Invite as I, type MessageReplyTarget as J, type MessageSendOptions as K, LinkChannel as L, Message as M, type ReactionCollectorEndReason as N, type ReactionCollectorOptions as O, type PartialMessage as P, type ReplyOptions as Q, ReactionCollector as R, Role as S, type RoleResolvable as T, TextChannel as U, User as V, UsersManager as W, VoiceChannel as X, Webhook as Y, type WebhookMessageEditOptions as Z, type WebhookSendOptions as _, type AllowedMentionsOptions as a, isChatInputCommandInteraction as a0, type AnyInteraction as b, BaseInteraction as c, CategoryChannel as d, Channel as e, ChannelManager as f, ChatInputCommandInteraction as g, Client as h, type ClientEventMethods as i, type ClientEvents as j, type ClientOptions as k, ClientUser as l, type CollectedReaction as m, type FetchedUserWithProfile as n, GuildBan as o, GuildChannel as p, GuildEmoji as q, GuildMember as r, GuildMemberManager as s, GuildMemberRoleManager as t, GuildSticker as u, MessageCollector as v, type MessageCollectorEndReason as w, type MessageCollectorOptions as x, type MessageEditOptions as y, MessageManager as z };