@fluxerjs/core 1.2.4 → 1.3.1

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.
package/dist/index.d.ts CHANGED
@@ -1,1941 +1,11 @@
1
- import { EventEmitter } from 'events';
2
- import { REST } from '@fluxerjs/rest';
3
- import { WebSocketManager } from '@fluxerjs/ws';
4
- import { APIEmbed, APIUserPartial, APIRole, RESTUpdateRoleBody, APIGuildMember, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIBan, APIEmoji, APISticker, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIVanityURL, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIGuildPartial, APIChannelPartial, APIInvite, APIChannelOverwrite, APIChannel, ChannelType, GatewayPresenceUpdateData, APIProfileResponse, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, APIApplicationCommandInteraction, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayInviteDeleteDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, APIInstance, GatewaySendPayload, Routes } from '@fluxerjs/types';
5
- export { GatewayOpcodes, MessageAttachmentFlags, Routes } from '@fluxerjs/types';
6
- import { Collection } from '@fluxerjs/collection';
7
- import { EmbedBuilder } from '@fluxerjs/builders';
1
+ export { A as AnyInteraction, B as Base, a as BaseInteraction, C as CacheSizeLimits, b as CategoryChannel, c as Channel, d as ChannelManager, e as ChatInputCommandInteraction, f as Client, g as ClientEventMethods, h as ClientEvents, i as ClientOptions, j as ClientUser, k as CollectedReaction, D as DMChannel, E as Events, F as FetchedUserWithProfile, G as Guild, l as GuildBan, m as GuildChannel, n as GuildEmoji, o as GuildMember, p as GuildMemberManager, q as GuildMemberRoleManager, r as GuildSticker, I as Invite, L as LinkChannel, M as Message, s as MessageCollector, t as MessageCollectorEndReason, u as MessageCollectorOptions, v as MessageEditOptions, w as MessageManager, x as MessageReaction, y as MessageSendOptions, P as PartialMessage, R as ReactionCollector, z as ReactionCollectorEndReason, H as ReactionCollectorOptions, J as ReplyOptions, K as Role, N as RoleResolvable, T as TextChannel, U as User, O as UsersManager, V as VoiceChannel, W as Webhook, Q as WebhookMessageEditOptions, S as WebhookSendOptions, X as createInteraction, Y as isChatInputCommandInteraction } from './subpath-message-CZC4oGko.js';
2
+ export { ErrorCodes, FluxerError, FluxerErrorOptions, PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, UserFlagsBitField, UserFlagsBits, UserFlagsResolvable, UserFlagsString, parsePrefixCommand, parseUserMention, resolvePermissionsToBitfield, resolveTenorToImageUrl } from '@fluxerjs/util';
8
3
  export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
9
- import { PermissionsBitField, PermissionResolvable, BitField } from '@fluxerjs/util';
10
- export { PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, UserFlagsBitField, UserFlagsBits, UserFlagsResolvable, UserFlagsString, parsePrefixCommand, parseUserMention, resolvePermissionsToBitfield, resolveTenorToImageUrl } from '@fluxerjs/util';
11
-
12
- /** Resolved file data (after URL fetch). Used internally by REST layer. */
13
- interface ResolvedMessageFile {
14
- name: string;
15
- data: Blob | ArrayBuffer | Uint8Array | Buffer;
16
- filename?: string;
17
- }
18
- /** File data for message attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
19
- type MessageFileData = {
20
- name: string;
21
- data: Blob | ArrayBuffer | Uint8Array | Buffer;
22
- filename?: string;
23
- } | {
24
- name: string;
25
- url: string;
26
- filename?: string;
27
- };
28
- /** Attachment metadata for file uploads (id matches FormData index). */
29
- interface MessageAttachmentMeta {
30
- id: number;
31
- filename: string;
32
- title?: string | null;
33
- description?: string | null;
34
- /** MessageAttachmentFlags: IS_SPOILER (8), CONTAINS_EXPLICIT_MEDIA (16), IS_ANIMATED (32) */
35
- flags?: number;
36
- }
37
- /** Options for sending a message (content, embeds, files). Used by Message.send, Channel.send, ChannelManager.send.
38
- * EmbedBuilder instances are auto-converted to API format—no need to call .toJSON().
39
- */
40
- type MessageSendOptions = {
41
- content?: string;
42
- /** EmbedBuilder instances are auto-converted; raw APIEmbed also supported. */
43
- embeds?: (APIEmbed | EmbedBuilder)[];
44
- /** File attachments. When present, request uses multipart/form-data. */
45
- files?: MessageFileData[];
46
- /** Attachment metadata for files (id = index). Use when files are provided. */
47
- attachments?: MessageAttachmentMeta[];
48
- /** Message flags (e.g. MessageFlags.SuppressNotifications for reply without ping). */
49
- flags?: number;
50
- };
51
- /** API-ready body from MessageSendOptions or text content (serializes EmbedBuilder, includes attachments when files present). */
52
- interface SendBodyResult {
53
- content?: string;
54
- embeds?: APIEmbed[];
55
- attachments?: Array<{
56
- id: number;
57
- filename: string;
58
- title?: string | null;
59
- description?: string | null;
60
- flags?: number;
61
- }>;
62
- /** Message flags (e.g. SuppressNotifications for reply without ping). */
63
- flags?: number;
64
- }
65
-
66
- /** Base class for all Fluxer structures. Provides the client reference. */
67
- declare abstract class Base {
68
- /** The client instance this structure belongs to. */
69
- abstract readonly client: Client;
70
- }
71
-
72
- /** Represents a user (or bot) on Fluxer. */
73
- declare class User extends Base {
74
- readonly client: Client;
75
- readonly id: string;
76
- username: string;
77
- discriminator: string;
78
- globalName: string | null;
79
- avatar: string | null;
80
- readonly bot: boolean;
81
- /** RGB avatar color (e.g. 7577782). Null if not set. */
82
- avatarColor: number | null;
83
- /** Public flags bitfield. Null if not set. */
84
- flags: number | null;
85
- /** Whether this is an official system user. */
86
- readonly system: boolean;
87
- /** Banner hash (from profile, member, or invite context). Null when not available. */
88
- banner: string | null;
89
- /** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
90
- constructor(client: Client, data: APIUserPartial);
91
- /** Update mutable fields from fresh API data. Used by getOrCreateUser cache. */
92
- _patch(data: APIUserPartial): void;
93
- /**
94
- * Get the URL for this user's avatar.
95
- * Auto-detects animated avatars (hash starting with `a_`) and uses gif extension.
96
- * @param options - Optional `size` and `extension` (default: png, or gif for animated)
97
- */
98
- avatarURL(options?: {
99
- size?: number;
100
- extension?: string;
101
- }): string | null;
102
- /** Get the avatar URL, or the default avatar if none set (Fluxer: fluxerstatic.com). */
103
- displayAvatarURL(options?: {
104
- size?: number;
105
- extension?: string;
106
- }): string;
107
- /**
108
- * Get the URL for this user's banner.
109
- * Returns null if the user has no banner (only available when fetched from profile/member context).
110
- */
111
- bannerURL(options?: {
112
- size?: number;
113
- extension?: string;
114
- }): string | null;
115
- /** Returns a mention string (e.g. `<@123456>`). */
116
- toString(): string;
117
- /**
118
- * Create or get a DM channel with this user.
119
- * Returns the DM channel; use {@link DMChannel.send} to send messages.
120
- */
121
- createDM(): Promise<DMChannel>;
122
- /**
123
- * Send a DM to this user.
124
- * Convenience method that creates the DM channel and sends the message.
125
- */
126
- send(options: MessageSendOptions): Promise<Message>;
127
- }
128
-
129
- /** Represents a role in a guild. */
130
- declare class Role extends Base {
131
- readonly client: Client;
132
- readonly id: string;
133
- readonly guildId: string;
134
- name: string;
135
- color: number;
136
- position: number;
137
- _permissions: string;
138
- hoist: boolean;
139
- mentionable: boolean;
140
- unicodeEmoji: string | null;
141
- /** Separately sorted position for hoisted roles. Null if not set. */
142
- hoistPosition: number | null;
143
- /** @param client - The client instance */
144
- /** @param data - API role from GET /guilds/{id}/roles or gateway role events */
145
- /** @param guildId - The guild this role belongs to */
146
- constructor(client: Client, data: APIRole, guildId: string);
147
- get permissions(): PermissionsBitField;
148
- /** Update mutable fields from fresh API data. Used by edit and gateway events. */
149
- _patch(data: Partial<APIRole>): void;
150
- /** Returns a mention string (e.g. `<@&123456>`). */
151
- toString(): string;
152
- /**
153
- * Edit this role.
154
- * Requires Manage Roles permission.
155
- * @param options - Role updates (permissions accepts PermissionResolvable for convenience)
156
- * @returns This role (updated in place)
157
- * @example
158
- * await role.edit({ name: 'Moderator', permissions: ['BanMembers', 'KickMembers'] });
159
- */
160
- edit(options: RESTUpdateRoleBody & {
161
- permissions?: string | PermissionResolvable;
162
- }): Promise<Role>;
163
- /**
164
- * Delete this role.
165
- * Requires Manage Roles permission.
166
- */
167
- delete(): Promise<void>;
168
- }
169
-
170
- /** Role ID or Role object for add/remove. */
171
- type RoleResolvable = string | Role;
172
- /**
173
- * Manages a guild member's roles with add/remove/set and a cache of Role objects.
174
- * Discord.js parity: member.roles.add(), member.roles.remove(), member.roles.set(), member.roles.cache
175
- *
176
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
177
- * @example
178
- * // Add a role (Discord.js style)
179
- * await member.roles.add(roleId);
180
- *
181
- * @example
182
- * // Remove a role
183
- * await member.roles.remove(roleId);
184
- *
185
- * @example
186
- * // Replace all roles
187
- * await member.roles.set(['roleId1', 'roleId2']);
188
- *
189
- * @example
190
- * // Check if member has a role
191
- * if (member.roles.cache.has(roleId)) { ... }
192
- */
193
- declare class GuildMemberRoleManager {
194
- private readonly member;
195
- private _roleIds;
196
- constructor(member: GuildMember, initialRoleIds?: string[]);
197
- /** Role IDs for this member. Used by permissions; prefer cache for Role objects. */
198
- get roleIds(): readonly string[];
199
- /** Check if the member has a role. Discord.js parity: member.roles.cache.has(roleId) */
200
- has(roleOrId: RoleResolvable): boolean;
201
- /**
202
- * Collection of Role objects for this member's roles (from guild.roles).
203
- * Discord.js parity: member.roles.cache
204
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
205
- */
206
- get cache(): Collection<string, Role>;
207
- /** Resolve role ID from RoleResolvable. */
208
- private _resolveId;
209
- /**
210
- * Add a role to this member.
211
- * Discord.js parity: member.roles.add(roleId)
212
- * Requires Manage Roles permission.
213
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
214
- */
215
- add(roleOrId: RoleResolvable): Promise<void>;
216
- /**
217
- * Remove a role from this member.
218
- * Discord.js parity: member.roles.remove(roleId)
219
- * Requires Manage Roles permission.
220
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
221
- */
222
- remove(roleOrId: RoleResolvable): Promise<void>;
223
- /**
224
- * Replace all roles for this member. PATCH /guilds/{id}/members/{userId}
225
- * Discord.js parity: member.roles.set(roleIds)
226
- * Requires Manage Roles permission.
227
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
228
- */
229
- set(roleIds: string[]): Promise<void>;
230
- /**
231
- * Update internal role IDs from API response. Called by GuildMember.edit().
232
- * @internal
233
- */
234
- _patch(roleIds: string[]): void;
235
- }
236
-
237
- /** Represents a member of a guild. */
238
- declare class GuildMember extends Base {
239
- readonly client: Client;
240
- readonly id: string;
241
- readonly user: User;
242
- readonly guild: Guild;
243
- nick: string | null;
244
- /**
245
- * Role manager with add/remove/set and cache. Discord.js parity: member.roles.add(), member.roles.cache
246
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
247
- */
248
- readonly roles: GuildMemberRoleManager;
249
- readonly joinedAt: Date;
250
- communicationDisabledUntil: Date | null;
251
- readonly mute: boolean;
252
- readonly deaf: boolean;
253
- readonly avatar: string | null;
254
- readonly banner: string | null;
255
- readonly accentColor: number | null;
256
- readonly profileFlags: number | null;
257
- /** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
258
- constructor(client: Client, data: APIGuildMember & {
259
- guild_id?: string;
260
- }, guild: Guild);
261
- /** Nickname, or global name, or username. */
262
- get displayName(): string;
263
- /**
264
- * Get the guild-specific avatar URL for this member.
265
- * Returns null if the member has no guild avatar (use displayAvatarURL for fallback).
266
- */
267
- avatarURL(options?: {
268
- size?: number;
269
- extension?: string;
270
- }): string | null;
271
- /**
272
- * Get the avatar URL to display for this member.
273
- * Uses guild-specific avatar if set, otherwise falls back to the user's avatar.
274
- */
275
- displayAvatarURL(options?: {
276
- size?: number;
277
- extension?: string;
278
- }): string;
279
- /**
280
- * Get the guild-specific banner URL for this member.
281
- * Returns null if the member has no guild banner.
282
- */
283
- bannerURL(options?: {
284
- size?: number;
285
- extension?: string;
286
- }): string | null;
287
- /**
288
- * Add a role to this member.
289
- * Prefer member.roles.add(roleId) for Discord.js parity.
290
- * @param roleId - The role ID to add
291
- * Requires Manage Roles permission.
292
- */
293
- addRole(roleId: string): Promise<void>;
294
- /**
295
- * Remove a role from this member.
296
- * Prefer member.roles.remove(roleId) for Discord.js parity.
297
- * @param roleId - The role ID to remove
298
- * Requires Manage Roles permission.
299
- */
300
- removeRole(roleId: string): Promise<void>;
301
- /**
302
- * Edit this guild member. PATCH /guilds/{id}/members/{userId} or /members/@me for the bot.
303
- * For @me: nick, avatar, banner, bio, pronouns, accent_color, profile_flags, mute, deaf,
304
- * communication_disabled_until, timeout_reason, channel_id, connection_id.
305
- * For other members: same plus roles (array of role IDs).
306
- */
307
- edit(options: {
308
- nick?: string | null;
309
- roles?: string[];
310
- avatar?: string | null;
311
- banner?: string | null;
312
- bio?: string | null;
313
- pronouns?: string | null;
314
- accent_color?: number | null;
315
- profile_flags?: number | null;
316
- mute?: boolean;
317
- deaf?: boolean;
318
- communication_disabled_until?: string | null;
319
- timeout_reason?: string | null;
320
- channel_id?: string | null;
321
- connection_id?: string | null;
322
- }): Promise<this>;
323
- /**
324
- * Get the member's guild-level permissions (from roles only, no channel overwrites).
325
- * Use this for server-wide permission checks (e.g. ban, kick, manage roles).
326
- * @returns Object with has(permission) to check specific permissions
327
- * @example
328
- * const perms = member.permissions;
329
- * if (perms.has(PermissionFlags.BanMembers)) { ... }
330
- */
331
- get permissions(): BitField<"CreateInstantInvite" | "KickMembers" | "BanMembers" | "Administrator" | "ManageChannels" | "ManageGuild" | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream" | "ViewChannel" | "SendMessages" | "SendTtsMessages" | "ManageMessages" | "EmbedLinks" | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers" | "MoveMembers" | "UseVad" | "ChangeNickname" | "ManageNicknames" | "ManageRoles" | "ManageWebhooks" | "ManageEmojisAndStickers" | "ManageExpressions" | "UseExternalStickers" | "ModerateMembers" | "CreateExpressions" | "PinMessages" | "BypassSlowmode" | "UpdateRtcRegion">;
332
- /**
333
- * Compute the member's effective permissions in a guild channel.
334
- * Applies role permissions and channel overwrites.
335
- * @param channel - The guild channel to check permissions for
336
- * @returns Object with has(permission) to check specific permissions
337
- * @example
338
- * const perms = member.permissionsIn(channel);
339
- * if (perms.has(PermissionFlags.SendMessages)) { ... }
340
- */
341
- permissionsIn(channel: GuildChannel): BitField<"CreateInstantInvite" | "KickMembers" | "BanMembers" | "Administrator" | "ManageChannels" | "ManageGuild" | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream" | "ViewChannel" | "SendMessages" | "SendTtsMessages" | "ManageMessages" | "EmbedLinks" | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis" | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers" | "MoveMembers" | "UseVad" | "ChangeNickname" | "ManageNicknames" | "ManageRoles" | "ManageWebhooks" | "ManageEmojisAndStickers" | "ManageExpressions" | "UseExternalStickers" | "ModerateMembers" | "CreateExpressions" | "PinMessages" | "BypassSlowmode" | "UpdateRtcRegion">;
342
- /**
343
- * Move this member to a different voice channel or disconnect them from voice.
344
- * Requires Move Members permission.
345
- * @param channelId - The voice channel ID to move the member to, or null to disconnect
346
- * @param connectionId - Optional connection ID for the specific voice session (usually not needed)
347
- * @returns Promise that resolves when the member has been moved
348
- * @example
349
- * // Move member to a different voice channel
350
- * await member.move('123456789012345678');
351
- *
352
- * // Disconnect member from voice
353
- * await member.move(null);
354
- */
355
- move(channelId: string | null, connectionId?: string | null): Promise<void>;
356
- private _computeBasePermissions;
357
- }
358
-
359
- /**
360
- * Manages guild members with a Collection-like API.
361
- * Extends Collection so you can use .get(), .set(), .filter(), etc.
362
- * Provides guild.members.me for Discord.js parity.
363
- *
364
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberManager
365
- */
366
- declare class GuildMemberManager extends Collection<string, GuildMember> {
367
- private readonly guild;
368
- constructor(guild: Guild);
369
- /**
370
- * Get a guild member from cache or fetch from the API if not present.
371
- * Convenience helper to avoid repeating `guild.members.get(userId) ?? (await guild.fetchMember(userId))`.
372
- * @param userId - Snowflake of the user
373
- * @returns The guild member
374
- * @throws FluxerError with MEMBER_NOT_FOUND if user is not in the guild (404)
375
- * @example
376
- * const member = await guild.members.resolve(userId);
377
- * console.log(member.displayName);
378
- */
379
- resolve(userId: string): Promise<GuildMember>;
380
- /**
381
- * The current bot user as a GuildMember in this guild.
382
- * Returns null if the bot's member is not cached or client.user is null.
383
- * Use fetchMe() to load the bot's member when not cached.
384
- *
385
- * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberManager
386
- * @example
387
- * const perms = guild.members.me?.permissions;
388
- * if (perms?.has(PermissionFlags.BanMembers)) { ... }
389
- */
390
- get me(): GuildMember | null;
391
- /**
392
- * Fetch the current bot user as a GuildMember in this guild.
393
- * Caches the result in guild.members.
394
- *
395
- * @throws Error if client.user is null (client not ready)
396
- * @example
397
- * const me = await guild.members.fetchMe();
398
- * console.log(me.displayName);
399
- */
400
- fetchMe(): Promise<GuildMember>;
401
- /**
402
- * Fetch guild members with pagination. GET /guilds/{id}/members.
403
- * @param options - limit (1-1000), after (user ID for pagination)
404
- * @returns Array of GuildMember objects (cached in guild.members)
405
- */
406
- fetch(options?: {
407
- limit?: number;
408
- after?: string;
409
- }): Promise<GuildMember[]>;
410
- }
411
-
412
- /** File data for webhook attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
413
- type WebhookFileData = MessageFileData;
414
- /** Attachment metadata for webhook file uploads (id matches FormData index). */
415
- interface WebhookAttachmentMeta {
416
- id: number;
417
- filename: string;
418
- title?: string | null;
419
- description?: string | null;
420
- /** MessageAttachmentFlags: IS_SPOILER (8), CONTAINS_EXPLICIT_MEDIA (16), IS_ANIMATED (32) */
421
- flags?: number;
422
- }
423
- /** Options for sending a message via webhook. Aligns with WebhookMessageRequest in the API. */
424
- interface WebhookSendOptions {
425
- /** Message text content (up to 2000 characters) */
426
- content?: string;
427
- /** Embed objects. Use EmbedBuilder or APIEmbed; EmbedBuilder is serialized automatically. */
428
- embeds?: (APIEmbed | EmbedBuilder)[];
429
- /** Override the webhook's default username for this message */
430
- username?: string;
431
- /** Override the webhook's default avatar URL for this message */
432
- avatar_url?: string;
433
- /** Text-to-speech */
434
- tts?: boolean;
435
- /** File attachments. When present, uses multipart/form-data (same as channel.send). */
436
- files?: WebhookFileData[];
437
- /** Attachment metadata for files (id = index). Use when files are provided. */
438
- attachments?: WebhookAttachmentMeta[];
439
- }
440
- /**
441
- * Represents a Discord/Fluxer webhook. Supports creating, fetching, sending, and deleting.
442
- * The token is only available when the webhook was created; fetched webhooks cannot send messages.
443
- */
444
- declare class Webhook extends Base {
445
- readonly client: Client;
446
- readonly id: string;
447
- readonly guildId: string;
448
- channelId: string;
449
- name: string;
450
- avatar: string | null;
451
- /** Present only when webhook was created via createWebhook(); not returned when fetching. */
452
- readonly token: string | null;
453
- /** User who created the webhook. */
454
- readonly user: User;
455
- /** @param data - API webhook from POST /channels/{id}/webhooks (has token) or GET /webhooks/{id} (no token) */
456
- constructor(client: Client, data: APIWebhook & {
457
- token?: string | null;
458
- });
459
- /**
460
- * Get the URL for this webhook's avatar.
461
- * Returns null if the webhook has no custom avatar.
462
- */
463
- avatarURL(options?: {
464
- size?: number;
465
- extension?: string;
466
- }): string | null;
467
- /** Delete this webhook. Requires bot token with Manage Webhooks permission. */
468
- delete(): Promise<void>;
469
- /**
470
- * Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
471
- * @param options - Fields to update (name, avatar, channel_id when using bot auth)
472
- * @returns This webhook instance with updated fields
473
- */
474
- edit(options: APIWebhookUpdateRequest | APIWebhookTokenUpdateRequest): Promise<Webhook>;
475
- /**
476
- * Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
477
- * @param options - Text content or object with content, embeds, username, avatar_url, tts, files, attachments
478
- * @param wait - If true, waits for the API and returns the created Message; otherwise returns void (204)
479
- * @throws Error if token is not available
480
- * @example
481
- * await webhook.send('Hello!');
482
- * await webhook.send({ embeds: [embed] });
483
- * await webhook.send({ content: 'File attached', files: [{ name: 'data.txt', data: buffer }] });
484
- * const msg = await webhook.send({ content: 'Hi' }, true);
485
- */
486
- send(options: string | WebhookSendOptions, wait?: boolean): Promise<Message | undefined>;
487
- /**
488
- * Fetch a webhook by ID using bot auth.
489
- * @param client - The client instance
490
- * @param webhookId - The webhook ID
491
- * @returns Webhook without token (cannot send)
492
- */
493
- static fetch(client: Client, webhookId: string): Promise<Webhook>;
494
- /**
495
- * Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
496
- * @param client - The client instance
497
- * @param webhookId - The webhook ID
498
- * @param token - The webhook token (from createWebhook or stored)
499
- * @param options - Optional channelId, guildId, name for display
500
- */
501
- static fromToken(client: Client, webhookId: string, token: string, options?: {
502
- channelId?: string;
503
- guildId?: string;
504
- name?: string;
505
- }): Webhook;
506
- }
507
-
508
- /** Represents a ban in a guild. */
509
- declare class GuildBan extends Base {
510
- readonly client: Client;
511
- readonly guildId: string;
512
- readonly user: User;
513
- readonly reason: string | null;
514
- /** ISO timestamp when a temporary ban expires. Null for permanent bans. */
515
- readonly expiresAt: string | null;
516
- /** @param data - API ban from GET /guilds/{id}/bans or gateway GUILD_BAN_ADD */
517
- constructor(client: Client, data: APIBan & {
518
- guild_id?: string;
519
- }, guildId: string);
520
- /**
521
- * Remove this ban (unban the user).
522
- * Requires Ban Members permission.
523
- */
524
- unban(): Promise<void>;
525
- }
526
-
527
- /** Represents a custom emoji in a guild. */
528
- declare class GuildEmoji extends Base {
529
- readonly client: Client;
530
- readonly id: string;
531
- readonly guildId: string;
532
- name: string;
533
- readonly animated: boolean;
534
- /** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
535
- constructor(client: Client, data: APIEmoji & {
536
- guild_id?: string;
537
- }, guildId: string);
538
- /** CDN URL for this emoji image. */
539
- get url(): string;
540
- /** Emoji identifier for use in reactions: `name:id` */
541
- get identifier(): string;
542
- /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
543
- delete(): Promise<void>;
544
- /**
545
- * Edit this emoji's name.
546
- * Requires Manage Emojis and Stickers permission.
547
- */
548
- edit(options: {
549
- name: string;
550
- }): Promise<GuildEmoji>;
551
- }
552
-
553
- /** Represents a custom sticker in a guild. */
554
- declare class GuildSticker extends Base {
555
- readonly client: Client;
556
- readonly id: string;
557
- readonly guildId: string;
558
- name: string;
559
- description: string;
560
- readonly tags: string[];
561
- readonly animated: boolean;
562
- /** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
563
- constructor(client: Client, data: APISticker & {
564
- guild_id?: string;
565
- }, guildId: string);
566
- /** CDN URL for this sticker image. */
567
- get url(): string;
568
- /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
569
- delete(): Promise<void>;
570
- /**
571
- * Edit this sticker's name and/or description.
572
- * Requires Manage Emojis and Stickers permission.
573
- */
574
- edit(options: {
575
- name?: string;
576
- description?: string;
577
- }): Promise<GuildSticker>;
578
- }
579
-
580
- /** Represents a Fluxer guild (server). */
581
- declare class Guild extends Base {
582
- readonly client: Client;
583
- readonly id: string;
584
- name: string;
585
- icon: string | null;
586
- banner: string | null;
587
- readonly ownerId: string;
588
- /** Invite splash image hash. Null if none. */
589
- splash: string | null;
590
- /** Custom vanity URL code (e.g. fluxer.gg/code). Null if none. */
591
- vanityURLCode: string | null;
592
- /** Enabled guild features. */
593
- features: GuildFeature[];
594
- verificationLevel: GuildVerificationLevel;
595
- defaultMessageNotifications: DefaultMessageNotifications;
596
- explicitContentFilter: GuildExplicitContentFilter;
597
- /** AFK voice channel ID. Null if none. */
598
- afkChannelId: string | null;
599
- /** AFK timeout in seconds. */
600
- afkTimeout: number;
601
- /** System messages channel ID. Null if none. */
602
- systemChannelId: string | null;
603
- /** Rules/guidelines channel ID. Null if none. */
604
- rulesChannelId: string | null;
605
- nsfwLevel: number;
606
- mfaLevel: GuildMFALevel;
607
- /** Banner image width. Optional. */
608
- bannerWidth?: number | null;
609
- /** Banner image height. Optional. */
610
- bannerHeight?: number | null;
611
- /** Splash image width. Optional. */
612
- splashWidth?: number | null;
613
- /** Splash image height. Optional. */
614
- splashHeight?: number | null;
615
- members: GuildMemberManager;
616
- channels: Collection<string, GuildChannel>;
617
- roles: Collection<string, Role>;
618
- emojis: Collection<string, GuildEmoji>;
619
- /** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
620
- constructor(client: Client, data: APIGuild & {
621
- roles?: APIRole[];
622
- ownerId?: string;
623
- });
624
- /** Get the guild icon URL, or null if no icon. */
625
- iconURL(options?: {
626
- size?: number;
627
- }): string | null;
628
- /** Get the guild banner URL, or null if no banner. */
629
- bannerURL(options?: {
630
- size?: number;
631
- }): string | null;
632
- /** Get the guild splash (invite background) URL, or null if no splash. */
633
- splashURL(options?: {
634
- size?: number;
635
- }): string | null;
636
- /**
637
- * Add a role to a member by user ID. Does not require fetching the member first.
638
- * @param userId - The user ID of the member
639
- * @param roleId - The role ID to add (or use guild.resolveRoleId for mention/name resolution)
640
- * Requires Manage Roles permission.
641
- */
642
- addRoleToMember(userId: string, roleId: string): Promise<void>;
643
- /**
644
- * Remove a role from a member by user ID. Does not require fetching the member first.
645
- * @param userId - The user ID of the member
646
- * @param roleId - The role ID to remove
647
- * Requires Manage Roles permission.
648
- */
649
- removeRoleFromMember(userId: string, roleId: string): Promise<void>;
650
- /**
651
- * Create a role in this guild.
652
- * Requires Manage Roles permission.
653
- * @param options - Role data (permissions accepts PermissionResolvable for convenience)
654
- * @returns The created role
655
- * @example
656
- * const role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });
657
- */
658
- createRole(options: RESTCreateRoleBody & {
659
- permissions?: string | PermissionResolvable;
660
- }): Promise<Role>;
661
- /**
662
- * Fetch all roles in this guild.
663
- * @returns Array of Role objects (cached in guild.roles)
664
- */
665
- fetchRoles(): Promise<Role[]>;
666
- /**
667
- * Fetch a role by ID.
668
- * @param roleId - The role ID to fetch
669
- * @returns The role
670
- * @throws FluxerError with ROLE_NOT_FOUND if role does not exist (404)
671
- */
672
- fetchRole(roleId: string): Promise<Role>;
673
- /**
674
- * Resolve a role ID from an argument (role mention, raw ID, or name).
675
- * Fetches guild roles if name is provided.
676
- * @param arg - Role mention (@role), role ID, or role name
677
- * @returns The role ID, or null if not found
678
- */
679
- resolveRoleId(arg: string): Promise<string | null>;
680
- /**
681
- * Ban a user from this guild.
682
- * @param userId - The user ID to ban
683
- * @param options - Optional reason, delete_message_days (0–7), and ban_duration_seconds (temporary ban).
684
- * ban_duration_seconds: 0 = permanent, or use 3600, 43200, 86400, 259200, 432000, 604800, 1209600, 2592000.
685
- * Requires Ban Members permission.
686
- */
687
- ban(userId: string, options?: {
688
- reason?: string;
689
- delete_message_days?: number;
690
- ban_duration_seconds?: number;
691
- }): Promise<void>;
692
- /**
693
- * Fetch guild bans. Requires Ban Members permission.
694
- * @returns List of GuildBan objects
695
- */
696
- fetchBans(): Promise<GuildBan[]>;
697
- /**
698
- * Remove a ban (unban a user).
699
- * @param userId - The user ID to unban
700
- * Requires Ban Members permission.
701
- */
702
- unban(userId: string): Promise<void>;
703
- /**
704
- * Kick a member from this guild.
705
- * @param userId - The user ID to kick
706
- * Requires Kick Members permission.
707
- */
708
- kick(userId: string): Promise<void>;
709
- /**
710
- * Fetch a guild member by user ID.
711
- * @param userId - The user ID of the member to fetch
712
- * @returns The guild member
713
- * @throws FluxerError with MEMBER_NOT_FOUND if user is not in the guild (404)
714
- * @throws FluxerError with cause for permission denied (403) or other REST errors
715
- */
716
- fetchMember(userId: string): Promise<GuildMember>;
717
- /**
718
- * Fetch guild audit logs. Requires View Audit Log permission.
719
- * @param options - Optional limit, before, after, user_id, action_type for filtering
720
- */
721
- fetchAuditLogs(options?: {
722
- limit?: number;
723
- before?: string;
724
- after?: string;
725
- userId?: string;
726
- actionType?: number;
727
- }): Promise<APIGuildAuditLog>;
728
- /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
729
- fetchWebhooks(): Promise<Webhook[]>;
730
- /**
731
- * Create a channel in this guild.
732
- * @param data - Channel data: type (0=text, 2=voice, 4=category, 5=link), name, and optional parent_id, topic, bitrate, user_limit, nsfw, permission_overwrites
733
- * Requires Manage Channels permission.
734
- */
735
- createChannel(data: {
736
- type: 0 | 2 | 4 | 5;
737
- name: string;
738
- parent_id?: string | null;
739
- topic?: string | null;
740
- bitrate?: number | null;
741
- user_limit?: number | null;
742
- nsfw?: boolean;
743
- permission_overwrites?: Array<{
744
- id: string;
745
- type: number;
746
- allow: string;
747
- deny: string;
748
- }>;
749
- }): Promise<GuildChannel>;
750
- /**
751
- * Fetch all channels in this guild.
752
- * @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
753
- */
754
- fetchChannels(): Promise<GuildChannel[]>;
755
- /**
756
- * Edit this guild. PATCH /guilds/{id}.
757
- * Requires guild owner or Administrator.
758
- */
759
- edit(options: {
760
- name?: string;
761
- icon?: string | null;
762
- system_channel_id?: string | null;
763
- system_channel_flags?: number;
764
- afk_channel_id?: string | null;
765
- afk_timeout?: number;
766
- default_message_notifications?: DefaultMessageNotifications;
767
- verification_level?: GuildVerificationLevel;
768
- mfa_level?: GuildMFALevel;
769
- explicit_content_filter?: GuildExplicitContentFilter;
770
- banner?: string | null;
771
- splash?: string | null;
772
- embed_splash?: string | null;
773
- splash_card_alignment?: string;
774
- features?: GuildFeature[];
775
- }): Promise<this>;
776
- /**
777
- * Delete this guild. POST /guilds/{id}/delete.
778
- * Must be the guild owner.
779
- */
780
- delete(): Promise<void>;
781
- /**
782
- * Fetch vanity URL for this guild. GET /guilds/{id}/vanity-url.
783
- * Requires Manage Guild permission.
784
- */
785
- fetchVanityURL(): Promise<APIVanityURL>;
786
- /**
787
- * Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
788
- * Must be the guild owner.
789
- */
790
- transferOwnership(newOwnerId: string, password?: string): Promise<void>;
791
- /**
792
- * Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
793
- */
794
- setTextChannelFlexibleNames(enabled: boolean): Promise<this>;
795
- /**
796
- * Set detached banner feature. PATCH /guilds/{id}/detached-banner.
797
- */
798
- setDetachedBanner(enabled: boolean): Promise<this>;
799
- /**
800
- * Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
801
- */
802
- setDisallowUnclaimedAccounts(enabled: boolean): Promise<this>;
803
- /**
804
- * Update role positions. PATCH /guilds/{id}/roles.
805
- * @param updates - Array of { id, position? }
806
- */
807
- setRolePositions(updates: Array<{
808
- id: string;
809
- position?: number;
810
- }>): Promise<APIRole[]>;
811
- /**
812
- * Update role hoist positions. PATCH /guilds/{id}/roles/hoist-positions.
813
- */
814
- setRoleHoistPositions(updates: Array<{
815
- id: string;
816
- hoist_position?: number;
817
- }>): Promise<APIRole[]>;
818
- /**
819
- * Reset role hoist positions. DELETE /guilds/{id}/roles/hoist-positions.
820
- */
821
- resetRoleHoistPositions(): Promise<APIRole[]>;
822
- /**
823
- * Update channel positions.
824
- * @param updates - Array of { id, position?, parent_id?, lock_permissions? }
825
- * Requires Manage Channels permission.
826
- */
827
- setChannelPositions(updates: Array<{
828
- id: string;
829
- position?: number;
830
- parent_id?: string | null;
831
- lock_permissions?: boolean;
832
- }>): Promise<void>;
833
- /**
834
- * Fetch all emojis in this guild.
835
- * @returns Array of GuildEmoji objects (cached in guild.emojis)
836
- */
837
- fetchEmojis(): Promise<GuildEmoji[]>;
838
- /**
839
- * Fetch a single emoji by ID.
840
- * @param emojiId - The emoji ID to fetch
841
- * @returns The guild emoji
842
- * @throws FluxerError if emoji not found (404)
843
- */
844
- fetchEmoji(emojiId: string): Promise<GuildEmoji>;
845
- /**
846
- * Bulk create emojis. POST /guilds/{id}/emojis/bulk.
847
- * @param emojis - Array of { name, image } (base64), 1-50 emojis
848
- * @returns Array of created GuildEmoji objects
849
- */
850
- createEmojisBulk(emojis: Array<{
851
- name: string;
852
- image: string;
853
- }>): Promise<GuildEmoji[]>;
854
- /**
855
- * Bulk create stickers. POST /guilds/{id}/stickers/bulk.
856
- * @param stickers - Array of { name, image, description?, tags? }, 1-50 stickers
857
- * @returns Array of created GuildSticker objects
858
- */
859
- createStickersBulk(stickers: Array<{
860
- name: string;
861
- image: string;
862
- description?: string;
863
- tags?: string[];
864
- }>): Promise<GuildSticker[]>;
865
- }
866
-
867
- /** Represents a reaction added to or removed from a message. */
868
- declare class MessageReaction extends Base {
869
- readonly client: Client;
870
- readonly messageId: string;
871
- readonly channelId: string;
872
- readonly guildId: string | null;
873
- readonly emoji: GatewayReactionEmoji;
874
- /** Raw gateway payload for low-level access. */
875
- readonly _data: GatewayMessageReactionAddDispatchData | GatewayMessageReactionRemoveDispatchData;
876
- constructor(client: Client, data: GatewayMessageReactionAddDispatchData | GatewayMessageReactionRemoveDispatchData);
877
- /** Emoji as a string: unicode or "name:id" for custom. */
878
- get emojiIdentifier(): string;
879
- /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
880
- get guild(): Guild | null;
881
- /**
882
- * Fetch the message this reaction belongs to.
883
- * Use when you need to edit, delete, or otherwise interact with the message.
884
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
885
- */
886
- fetchMessage(): Promise<Message>;
887
- }
888
-
889
- interface ReactionCollectorOptions {
890
- /** Filter function. Return true to collect the reaction. */
891
- filter?: (reaction: MessageReaction, user: User) => boolean;
892
- /** Max duration in ms. Collector stops when time expires. */
893
- time?: number;
894
- /** Max reactions to collect. Collector stops when limit reached. */
895
- max?: number;
896
- }
897
- type ReactionCollectorEndReason = 'time' | 'limit' | 'user';
898
- interface CollectedReaction {
899
- reaction: MessageReaction;
900
- user: User;
901
- }
902
- interface ReactionCollectorEvents {
903
- collect: [reaction: MessageReaction, user: User];
904
- end: [collected: Collection<string, CollectedReaction>, reason: ReactionCollectorEndReason];
905
- }
906
- /**
907
- * Collects reactions on a message. Use message.createReactionCollector().
908
- * @example
909
- * const collector = message.createReactionCollector({ filter: (r, u) => u.id === userId, time: 10000 });
910
- * collector.on('collect', (reaction, user) => console.log(user.username, 'reacted', reaction.emoji.name));
911
- * collector.on('end', (collected, reason) => console.log(`Stopped: ${reason}`));
912
- */
913
- declare class ReactionCollector extends EventEmitter {
914
- readonly client: Client;
915
- readonly messageId: string;
916
- readonly channelId: string;
917
- readonly options: Required<ReactionCollectorOptions>;
918
- readonly collected: Collection<string, CollectedReaction>;
919
- private _timeout;
920
- private _ended;
921
- private _listener;
922
- constructor(client: Client, messageId: string, channelId: string, options?: ReactionCollectorOptions);
923
- stop(reason?: ReactionCollectorEndReason): void;
924
- on<K extends keyof ReactionCollectorEvents>(event: K, listener: (...args: ReactionCollectorEvents[K]) => void): this;
925
- emit<K extends keyof ReactionCollectorEvents>(event: K, ...args: ReactionCollectorEvents[K]): boolean;
926
- }
927
-
928
- /** Options for editing a message (content and/or embeds). */
929
- interface MessageEditOptions {
930
- /** New text content */
931
- content?: string;
932
- /** New embeds (replaces existing) */
933
- embeds?: (APIEmbed | EmbedBuilder)[];
934
- }
935
- type MessagePayload = {
936
- files?: ResolvedMessageFile[];
937
- body: SendBodyResult & {
938
- message_reference?: APIMessageReference;
939
- flags?: number;
940
- };
941
- };
942
- /** Options for message.reply() — ping toggle and reply-to-different-message. */
943
- interface ReplyOptions {
944
- /** Whether to ping the replied-to user (default true). Use false to suppress the mention notification. */
945
- ping?: boolean;
946
- /** Reply to a different message instead of this one. Default: this message. */
947
- replyTo?: Message | {
948
- channelId: string;
949
- messageId: string;
950
- };
951
- }
952
-
953
- /** Represents a message in a channel. */
954
- declare class Message extends Base {
955
- readonly client: Client;
956
- readonly id: string;
957
- readonly channelId: string;
958
- readonly guildId: string | null;
959
- readonly author: User;
960
- content: string;
961
- readonly createdAt: Date;
962
- readonly editedAt: Date | null;
963
- pinned: boolean;
964
- readonly attachments: Collection<string, APIMessageAttachment>;
965
- readonly type: MessageType;
966
- readonly flags: number;
967
- readonly mentionEveryone: boolean;
968
- readonly tts: boolean;
969
- readonly embeds: APIEmbed[];
970
- readonly stickers: APIMessageSticker[];
971
- readonly reactions: APIMessageReaction[];
972
- readonly messageReference: APIMessageReference | null;
973
- readonly messageSnapshots: APIMessageSnapshot[];
974
- readonly call: APIMessageCall | null;
975
- readonly referencedMessage: Message | null;
976
- /** Webhook ID if this message was sent via webhook. Null otherwise. */
977
- readonly webhookId: string | null;
978
- /** Users mentioned in this message. */
979
- readonly mentions: User[];
980
- /** Role IDs mentioned in this message. */
981
- readonly mentionRoles: string[];
982
- /** Client-side nonce for acknowledgment. Null if not provided. */
983
- readonly nonce: string | null;
984
- /**
985
- * Channel where this message was sent. Resolved from cache; null if not cached.
986
- * Messages can only exist in text-based channels (text, DM, announcement), so this always has send() when non-null.
987
- */
988
- get channel(): (TextChannel | DMChannel | GuildChannel) | null;
989
- /** Guild where this message was sent. Resolved from cache; null for DMs or if not cached. */
990
- get guild(): Guild | null;
991
- /**
992
- * Resolve the channel (from cache or API). Use when you need the channel and it may not be cached.
993
- * @returns The channel
994
- * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
995
- */
996
- resolveChannel(): Promise<Channel>;
997
- /**
998
- * Resolve the guild (from cache or API). Returns null for DMs.
999
- * @returns The guild, or null if this is a DM or guild not found
1000
- */
1001
- resolveGuild(): Promise<Guild | null>;
1002
- /** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
1003
- constructor(client: Client, data: APIMessage);
1004
- /**
1005
- * Send a message to this channel without replying. Use when you want a standalone message.
1006
- * @param options - Text content or object with content, embeds, and/or files
1007
- * @example
1008
- * await message.send('Pong!');
1009
- * await message.send({ embeds: [embed] }); // EmbedBuilder auto-converted
1010
- * await message.send({ content: 'File', files: [{ name: 'data.txt', data }] });
1011
- */
1012
- send(options: string | MessageSendOptions): Promise<Message>;
1013
- /**
1014
- * Send a message to a specific channel. Use for logging, forwarding, or sending to another channel in the guild.
1015
- * @param channelId - Snowflake of the target channel (e.g. log channel ID)
1016
- * @param options - Text content or object with content and/or embeds
1017
- * @example
1018
- * await message.sendTo(logChannelId, 'User ' + message.author.username + ' said: ' + message.content);
1019
- * await message.sendTo(announceChannelId, { embeds: [embed] });
1020
- */
1021
- sendTo(channelId: string, options: MessageSendOptions): Promise<Message>;
1022
- /**
1023
- * Reply to this message (shows as a reply in the client).
1024
- * @param options - Text content or object with content, embeds, and/or reply options (ping, replyTo)
1025
- * @example
1026
- * await message.reply('Pong!');
1027
- * await message.reply({ embeds: [embed] });
1028
- * await message.reply('No ping!', { ping: false });
1029
- * await message.reply({ content: 'Reply to other', replyTo: otherMessage });
1030
- */
1031
- reply(options: string | (MessageSendOptions & ReplyOptions), replyOptions?: ReplyOptions): Promise<Message>;
1032
- /** Exposed for testing purposes, use Message.reply() or send() for normal use */
1033
- static _createMessageBody(content: string | MessageSendOptions, referenced_message?: {
1034
- channel_id: string;
1035
- message_id: string;
1036
- guild_id?: string;
1037
- }, ping?: boolean): Promise<MessagePayload>;
1038
- _send(payload: MessagePayload): Promise<Message>;
1039
- /**
1040
- * Edit this message. Only the author (or admins) can edit.
1041
- * @param options - New content and/or embeds
1042
- */
1043
- edit(options: MessageEditOptions): Promise<Message>;
1044
- /**
1045
- * Create a reaction collector for this message.
1046
- * Collects reactions matching the filter until time expires or max is reached.
1047
- * @param options - Filter, time (ms), and max count
1048
- * @example
1049
- * const collector = message.createReactionCollector({ filter: (r, u) => u.id === userId, time: 10000 });
1050
- * collector.on('collect', (reaction, user) => console.log(user.username, 'reacted with', reaction.emoji.name));
1051
- * collector.on('end', (collected, reason) => { ... });
1052
- */
1053
- createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
1054
- /**
1055
- * Re-fetch this message from the API to get the latest content, embeds, reactions, etc.
1056
- * Use when you have a stale Message (e.g. from an old event or cache) and need fresh data.
1057
- * @returns The updated message
1058
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message was deleted or does not exist
1059
- * @example
1060
- * const updated = await message.fetch();
1061
- * console.log('Latest content:', updated.content);
1062
- */
1063
- fetch(): Promise<Message>;
1064
- /** Delete this message. */
1065
- delete(): Promise<void>;
1066
- /**
1067
- * Delete a specific attachment from this message.
1068
- * DELETE /channels/{id}/messages/{id}/attachments/{attachmentId}.
1069
- */
1070
- deleteAttachment(attachmentId: string): Promise<void>;
1071
- /** Pin this message to the channel. Requires Manage Messages permission. */
1072
- pin(): Promise<void>;
1073
- /** Unpin this message from the channel. Requires Manage Messages permission. */
1074
- unpin(): Promise<void>;
1075
- /**
1076
- * Format emoji for reaction API: unicode string or "name:id" for custom.
1077
- * For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.
1078
- */
1079
- private static formatEmoji;
1080
- private resolveEmojiForReaction;
1081
- /**
1082
- * Add a reaction to this message (as the bot).
1083
- * @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
1084
- */
1085
- react(emoji: string | {
1086
- name: string;
1087
- id?: string;
1088
- animated?: boolean;
1089
- }): Promise<void>;
1090
- /**
1091
- * Remove the bot's reaction, or a specific user's reaction if userId is provided.
1092
- * @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
1093
- * @param userId - If provided, removes that user's reaction (requires moderator permissions)
1094
- */
1095
- removeReaction(emoji: string | {
1096
- name: string;
1097
- id?: string;
1098
- animated?: boolean;
1099
- }, userId?: string): Promise<void>;
1100
- /**
1101
- * Remove all reactions from this message.
1102
- * Requires moderator permissions.
1103
- */
1104
- removeAllReactions(): Promise<void>;
1105
- /**
1106
- * Remove all reactions of a specific emoji from this message.
1107
- * @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`. Requires moderator permissions.
1108
- */
1109
- removeReactionEmoji(emoji: string | {
1110
- name: string;
1111
- id?: string;
1112
- animated?: boolean;
1113
- }): Promise<void>;
1114
- /**
1115
- * Fetch users who reacted with the given emoji.
1116
- * @param emoji - Unicode emoji or custom `{ name, id }`
1117
- * @param options - limit (1–100), after (user ID for pagination)
1118
- * @returns Array of User objects
1119
- */
1120
- fetchReactionUsers(emoji: string | {
1121
- name: string;
1122
- id?: string;
1123
- animated?: boolean;
1124
- }, options?: {
1125
- limit?: number;
1126
- after?: string;
1127
- }): Promise<User[]>;
1128
- }
1129
-
1130
- /**
1131
- * Manages messages for a channel. Access via channel.messages.
1132
- * @example
1133
- * const message = channel.messages.get(messageId); // from cache (if enabled)
1134
- * const message = await channel.messages.fetch(messageId); // from API
1135
- * if (message) await message.edit({ content: 'Updated!' });
1136
- */
1137
- declare class MessageManager {
1138
- private readonly client;
1139
- private readonly channelId;
1140
- constructor(client: Client, channelId: string);
1141
- /**
1142
- * Get a message from cache. Returns undefined if not cached or caching is disabled.
1143
- * Requires options.cache.messages > 0.
1144
- * @param messageId - Snowflake of the message
1145
- */
1146
- get(messageId: string): Message | undefined;
1147
- /**
1148
- * Fetch a message by ID from this channel.
1149
- * When message caching is enabled, the fetched message is added to the cache.
1150
- * @param messageId - Snowflake of the message
1151
- * @returns The message
1152
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
1153
- */
1154
- fetch(messageId: string): Promise<Message>;
1155
- }
1156
-
1157
- interface MessageCollectorOptions {
1158
- /** Filter function. Return true to collect the message. */
1159
- filter?: (message: Message) => boolean;
1160
- /** Max duration in ms. Collector stops when time expires. */
1161
- time?: number;
1162
- /** Max messages to collect. Collector stops when limit reached. */
1163
- max?: number;
1164
- }
1165
- type MessageCollectorEndReason = 'time' | 'limit' | 'user';
1166
- interface MessageCollectorEvents {
1167
- collect: [message: Message];
1168
- end: [collected: Collection<string, Message>, reason: MessageCollectorEndReason];
1169
- }
1170
- /**
1171
- * Collects messages in a channel. Use channel.createMessageCollector().
1172
- * @example
1173
- * const collector = channel.createMessageCollector({ filter: m => m.author.id === userId, time: 10000 });
1174
- * collector.on('collect', m => console.log(m.content));
1175
- * collector.on('end', (collected, reason) => console.log(`Stopped: ${reason}`));
1176
- */
1177
- declare class MessageCollector extends EventEmitter {
1178
- readonly client: Client;
1179
- readonly channelId: string;
1180
- readonly options: Required<MessageCollectorOptions>;
1181
- readonly collected: Collection<string, Message>;
1182
- private _timeout;
1183
- private _ended;
1184
- private _listener;
1185
- constructor(client: Client, channelId: string, options?: MessageCollectorOptions);
1186
- stop(reason?: MessageCollectorEndReason): void;
1187
- on<K extends keyof MessageCollectorEvents>(event: K, listener: (...args: MessageCollectorEvents[K]) => void): this;
1188
- emit<K extends keyof MessageCollectorEvents>(event: K, ...args: MessageCollectorEvents[K]): boolean;
1189
- }
1190
-
1191
- /** Represents an invite to a guild or channel. */
1192
- declare class Invite extends Base {
1193
- readonly client: Client;
1194
- readonly code: string;
1195
- readonly type: number;
1196
- readonly guild: APIGuildPartial;
1197
- readonly channel: APIChannelPartial;
1198
- readonly inviter: User | null;
1199
- readonly memberCount: number | null;
1200
- readonly presenceCount: number | null;
1201
- readonly expiresAt: string | null;
1202
- readonly temporary: boolean | null;
1203
- readonly createdAt: string | null;
1204
- readonly uses: number | null;
1205
- readonly maxUses: number | null;
1206
- readonly maxAge: number | null;
1207
- /** @param data - API invite from GET /invites/{code}, channel/guild invite list, or gateway INVITE_CREATE */
1208
- constructor(client: Client, data: APIInvite);
1209
- /** Full invite URL (https://fluxer.gg/{code} or instance-specific). */
1210
- get url(): string;
1211
- /**
1212
- * Resolve the guild from cache if available.
1213
- * @returns The guild, or null if not cached
1214
- */
1215
- getGuild(): Guild | null;
1216
- /**
1217
- * Delete this invite.
1218
- * Requires Manage Guild or Create Instant Invite permission.
1219
- */
1220
- delete(): Promise<void>;
1221
- }
1222
-
1223
- /** Base class for all channel types. */
1224
- declare abstract class Channel extends Base {
1225
- /** Whether this channel has a send method (TextChannel, DMChannel). */
1226
- isTextBased(): this is TextChannel | DMChannel;
1227
- /** Whether this channel is a DM or Group DM. */
1228
- isDM(): this is DMChannel;
1229
- /** Whether this channel is voice-based (VoiceChannel). */
1230
- isVoice(): this is VoiceChannel;
1231
- isLink(): this is LinkChannel;
1232
- /** Create a DM channel from API data (type DM or GroupDM). */
1233
- static createDM(client: Client, data: APIChannelPartial): DMChannel;
1234
- readonly client: Client;
1235
- readonly id: string;
1236
- type: ChannelType;
1237
- /** Channel name. Guild channels and Group DMs have names; 1:1 DMs are typically null. */
1238
- name: string | null;
1239
- /** Channel icon hash (Group DMs). Null if none. */
1240
- icon: string | null;
1241
- /** ISO timestamp when the last message was pinned. Null if never pinned. */
1242
- lastPinTimestamp: string | null;
1243
- /** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
1244
- constructor(client: Client, data: APIChannelPartial);
1245
- /**
1246
- * Create the appropriate channel subclass from API data.
1247
- * @param client - The client instance
1248
- * @param data - Channel data from the API
1249
- */
1250
- static from(client: Client, data: APIChannel | APIChannelPartial): GuildChannel | TextChannel | null;
1251
- /**
1252
- * Create a channel from API data, including DM and GroupDM.
1253
- * Used by ChannelManager.fetch() for GET /channels/{id}.
1254
- */
1255
- static fromOrCreate(client: Client, data: APIChannel | APIChannelPartial): TextChannel | DMChannel | GuildChannel | null;
1256
- /**
1257
- * Bulk delete messages. Requires Manage Messages permission.
1258
- * @param messageIds - Array of message IDs to delete (2–100)
1259
- */
1260
- bulkDeleteMessages(messageIds: string[]): Promise<void>;
1261
- /**
1262
- * Send a typing indicator to the channel. Lasts ~10 seconds.
1263
- */
1264
- sendTyping(): Promise<void>;
1265
- /**
1266
- * Whether the bot can send messages in this channel.
1267
- * For DMs: always true (when the channel exists).
1268
- * For guild channels: checks ViewChannel and SendMessages permissions via guild.members.me.
1269
- */
1270
- canSendMessage(): boolean;
1271
- }
1272
- declare class GuildChannel extends Channel {
1273
- readonly guildId: string;
1274
- name: string | null;
1275
- position?: number;
1276
- parentId: string | null;
1277
- /** Permission overwrites for roles and members. */
1278
- permissionOverwrites: APIChannelOverwrite[];
1279
- constructor(client: Client, data: APIChannel);
1280
- /**
1281
- * Create a webhook in this channel.
1282
- * @param options - Webhook name and optional avatar URL
1283
- * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
1284
- */
1285
- createWebhook(options: {
1286
- name: string;
1287
- avatar?: string | null;
1288
- }): Promise<Webhook>;
1289
- /**
1290
- * Fetch all webhooks in this channel.
1291
- * @returns Webhooks (includes token when listing from channel; can send via send())
1292
- */
1293
- fetchWebhooks(): Promise<Webhook[]>;
1294
- /**
1295
- * Create an invite for this channel.
1296
- * @param options - max_uses (0–100), max_age (0–604800 seconds), unique, temporary
1297
- * Requires Create Instant Invite permission.
1298
- */
1299
- createInvite(options?: {
1300
- max_uses?: number;
1301
- max_age?: number;
1302
- unique?: boolean;
1303
- temporary?: boolean;
1304
- }): Promise<Invite>;
1305
- /**
1306
- * Fetch invites for this channel.
1307
- * Requires Manage Channel permission.
1308
- */
1309
- fetchInvites(): Promise<Invite[]>;
1310
- /**
1311
- * Set or update a permission overwrite. PUT /channels/{id}/permissions/{overwriteId}.
1312
- * @param overwriteId - Role or member ID
1313
- * @param options - type (0=role, 1=member), allow, deny (permission bitfields)
1314
- */
1315
- editPermission(overwriteId: string, options: {
1316
- type: 0 | 1;
1317
- allow?: string;
1318
- deny?: string;
1319
- }): Promise<void>;
1320
- /**
1321
- * Whether the bot can send messages in this channel.
1322
- * Checks ViewChannel and SendMessages via guild.members.me permissions.
1323
- * Returns false if guild or bot member not cached.
1324
- */
1325
- canSendMessage(): boolean;
1326
- /**
1327
- * Send a message to this guild channel.
1328
- * Works for text and announcement channels. Voice/category/link channels will fail at the API.
1329
- */
1330
- send(options: MessageSendOptions): Promise<Message>;
1331
- /**
1332
- * Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
1333
- */
1334
- deletePermission(overwriteId: string): Promise<void>;
1335
- /**
1336
- * Edit this channel. PATCH /channels/{id}.
1337
- * Requires Manage Channel permission.
1338
- */
1339
- edit(options: {
1340
- name?: string | null;
1341
- topic?: string | null;
1342
- parent_id?: string | null;
1343
- bitrate?: number | null;
1344
- user_limit?: number | null;
1345
- nsfw?: boolean;
1346
- rate_limit_per_user?: number;
1347
- rtc_region?: string | null;
1348
- permission_overwrites?: Array<{
1349
- id: string;
1350
- type: number;
1351
- allow?: string;
1352
- deny?: string;
1353
- }>;
1354
- }): Promise<this>;
1355
- /**
1356
- * Delete this channel. Requires Manage Channel permission.
1357
- * @param options - silent: if true, does not send a system message (default false)
1358
- */
1359
- delete(options?: {
1360
- silent?: boolean;
1361
- }): Promise<void>;
1362
- }
1363
- declare class TextChannel extends GuildChannel {
1364
- topic?: string | null;
1365
- nsfw?: boolean;
1366
- rateLimitPerUser?: number;
1367
- lastMessageId?: string | null;
1368
- constructor(client: Client, data: APIChannel);
1369
- /**
1370
- * Send a message to this channel.
1371
- * @param options - Text content or object with content, embeds, and/or files
1372
- */
1373
- send(options: MessageSendOptions): Promise<Message>;
1374
- /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1375
- get messages(): MessageManager;
1376
- /**
1377
- * Create a message collector for this channel.
1378
- * Collects messages matching the filter until time expires or max is reached.
1379
- * @param options - Filter, time (ms), and max count
1380
- * @example
1381
- * const collector = channel.createMessageCollector({ filter: m => m.author.id === userId, time: 10000 });
1382
- * collector.on('collect', m => console.log(m.content));
1383
- * collector.on('end', (collected, reason) => { ... });
1384
- */
1385
- createMessageCollector(options?: MessageCollectorOptions): MessageCollector;
1386
- /**
1387
- * Fetch pinned messages in this channel.
1388
- * @returns Pinned messages
1389
- */
1390
- fetchPinnedMessages(): Promise<Message[]>;
1391
- /**
1392
- * Fetch a message by ID from this channel.
1393
- * @param messageId - Snowflake of the message
1394
- * @returns The message, or null if not found
1395
- * @deprecated Use channel.messages.fetch(messageId) instead.
1396
- */
1397
- fetchMessage(messageId: string): Promise<Message>;
1398
- }
1399
- declare class CategoryChannel extends GuildChannel {
1400
- }
1401
- declare class VoiceChannel extends GuildChannel {
1402
- bitrate?: number | null;
1403
- userLimit?: number | null;
1404
- rtcRegion?: string | null;
1405
- constructor(client: Client, data: APIChannel);
1406
- }
1407
- declare class LinkChannel extends GuildChannel {
1408
- url: string | null;
1409
- constructor(client: Client, data: APIChannel);
1410
- }
1411
- /** DM channel (direct message between bot and a user). */
1412
- declare class DMChannel extends Channel {
1413
- lastMessageId?: string | null;
1414
- /** Group DM creator ID. Null for 1:1 DMs. */
1415
- ownerId: string | null;
1416
- /** Group DM recipients as User objects. Empty for 1:1 DMs. */
1417
- recipients: User[];
1418
- /** Group DM member display names (userId -> nickname). */
1419
- nicks: Record<string, string>;
1420
- constructor(client: Client, data: APIChannelPartial & Partial<APIChannel>);
1421
- /**
1422
- * Send a message to this DM channel.
1423
- * @param options - Text content or object with content, embeds, and/or files
1424
- */
1425
- send(options: MessageSendOptions): Promise<Message>;
1426
- /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1427
- get messages(): MessageManager;
1428
- /**
1429
- * Create a message collector for this DM channel.
1430
- * @param options - Filter, time (ms), and max count
1431
- */
1432
- createMessageCollector(options?: MessageCollectorOptions): MessageCollector;
1433
- /**
1434
- * Fetch pinned messages in this DM channel.
1435
- * @returns Pinned messages
1436
- */
1437
- fetchPinnedMessages(): Promise<Message[]>;
1438
- /**
1439
- * Fetch a message by ID from this DM channel.
1440
- * @param messageId - Snowflake of the message
1441
- * @returns The message, or null if not found
1442
- * @deprecated Use channel.messages.fetch(messageId) instead.
1443
- */
1444
- fetchMessage(messageId: string): Promise<Message>;
1445
- /**
1446
- * Add a recipient to this Group DM. Requires Group DM (type GroupDM).
1447
- * PUT /channels/{id}/recipients/{userId}.
1448
- */
1449
- addRecipient(userId: string): Promise<void>;
1450
- /**
1451
- * Remove a recipient from this Group DM. Requires Group DM (type GroupDM).
1452
- * DELETE /channels/{id}/recipients/{userId}.
1453
- * @param options - silent: if true, does not send a system message (default false)
1454
- */
1455
- removeRecipient(userId: string, options?: {
1456
- silent?: boolean;
1457
- }): Promise<void>;
1458
- }
1459
-
1460
- /**
1461
- * Manages channels with fetch and send.
1462
- * Extends Collection so you can use .get(), .set(), .filter(), etc.
1463
- */
1464
- declare class ChannelManager extends Collection<string, Channel | GuildChannel> {
1465
- private readonly client;
1466
- private readonly maxSize;
1467
- constructor(client: Client);
1468
- set(key: string, value: Channel): this;
1469
- /**
1470
- * Get a channel from cache or fetch from the API if not present.
1471
- * Convenience helper to avoid repeating `client.channels.get(id) ?? (await client.channels.fetch(id))`.
1472
- * @param channelId - Snowflake of the channel
1473
- * @returns The channel
1474
- * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
1475
- * @example
1476
- * const channel = await client.channels.resolve(message.channelId);
1477
- * if (channel?.isTextBased()) await channel.send('Hello!');
1478
- */
1479
- resolve(channelId: string): Promise<Channel>;
1480
- /**
1481
- * Fetch a channel by ID from the API (or return from cache if present).
1482
- * @param channelId - Snowflake of the channel
1483
- * @returns The channel
1484
- * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
1485
- * @example
1486
- * const channel = await client.channels.fetch(channelId);
1487
- * if (channel?.isTextBased()) await channel.send('Hello!');
1488
- */
1489
- fetch(channelId: string): Promise<Channel>;
1490
- /**
1491
- * Fetch a message by ID from the API.
1492
- * @param channelId - Snowflake of the channel
1493
- * @param messageId - Snowflake of the message
1494
- * @returns The message
1495
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
1496
- * @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.resolve(channelId))?.messages?.fetch(messageId).
1497
- * @example
1498
- * const channel = await client.channels.resolve(channelId);
1499
- * const message = await channel?.messages?.fetch(messageId);
1500
- */
1501
- fetchMessage(channelId: string, messageId: string): Promise<Message>;
1502
- /**
1503
- * Send a message to a channel by ID. Works even when the channel is not cached.
1504
- * Skips the fetch when you only need to send.
1505
- * @param channelId - Snowflake of the channel (text channel or DM)
1506
- * @param payload - Text content or object with content, embeds, and/or files
1507
- * @returns The created message
1508
- * @example
1509
- * await client.channels.send(logChannelId, 'User joined!');
1510
- * await client.channels.send(channelId, { embeds: [embed] });
1511
- * await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
1512
- */
1513
- send(channelId: string, payload: string | MessageSendOptions): Promise<Message>;
1514
- }
1515
-
1516
- /**
1517
- * Manages guilds with fetch.
1518
- * Extends Collection so you can use .get(), .set(), .filter(), etc.
1519
- */
1520
- declare class GuildManager extends Collection<string, Guild> {
1521
- private readonly client;
1522
- private readonly maxSize;
1523
- constructor(client: Client);
1524
- set(key: string, value: Guild): this;
1525
- /**
1526
- * Get a guild from cache or fetch from the API if not present.
1527
- * Convenience helper to avoid repeating `client.guilds.get(id) ?? (await client.guilds.fetch(id))`.
1528
- * @param guildId - Snowflake of the guild
1529
- * @returns The guild, or null if not found
1530
- * @example
1531
- * const guild = await client.guilds.resolve(message.guildId);
1532
- * if (guild) console.log(guild.name);
1533
- */
1534
- resolve(guildId: string): Promise<Guild | null>;
1535
- /**
1536
- * Create a guild. POST /guilds.
1537
- * @param options - name (required), icon (base64), empty_features
1538
- * @returns The created guild
1539
- */
1540
- create(options: {
1541
- name: string;
1542
- icon?: string | null;
1543
- empty_features?: boolean;
1544
- }): Promise<Guild>;
1545
- /**
1546
- * Fetch a guild by ID from the API (or return from cache if present).
1547
- * @param guildId - Snowflake of the guild
1548
- * @returns The guild, or null if not found
1549
- * @example
1550
- * const guild = await client.guilds.fetch(guildId);
1551
- * if (guild) console.log(guild.name);
1552
- */
1553
- fetch(guildId: string): Promise<Guild | null>;
1554
- }
1555
-
1556
- /** Optional cache size limits. When exceeded, oldest entries are evicted (FIFO). Omit or use 0 for unbounded. */
1557
- interface CacheSizeLimits {
1558
- channels?: number;
1559
- guilds?: number;
1560
- users?: number;
1561
- /** Max messages per channel to cache. Enables channel.messages.get() and oldMessage in messageUpdate. 0 = disabled. */
1562
- messages?: number;
1563
- }
1564
- interface ClientOptions {
1565
- rest?: Partial<ConstructorParameters<typeof REST>[0]>;
1566
- /** Gateway intents. Not yet supported by Fluxer—value is always sent as 0. Set suppressIntentWarning to silence the warning. */
1567
- intents?: number;
1568
- /** Suppress the warning when intents are set (Fluxer does not support intents yet). */
1569
- suppressIntentWarning?: boolean;
1570
- /** When true, delay the Ready event until all guilds from READY (including unavailable) have been received via GUILD_CREATE. Default: false. */
1571
- waitForGuilds?: boolean;
1572
- /** Cache size limits (channels, guilds, users). When exceeded, oldest entries are evicted. Omit or 0 = unbounded. */
1573
- cache?: CacheSizeLimits;
1574
- /** Initial presence (status, custom_status, etc.) sent on identify. Can also update via PresenceUpdate after connect. */
1575
- presence?: GatewayPresenceUpdateData;
1576
- /** Optional WebSocket constructor (e.g. `require('ws')` in Node for compatibility) */
1577
- WebSocket?: new (url: string) => {
1578
- send(data: string | ArrayBufferLike): void;
1579
- close(code?: number): void;
1580
- readyState: number;
1581
- addEventListener?(type: string, listener: (e: unknown) => void): void;
1582
- on?(event: string, cb: (data?: unknown) => void): void;
1583
- };
1584
- }
1585
-
1586
- declare class ClientUser extends User {
1587
- readonly client: Client;
1588
- constructor(client: Client, data: APIUserPartial);
1589
- /**
1590
- * Fetch guilds the bot is a member of.
1591
- * @returns Array of Guild objects (cached in client.guilds)
1592
- */
1593
- fetchGuilds(): Promise<Guild[]>;
1594
- /**
1595
- * Leave a guild. Requires the bot to be a member.
1596
- * @param guildId - The guild ID to leave
1597
- */
1598
- leaveGuild(guildId: string): Promise<void>;
1599
- }
1600
-
1601
- /** Event name constants for client.on(Events.X, handler). Use with ClientEvents for typed callbacks. */
1602
- declare const Events: {
1603
- readonly Ready: "ready";
1604
- readonly MessageCreate: "messageCreate";
1605
- readonly MessageUpdate: "messageUpdate";
1606
- readonly MessageDelete: "messageDelete";
1607
- readonly MessageDeleteBulk: "messageDeleteBulk";
1608
- readonly MessageReactionAdd: "messageReactionAdd";
1609
- readonly MessageReactionRemove: "messageReactionRemove";
1610
- readonly MessageReactionRemoveAll: "messageReactionRemoveAll";
1611
- readonly MessageReactionRemoveEmoji: "messageReactionRemoveEmoji";
1612
- readonly InteractionCreate: "interactionCreate";
1613
- readonly GuildCreate: "guildCreate";
1614
- readonly GuildUpdate: "guildUpdate";
1615
- readonly GuildDelete: "guildDelete";
1616
- readonly GuildBanAdd: "guildBanAdd";
1617
- readonly GuildBanRemove: "guildBanRemove";
1618
- readonly GuildEmojisUpdate: "guildEmojisUpdate";
1619
- readonly GuildStickersUpdate: "guildStickersUpdate";
1620
- readonly GuildIntegrationsUpdate: "guildIntegrationsUpdate";
1621
- readonly GuildMemberAdd: "guildMemberAdd";
1622
- readonly GuildMemberUpdate: "guildMemberUpdate";
1623
- readonly GuildMemberRemove: "guildMemberRemove";
1624
- readonly GuildRoleCreate: "guildRoleCreate";
1625
- readonly GuildRoleUpdate: "guildRoleUpdate";
1626
- readonly GuildRoleDelete: "guildRoleDelete";
1627
- readonly GuildScheduledEventCreate: "guildScheduledEventCreate";
1628
- readonly GuildScheduledEventUpdate: "guildScheduledEventUpdate";
1629
- readonly GuildScheduledEventDelete: "guildScheduledEventDelete";
1630
- readonly ChannelCreate: "channelCreate";
1631
- readonly ChannelUpdate: "channelUpdate";
1632
- readonly ChannelDelete: "channelDelete";
1633
- readonly ChannelPinsUpdate: "channelPinsUpdate";
1634
- readonly InviteCreate: "inviteCreate";
1635
- readonly InviteDelete: "inviteDelete";
1636
- readonly TypingStart: "typingStart";
1637
- readonly UserUpdate: "userUpdate";
1638
- readonly PresenceUpdate: "presenceUpdate";
1639
- readonly VoiceStateUpdate: "voiceStateUpdate";
1640
- readonly VoiceServerUpdate: "voiceServerUpdate";
1641
- readonly VoiceStatesSync: "voiceStatesSync";
1642
- readonly WebhooksUpdate: "webhooksUpdate";
1643
- readonly Resumed: "resumed";
1644
- readonly Error: "error";
1645
- readonly Debug: "debug";
1646
- };
1647
-
1648
- /** Result of {@link UsersManager.fetchWithProfile}. */
1649
- interface FetchedUserWithProfile {
1650
- /** The user (cached in client.users). */
1651
- user: User;
1652
- /** Raw user data from GET /users/{id}. */
1653
- userData: APIUserPartial;
1654
- /** Global profile (bio, pronouns, mutual guilds, etc.). Null if unavailable. */
1655
- globalProfile: APIProfileResponse | null;
1656
- /** Server-specific profile when guildId was provided. Null if unavailable. */
1657
- serverProfile: APIProfileResponse | null;
1658
- /** Guild member when guildId was provided and user is in the guild. Null otherwise. */
1659
- member: GuildMember | null;
1660
- /** Raw member data when member exists (for premium_since, etc.). */
1661
- memberData: (APIGuildMember & {
1662
- user: {
1663
- id: string;
1664
- };
1665
- }) | null;
1666
- }
1667
- /**
1668
- * Manages users with fetch and profile helpers.
1669
- * Extends Collection so you can use .get(), .set(), .filter(), etc.
1670
- */
1671
- declare class UsersManager extends Collection<string, User> {
1672
- private readonly client;
1673
- private readonly maxSize;
1674
- constructor(client: Client);
1675
- set(key: string, value: User): this;
1676
- /**
1677
- * Fetch a user by ID from the API.
1678
- * Updates cache if user already exists.
1679
- * @param userId - Snowflake of the user
1680
- * @returns The user
1681
- * @throws FluxerError (or REST error) if user not found
1682
- * @example
1683
- * const user = await client.users.fetch(userId);
1684
- * console.log(user.username);
1685
- */
1686
- fetch(userId: string): Promise<User>;
1687
- /**
1688
- * Fetch a user with full profile and optional guild context.
1689
- * Returns user, global profile, server profile (when guildId), and member (when guildId).
1690
- * Ideal for userinfo commands.
1691
- * @param userId - Snowflake of the user
1692
- * @param options - Optional guildId for server profile and member data
1693
- * @returns User, raw data, profiles, and member (when in guild)
1694
- * @throws FluxerError (or REST error) if user not found
1695
- * @example
1696
- * const { user, globalProfile, serverProfile, member } = await client.users.fetchWithProfile(
1697
- * userId,
1698
- * { guildId: message.guildId ?? undefined },
1699
- * );
1700
- */
1701
- fetchWithProfile(userId: string, options?: {
1702
- guildId?: string | null;
1703
- }): Promise<FetchedUserWithProfile>;
1704
- }
1705
-
1706
- /** Minimal message data for MessageDelete when the full message is not available. */
1707
- interface PartialMessage {
1708
- id: string;
1709
- channelId: string;
1710
- channel?: Channel | null;
1711
- /** Message content, when provided by the gateway (e.g. Fluxer). */
1712
- content?: string | null;
1713
- /** Author user ID, when provided by the gateway (e.g. Fluxer). */
1714
- authorId?: string | null;
1715
- }
1716
-
1717
- /**
1718
- * Callback parameter types for client events. Use with client.on(Events.X, handler).
1719
- * @see Events
1720
- */
1721
- interface ClientEvents {
1722
- [Events.Ready]: [];
1723
- [Events.MessageCreate]: [message: Message];
1724
- [Events.MessageUpdate]: [oldMessage: Message | null, newMessage: Message];
1725
- [Events.MessageDelete]: [message: PartialMessage];
1726
- [Events.MessageReactionAdd]: [
1727
- reaction: MessageReaction,
1728
- user: User,
1729
- messageId: string,
1730
- channelId: string,
1731
- emoji: GatewayReactionEmoji,
1732
- userId: string
1733
- ];
1734
- [Events.MessageReactionRemove]: [
1735
- reaction: MessageReaction,
1736
- user: User,
1737
- messageId: string,
1738
- channelId: string,
1739
- emoji: GatewayReactionEmoji,
1740
- userId: string
1741
- ];
1742
- [Events.MessageReactionRemoveAll]: [data: GatewayMessageReactionRemoveAllDispatchData];
1743
- [Events.MessageReactionRemoveEmoji]: [data: GatewayMessageReactionRemoveEmojiDispatchData];
1744
- [Events.InteractionCreate]: [interaction: APIApplicationCommandInteraction];
1745
- [Events.GuildCreate]: [guild: Guild];
1746
- [Events.GuildUpdate]: [oldGuild: Guild, newGuild: Guild];
1747
- [Events.GuildDelete]: [guild: Guild];
1748
- [Events.ChannelCreate]: [channel: GuildChannel];
1749
- [Events.ChannelUpdate]: [oldChannel: Channel, newChannel: Channel];
1750
- [Events.ChannelDelete]: [channel: Channel];
1751
- [Events.GuildMemberAdd]: [member: GuildMember];
1752
- [Events.GuildMemberUpdate]: [oldMember: GuildMember, newMember: GuildMember];
1753
- [Events.GuildMemberRemove]: [member: GuildMember];
1754
- [Events.VoiceStateUpdate]: [data: GatewayVoiceStateUpdateDispatchData];
1755
- [Events.VoiceServerUpdate]: [data: GatewayVoiceServerUpdateDispatchData];
1756
- [Events.VoiceStatesSync]: [
1757
- data: {
1758
- guildId: string;
1759
- voiceStates: Array<{
1760
- user_id: string;
1761
- channel_id: string | null;
1762
- }>;
1763
- }
1764
- ];
1765
- [Events.MessageDeleteBulk]: [data: GatewayMessageDeleteBulkDispatchData];
1766
- [Events.GuildBanAdd]: [ban: GuildBan];
1767
- [Events.GuildBanRemove]: [ban: GuildBan];
1768
- [Events.GuildEmojisUpdate]: [data: GatewayGuildEmojisUpdateDispatchData];
1769
- [Events.GuildStickersUpdate]: [data: GatewayGuildStickersUpdateDispatchData];
1770
- [Events.GuildIntegrationsUpdate]: [data: GatewayGuildIntegrationsUpdateDispatchData];
1771
- [Events.GuildRoleCreate]: [data: GatewayGuildRoleCreateDispatchData];
1772
- [Events.GuildRoleUpdate]: [data: GatewayGuildRoleUpdateDispatchData];
1773
- [Events.GuildRoleDelete]: [data: GatewayGuildRoleDeleteDispatchData];
1774
- [Events.GuildScheduledEventCreate]: [data: GatewayGuildScheduledEventCreateDispatchData];
1775
- [Events.GuildScheduledEventUpdate]: [data: GatewayGuildScheduledEventUpdateDispatchData];
1776
- [Events.GuildScheduledEventDelete]: [data: GatewayGuildScheduledEventDeleteDispatchData];
1777
- [Events.ChannelPinsUpdate]: [data: GatewayChannelPinsUpdateDispatchData];
1778
- [Events.InviteCreate]: [invite: Invite];
1779
- [Events.InviteDelete]: [data: GatewayInviteDeleteDispatchData];
1780
- [Events.TypingStart]: [data: GatewayTypingStartDispatchData];
1781
- [Events.UserUpdate]: [data: GatewayUserUpdateDispatchData];
1782
- [Events.PresenceUpdate]: [data: GatewayPresenceUpdateDispatchData];
1783
- [Events.WebhooksUpdate]: [data: GatewayWebhooksUpdateDispatchData];
1784
- [Events.Resumed]: [];
1785
- [Events.Error]: [error: Error];
1786
- [Events.Debug]: [message: string];
1787
- }
1788
- /** Typed event handler methods. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
1789
- type ClientEventMethods = {
1790
- [K in keyof typeof Events]: (cb: (...args: ClientEvents[(typeof Events)[K]]) => void) => Client;
1791
- };
1792
- /** Main Fluxer bot client. Connects to the gateway, emits events, and provides REST access. */
1793
- declare class Client extends EventEmitter {
1794
- readonly options: ClientOptions;
1795
- readonly rest: REST;
1796
- readonly guilds: GuildManager;
1797
- readonly channels: ChannelManager;
1798
- readonly users: UsersManager;
1799
- /** Typed event handlers. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
1800
- readonly events: ClientEventMethods;
1801
- /** The authenticated bot user. Null until READY is received. */
1802
- user: ClientUser | null;
1803
- /** Timestamp when the client became ready. Null until READY is received. */
1804
- readyAt: Date | null;
1805
- private _ws;
1806
- /** When waitForGuilds, set of guild IDs we're waiting for GUILD_CREATE on. Null when not waiting. */
1807
- _pendingGuildIds: Set<string> | null;
1808
- /** Timeout for guild stream when READY has no guilds (gateway sends only GUILD_CREATE). Cleared in finally. */
1809
- private _guildStreamSettleTimeout;
1810
- /** Per-channel message cache (channelId -> messageId -> APIMessage). Used when options.cache.messages > 0. */
1811
- private _messageCaches;
1812
- /** @param options - Token, REST config, WebSocket, presence, etc. */
1813
- constructor(options?: ClientOptions);
1814
- /**
1815
- * Resolve an emoji argument to the API format (unicode or "name:id").
1816
- * Supports: <:name:id>, :name:, name:id, { name, id }, unicode.
1817
- * When id is missing (e.g. :name:), fetches guild emojis if guildId provided.
1818
- * When reacting in a guild channel, custom emojis must be from that guild.
1819
- * @param emoji - Emoji string or object
1820
- * @param guildId - Guild ID for resolving custom emoji by name (required when id is missing)
1821
- * @returns API-formatted string for reactions
1822
- */
1823
- resolveEmoji(emoji: string | {
1824
- name: string;
1825
- id?: string;
1826
- animated?: boolean;
1827
- }, guildId?: string | null): Promise<string>;
1828
- /**
1829
- * Asserts that a custom emoji (by id) belongs to the given guild.
1830
- * Used when reacting in guild channels to reject emojis from other servers.
1831
- * @throws FluxerError with EMOJI_NOT_IN_GUILD if the emoji is not in the guild
1832
- */
1833
- private assertEmojiInGuild;
1834
- /**
1835
- * Fetch instance info (API URL, gateway URL, features). GET /instance.
1836
- * Does not require authentication.
1837
- */
1838
- fetchInstance(): Promise<APIInstance>;
1839
- /**
1840
- * Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
1841
- * @param channelId - Snowflake of the channel
1842
- * @param messageId - Snowflake of the message
1843
- * @returns The message
1844
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
1845
- * @deprecated Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.resolve(channelId))?.messages?.fetch(messageId)
1846
- * @example
1847
- * const channel = await client.channels.resolve(channelId);
1848
- * const message = await channel?.messages?.fetch(messageId);
1849
- */
1850
- fetchMessage(channelId: string, messageId: string): Promise<Message>;
1851
- /**
1852
- * Send a message to any channel by ID. Shorthand for client.channels.send().
1853
- * Works even when the channel is not cached.
1854
- * @deprecated Use client.channels.send(channelId, payload).
1855
- */
1856
- sendToChannel(channelId: string, payload: string | MessageSendOptions): Promise<Message>;
1857
- /**
1858
- * Get the message cache for a channel. Returns null if message caching is disabled.
1859
- * Used by MessageManager.get() and event handlers.
1860
- * @internal
1861
- */
1862
- _getMessageCache(channelId: string): Map<string, APIMessage> | null;
1863
- /**
1864
- * Add a message to the channel cache. Evicts oldest (FIFO) when over limit.
1865
- * @internal
1866
- */
1867
- _addMessageToCache(channelId: string, data: APIMessage): void;
1868
- /**
1869
- * Remove a message from the channel cache.
1870
- * @internal
1871
- */
1872
- _removeMessageFromCache(channelId: string, messageId: string): void;
1873
- /**
1874
- * Get or create a User from API data. Caches in client.users.
1875
- * Updates existing user's username, avatar, etc. when fresh data is provided.
1876
- */
1877
- getOrCreateUser(data: APIUserPartial): User;
1878
- /** WebSocket manager. Throws if not logged in. */
1879
- get ws(): WebSocketManager;
1880
- /**
1881
- * Send a payload to the gateway (e.g. Voice State Update).
1882
- * @param shardId - Shard ID (use 0 for single-shard)
1883
- * @param payload - Gateway payload to send
1884
- */
1885
- sendToGateway(shardId: number, payload: GatewaySendPayload): void;
1886
- private handleDispatch;
1887
- /**
1888
- * Connect to the Fluxer gateway and authenticate.
1889
- * @param token - Bot token (e.g. from FLUXER_BOT_TOKEN)
1890
- */
1891
- login(token: string): Promise<string>;
1892
- /**
1893
- * Called when all guilds have been received (or immediately if not waiting).
1894
- * Sets readyAt, emits Ready, clears pending state.
1895
- */
1896
- _finalizeReady(): void;
1897
- /**
1898
- * Called by GUILD_CREATE handler when waitForGuilds is enabled.
1899
- * Removes guild from pending set; when empty, finalizes ready.
1900
- */
1901
- _onGuildReceived(guildId: string): void;
1902
- /** Disconnect from the gateway and clear cached data. */
1903
- destroy(): Promise<void>;
1904
- /** Returns true if the client has received Ready and `user` is set. */
1905
- isReady(): this is Client & {
1906
- user: NonNullable<Client['user']>;
1907
- };
1908
- /**
1909
- * Throws if the client is not ready. Use before accessing client.user or other post-ready state.
1910
- * @throws FluxerError with CLIENT_NOT_READY if client has not received Ready yet
1911
- */
1912
- assertReady(): asserts this is Client & {
1913
- user: NonNullable<Client['user']>;
1914
- };
1915
- static get Routes(): typeof Routes;
1916
- }
1917
-
1918
- interface FluxerErrorOptions {
1919
- code?: string;
1920
- cause?: Error;
1921
- }
1922
- declare class FluxerError extends Error {
1923
- readonly code?: string;
1924
- constructor(message: string, options?: FluxerErrorOptions);
1925
- }
1926
-
1927
- declare const ErrorCodes: {
1928
- readonly ClientNotReady: "CLIENT_NOT_READY";
1929
- readonly InvalidToken: "INVALID_TOKEN";
1930
- readonly AlreadyLoggedIn: "ALREADY_LOGGED_IN";
1931
- readonly ChannelNotFound: "CHANNEL_NOT_FOUND";
1932
- readonly MessageNotFound: "MESSAGE_NOT_FOUND";
1933
- readonly GuildNotFound: "GUILD_NOT_FOUND";
1934
- readonly MemberNotFound: "MEMBER_NOT_FOUND";
1935
- readonly RoleNotFound: "ROLE_NOT_FOUND";
1936
- readonly EmojiNotInGuild: "EMOJI_NOT_IN_GUILD";
1937
- readonly EmojiNotFound: "EMOJI_NOT_FOUND";
1938
- };
4
+ export { GatewayOpcodes, MessageAttachmentFlags, Routes } from '@fluxerjs/types';
5
+ import 'events';
6
+ import '@fluxerjs/rest';
7
+ import '@fluxerjs/ws';
8
+ import '@fluxerjs/collection';
1939
9
 
1940
10
  /** User Content CDN (avatars, icons, banners, emojis, attachments). */
1941
11
  declare const CDN_URL = "https://fluxerusercontent.com";
@@ -2004,4 +74,4 @@ declare function cdnMemberBannerURL(guildId: string, userId: string, bannerHash:
2004
74
  */
2005
75
  declare function cdnDefaultAvatarURL(userIdOrIndex: string | number): string;
2006
76
 
2007
- export { Base, CDN_URL, CategoryChannel, type CdnUrlOptions, Channel, ChannelManager, Client, type ClientEventMethods, type ClientEvents, ClientUser, type CollectedReaction, DMChannel, ErrorCodes, Events, type FetchedUserWithProfile, FluxerError, type FluxerErrorOptions, Guild, GuildBan, GuildChannel, GuildEmoji, GuildMember, GuildMemberManager, GuildMemberRoleManager, GuildSticker, Invite, LinkChannel, Message, MessageCollector, type MessageCollectorEndReason, type MessageCollectorOptions, type MessageEditOptions, MessageManager, MessageReaction, type MessageSendOptions, type PartialMessage, ReactionCollector, type ReactionCollectorEndReason, type ReactionCollectorOptions, type ReplyOptions, Role, type RoleResolvable, STATIC_CDN_URL, TextChannel, User, UsersManager, VoiceChannel, Webhook, type WebhookSendOptions, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };
77
+ export { CDN_URL, type CdnUrlOptions, STATIC_CDN_URL, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };