@fluxerjs/core 1.2.0 → 1.2.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.mjs CHANGED
@@ -1,214 +1,2412 @@
1
- import {
2
- GuildEmoji
3
- } from "./chunk-IHXSHE2Z.mjs";
4
- import {
5
- GuildSticker
6
- } from "./chunk-KR26CBFE.mjs";
7
- import {
8
- Guild,
9
- GuildMemberManager
10
- } from "./chunk-YGXCMETR.mjs";
11
- import {
12
- MessageReaction
13
- } from "./chunk-75ODDXY3.mjs";
14
- import {
15
- ClientUser,
16
- User
17
- } from "./chunk-U33GNMEZ.mjs";
18
- import {
19
- Message,
20
- ReactionCollector
21
- } from "./chunk-HVCL7QLT.mjs";
22
- import {
23
- Webhook
24
- } from "./chunk-3JVE6RW7.mjs";
25
- import {
26
- Invite
27
- } from "./chunk-QEXIYXXU.mjs";
28
- import {
29
- CategoryChannel,
30
- Channel,
31
- DMChannel,
32
- GuildChannel,
33
- LinkChannel,
34
- MessageCollector,
35
- MessageManager,
36
- TextChannel,
37
- VoiceChannel
38
- } from "./chunk-IRDYSGQO.mjs";
39
- import {
40
- ErrorCodes,
41
- FluxerError
42
- } from "./chunk-6S3BDHBI.mjs";
43
- import {
44
- Events
45
- } from "./chunk-AH7KYH2Z.mjs";
46
- import {
47
- buildSendBody,
48
- resolveMessageFiles
49
- } from "./chunk-VJDH54HJ.mjs";
50
- import {
51
- GuildMember
52
- } from "./chunk-24E6OQID.mjs";
53
- import {
54
- cdnAvatarURL,
55
- cdnBannerURL,
56
- cdnDefaultAvatarURL,
57
- cdnDisplayAvatarURL,
58
- cdnMemberAvatarURL,
59
- cdnMemberBannerURL
60
- } from "./chunk-G6F6VL4O.mjs";
61
- import {
62
- CDN_URL,
63
- STATIC_CDN_URL
64
- } from "./chunk-BKPVGBOT.mjs";
65
- import {
66
- Role
67
- } from "./chunk-2ZSMLDEI.mjs";
68
- import {
69
- GuildBan
70
- } from "./chunk-UXIF75BV.mjs";
71
- import {
72
- Base
73
- } from "./chunk-XNS4O6QJ.mjs";
74
-
75
1
  // src/client/Client.ts
76
- import { EventEmitter } from "events";
2
+ import { EventEmitter as EventEmitter3 } from "events";
77
3
  import { REST } from "@fluxerjs/rest";
78
4
  import { WebSocketManager } from "@fluxerjs/ws";
79
- import { Routes as Routes4 } from "@fluxerjs/types";
5
+ import {
6
+ Routes as Routes20
7
+ } from "@fluxerjs/types";
80
8
 
81
9
  // src/client/ChannelManager.ts
10
+ import { Collection as Collection4 } from "@fluxerjs/collection";
11
+ import { Routes as Routes6 } from "@fluxerjs/types";
12
+ import { emitDeprecationWarning as emitDeprecationWarning2 } from "@fluxerjs/util";
13
+ import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
14
+
15
+ // src/errors/FluxerError.ts
16
+ var FluxerError = class _FluxerError extends Error {
17
+ code;
18
+ constructor(message, options) {
19
+ super(message, options?.cause ? { cause: options.cause } : void 0);
20
+ this.name = "FluxerError";
21
+ this.code = options?.code;
22
+ Object.setPrototypeOf(this, _FluxerError.prototype);
23
+ }
24
+ };
25
+
26
+ // src/errors/ErrorCodes.ts
27
+ var ErrorCodes = {
28
+ ClientNotReady: "CLIENT_NOT_READY",
29
+ InvalidToken: "INVALID_TOKEN",
30
+ AlreadyLoggedIn: "ALREADY_LOGGED_IN",
31
+ ChannelNotFound: "CHANNEL_NOT_FOUND",
32
+ MessageNotFound: "MESSAGE_NOT_FOUND",
33
+ GuildNotFound: "GUILD_NOT_FOUND",
34
+ MemberNotFound: "MEMBER_NOT_FOUND",
35
+ RoleNotFound: "ROLE_NOT_FOUND",
36
+ EmojiNotInGuild: "EMOJI_NOT_IN_GUILD",
37
+ EmojiNotFound: "EMOJI_NOT_FOUND"
38
+ };
39
+
40
+ // src/util/messageUtils.ts
41
+ import { EmbedBuilder } from "@fluxerjs/builders";
42
+ var FILE_FETCH_TIMEOUT_MS = 3e4;
43
+ async function resolveMessageFiles(files) {
44
+ const result = [];
45
+ for (let i = 0; i < files.length; i++) {
46
+ const f = files[i];
47
+ const filename = f.filename ?? f.name;
48
+ if ("url" in f && f.url) {
49
+ if (!URL.canParse(f.url)) {
50
+ throw new Error(`Invalid file URL at index ${i}: ${f.url}`);
51
+ }
52
+ const res = await fetch(f.url, {
53
+ signal: AbortSignal.timeout(FILE_FETCH_TIMEOUT_MS)
54
+ });
55
+ if (!res.ok) {
56
+ throw new Error(`Failed to fetch file from ${f.url}: ${res.status} ${res.statusText}`);
57
+ }
58
+ const data = await res.arrayBuffer();
59
+ result.push({ name: f.name, data, filename });
60
+ } else if ("data" in f && f.data != null) {
61
+ result.push({ name: f.name, data: f.data, filename });
62
+ } else {
63
+ throw new Error(`File at index ${i} must have either "data" or "url"`);
64
+ }
65
+ }
66
+ return result;
67
+ }
68
+ function buildSendBody(options) {
69
+ const body = typeof options === "string" ? { content: options } : options;
70
+ const result = {};
71
+ if (body.content !== void 0) result.content = body.content;
72
+ if (body.embeds?.length) {
73
+ result.embeds = body.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
74
+ }
75
+ if (body.files?.length && body.attachments) {
76
+ result.attachments = body.attachments.map((a) => ({
77
+ id: a.id,
78
+ filename: a.filename,
79
+ ...a.title != null && { title: a.title },
80
+ ...a.description != null && { description: a.description },
81
+ ...a.flags != null && { flags: a.flags }
82
+ }));
83
+ } else if (body.files?.length) {
84
+ result.attachments = body.files.map((f, i) => ({
85
+ id: i,
86
+ filename: f.filename ?? f.name
87
+ }));
88
+ }
89
+ return result;
90
+ }
91
+
92
+ // src/client/MessageManager.ts
93
+ import { Routes as Routes2 } from "@fluxerjs/types";
94
+ import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
95
+
96
+ // src/structures/Base.ts
97
+ var Base = class {
98
+ };
99
+
100
+ // src/structures/Message.ts
101
+ import { Collection as Collection2 } from "@fluxerjs/collection";
102
+ import { MessageType, Routes } from "@fluxerjs/types";
103
+ import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
104
+
105
+ // src/util/ReactionCollector.ts
106
+ import { EventEmitter } from "events";
82
107
  import { Collection } from "@fluxerjs/collection";
83
- import { Routes } from "@fluxerjs/types";
108
+
109
+ // src/util/Events.ts
110
+ var Events = {
111
+ Ready: "ready",
112
+ MessageCreate: "messageCreate",
113
+ MessageUpdate: "messageUpdate",
114
+ MessageDelete: "messageDelete",
115
+ MessageDeleteBulk: "messageDeleteBulk",
116
+ MessageReactionAdd: "messageReactionAdd",
117
+ MessageReactionRemove: "messageReactionRemove",
118
+ MessageReactionRemoveAll: "messageReactionRemoveAll",
119
+ MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
120
+ InteractionCreate: "interactionCreate",
121
+ GuildCreate: "guildCreate",
122
+ GuildUpdate: "guildUpdate",
123
+ GuildDelete: "guildDelete",
124
+ GuildBanAdd: "guildBanAdd",
125
+ GuildBanRemove: "guildBanRemove",
126
+ GuildEmojisUpdate: "guildEmojisUpdate",
127
+ GuildStickersUpdate: "guildStickersUpdate",
128
+ GuildIntegrationsUpdate: "guildIntegrationsUpdate",
129
+ GuildMemberAdd: "guildMemberAdd",
130
+ GuildMemberUpdate: "guildMemberUpdate",
131
+ GuildMemberRemove: "guildMemberRemove",
132
+ GuildRoleCreate: "guildRoleCreate",
133
+ GuildRoleUpdate: "guildRoleUpdate",
134
+ GuildRoleDelete: "guildRoleDelete",
135
+ GuildScheduledEventCreate: "guildScheduledEventCreate",
136
+ GuildScheduledEventUpdate: "guildScheduledEventUpdate",
137
+ GuildScheduledEventDelete: "guildScheduledEventDelete",
138
+ ChannelCreate: "channelCreate",
139
+ ChannelUpdate: "channelUpdate",
140
+ ChannelDelete: "channelDelete",
141
+ ChannelPinsUpdate: "channelPinsUpdate",
142
+ InviteCreate: "inviteCreate",
143
+ InviteDelete: "inviteDelete",
144
+ TypingStart: "typingStart",
145
+ UserUpdate: "userUpdate",
146
+ PresenceUpdate: "presenceUpdate",
147
+ VoiceStateUpdate: "voiceStateUpdate",
148
+ VoiceServerUpdate: "voiceServerUpdate",
149
+ VoiceStatesSync: "voiceStatesSync",
150
+ WebhooksUpdate: "webhooksUpdate",
151
+ Resumed: "resumed",
152
+ Error: "error",
153
+ Debug: "debug"
154
+ };
155
+
156
+ // src/util/ReactionCollector.ts
157
+ var ReactionCollector = class extends EventEmitter {
158
+ client;
159
+ messageId;
160
+ channelId;
161
+ options;
162
+ collected = new Collection();
163
+ _timeout = null;
164
+ _ended = false;
165
+ _listener;
166
+ constructor(client, messageId, channelId, options = {}) {
167
+ super();
168
+ this.client = client;
169
+ this.messageId = messageId;
170
+ this.channelId = channelId;
171
+ this.options = {
172
+ filter: options.filter ?? (() => true),
173
+ time: options.time ?? 0,
174
+ max: options.max ?? 0
175
+ };
176
+ this._listener = (reaction, user, _msgId, chId, _emoji, userId) => {
177
+ if (this._ended || reaction.messageId !== this.messageId || chId !== this.channelId) return;
178
+ if (!this.options.filter(reaction, user)) return;
179
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
180
+ this.collected.set(key, { reaction, user });
181
+ this.emit("collect", reaction, user);
182
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
183
+ this.stop("limit");
184
+ }
185
+ };
186
+ this.client.on(Events.MessageReactionAdd, this._listener);
187
+ if (this.options.time > 0) {
188
+ this._timeout = setTimeout(() => this.stop("time"), this.options.time);
189
+ }
190
+ }
191
+ stop(reason = "user") {
192
+ if (this._ended) return;
193
+ this._ended = true;
194
+ this.client.off(Events.MessageReactionAdd, this._listener);
195
+ if (this._timeout) {
196
+ clearTimeout(this._timeout);
197
+ this._timeout = null;
198
+ }
199
+ this.emit("end", this.collected, reason);
200
+ }
201
+ on(event, listener) {
202
+ return super.on(event, listener);
203
+ }
204
+ emit(event, ...args) {
205
+ return super.emit(event, ...args);
206
+ }
207
+ };
208
+
209
+ // src/structures/Message.ts
210
+ var Message = class _Message extends Base {
211
+ client;
212
+ id;
213
+ channelId;
214
+ guildId;
215
+ author;
216
+ content;
217
+ createdAt;
218
+ editedAt;
219
+ pinned;
220
+ attachments;
221
+ type;
222
+ flags;
223
+ mentionEveryone;
224
+ tts;
225
+ embeds;
226
+ stickers;
227
+ reactions;
228
+ messageReference;
229
+ messageSnapshots;
230
+ call;
231
+ referencedMessage;
232
+ /** Webhook ID if this message was sent via webhook. Null otherwise. */
233
+ webhookId;
234
+ /** Users mentioned in this message. */
235
+ mentions;
236
+ /** Role IDs mentioned in this message. */
237
+ mentionRoles;
238
+ /** Client-side nonce for acknowledgment. Null if not provided. */
239
+ nonce;
240
+ /** Channel where this message was sent. Resolved from cache; null if not cached (e.g. DM channel not in cache). */
241
+ get channel() {
242
+ return this.client.channels.get(this.channelId) ?? null;
243
+ }
244
+ /** Guild where this message was sent. Resolved from cache; null for DMs or if not cached. */
245
+ get guild() {
246
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
247
+ }
248
+ /**
249
+ * Resolve the channel (from cache or API). Use when you need the channel and it may not be cached.
250
+ * @returns The channel
251
+ * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
252
+ */
253
+ async resolveChannel() {
254
+ return this.client.channels.resolve(this.channelId);
255
+ }
256
+ /**
257
+ * Resolve the guild (from cache or API). Returns null for DMs.
258
+ * @returns The guild, or null if this is a DM or guild not found
259
+ */
260
+ async resolveGuild() {
261
+ return this.guildId ? this.client.guilds.resolve(this.guildId) : null;
262
+ }
263
+ /** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
264
+ constructor(client, data) {
265
+ super();
266
+ this.client = client;
267
+ this.id = data.id;
268
+ this.channelId = data.channel_id;
269
+ this.guildId = data.guild_id ?? null;
270
+ this.author = client.getOrCreateUser(data.author);
271
+ this.content = data.content;
272
+ this.createdAt = new Date(data.timestamp);
273
+ this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
274
+ this.pinned = data.pinned;
275
+ this.attachments = new Collection2();
276
+ for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
277
+ this.type = data.type ?? MessageType.Default;
278
+ this.flags = data.flags ?? 0;
279
+ this.mentionEveryone = data.mention_everyone ?? false;
280
+ this.tts = data.tts ?? false;
281
+ this.embeds = data.embeds ?? [];
282
+ this.stickers = data.stickers ?? [];
283
+ this.reactions = data.reactions ?? [];
284
+ this.messageReference = data.message_reference ?? null;
285
+ this.messageSnapshots = data.message_snapshots ?? [];
286
+ this.call = data.call ?? null;
287
+ this.referencedMessage = data.referenced_message ? new _Message(client, data.referenced_message) : null;
288
+ this.webhookId = data.webhook_id ?? null;
289
+ this.mentions = (data.mentions ?? []).map((u) => client.getOrCreateUser(u));
290
+ this.mentionRoles = data.mention_roles ?? [];
291
+ this.nonce = data.nonce ?? null;
292
+ }
293
+ /**
294
+ * Send a message to this channel without replying. Use when you want a standalone message.
295
+ * @param options - Text content or object with content, embeds, and/or files
296
+ * @example
297
+ * await message.send('Pong!');
298
+ * await message.send({ embeds: [embed] }); // EmbedBuilder auto-converted
299
+ * await message.send({ content: 'File', files: [{ name: 'data.txt', data }] });
300
+ */
301
+ async send(options) {
302
+ const opts = typeof options === "string" ? { content: options } : options;
303
+ const body = buildSendBody(options);
304
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
305
+ const postOptions = files?.length ? { body, files } : { body };
306
+ const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
307
+ return new _Message(this.client, data);
308
+ }
309
+ /**
310
+ * Send a message to a specific channel. Use for logging, forwarding, or sending to another channel in the guild.
311
+ * @param channelId - Snowflake of the target channel (e.g. log channel ID)
312
+ * @param options - Text content or object with content and/or embeds
313
+ * @example
314
+ * await message.sendTo(logChannelId, 'User ' + message.author.username + ' said: ' + message.content);
315
+ * await message.sendTo(announceChannelId, { embeds: [embed] });
316
+ */
317
+ async sendTo(channelId, options) {
318
+ return this.client.channels.send(channelId, options);
319
+ }
320
+ /**
321
+ * Reply to this message (shows as a reply in the client).
322
+ * @param options - Text content or object with content, embeds, and/or files
323
+ * @example
324
+ * await message.reply('Pong!');
325
+ * await message.reply({ embeds: [embed] });
326
+ */
327
+ async reply(options) {
328
+ const opts = typeof options === "string" ? { content: options } : options;
329
+ const base = buildSendBody(options);
330
+ const body = {
331
+ ...base,
332
+ message_reference: {
333
+ channel_id: this.channelId,
334
+ message_id: this.id,
335
+ guild_id: this.guildId ?? void 0
336
+ }
337
+ };
338
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
339
+ const postOptions = files?.length ? { body, files } : { body };
340
+ const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
341
+ return new _Message(this.client, data);
342
+ }
343
+ /**
344
+ * Edit this message. Only the author (or admins) can edit.
345
+ * @param options - New content and/or embeds
346
+ */
347
+ async edit(options) {
348
+ const body = {};
349
+ if (options.content !== void 0) body.content = options.content;
350
+ if (options.embeds?.length) {
351
+ body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder2 ? e.toJSON() : e);
352
+ }
353
+ const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
354
+ body
355
+ });
356
+ return new _Message(this.client, data);
357
+ }
358
+ /**
359
+ * Create a reaction collector for this message.
360
+ * Collects reactions matching the filter until time expires or max is reached.
361
+ * @param options - Filter, time (ms), and max count
362
+ * @example
363
+ * const collector = message.createReactionCollector({ filter: (r, u) => u.id === userId, time: 10000 });
364
+ * collector.on('collect', (reaction, user) => console.log(user.username, 'reacted with', reaction.emoji.name));
365
+ * collector.on('end', (collected, reason) => { ... });
366
+ */
367
+ createReactionCollector(options) {
368
+ return new ReactionCollector(this.client, this.id, this.channelId, options);
369
+ }
370
+ /**
371
+ * Re-fetch this message from the API to get the latest content, embeds, reactions, etc.
372
+ * Use when you have a stale Message (e.g. from an old event or cache) and need fresh data.
373
+ * @returns The updated message
374
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message was deleted or does not exist
375
+ * @example
376
+ * const updated = await message.fetch();
377
+ * console.log('Latest content:', updated.content);
378
+ */
379
+ async fetch() {
380
+ return this.client.channels.fetchMessage(this.channelId, this.id);
381
+ }
382
+ /** Delete this message. */
383
+ async delete() {
384
+ await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
385
+ }
386
+ /**
387
+ * Delete a specific attachment from this message.
388
+ * DELETE /channels/{id}/messages/{id}/attachments/{attachmentId}.
389
+ */
390
+ async deleteAttachment(attachmentId) {
391
+ await this.client.rest.delete(
392
+ Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
393
+ { auth: true }
394
+ );
395
+ this.attachments.delete(attachmentId);
396
+ }
397
+ /** Pin this message to the channel. Requires Manage Messages permission. */
398
+ async pin() {
399
+ await this.client.rest.put(Routes.channelPinMessage(this.channelId, this.id));
400
+ this.pinned = true;
401
+ }
402
+ /** Unpin this message from the channel. Requires Manage Messages permission. */
403
+ async unpin() {
404
+ await this.client.rest.delete(Routes.channelPinMessage(this.channelId, this.id));
405
+ this.pinned = false;
406
+ }
407
+ /**
408
+ * Format emoji for reaction API: unicode string or "name:id" for custom.
409
+ * For string resolution (e.g. :name:), use client.resolveEmoji; Message methods resolve automatically when guildId is available.
410
+ */
411
+ static formatEmoji(emoji) {
412
+ if (typeof emoji === "string") return emoji;
413
+ return `${emoji.name}:${emoji.id}`;
414
+ }
415
+ resolveEmojiForReaction(emoji) {
416
+ return this.client.resolveEmoji(emoji, this.guildId);
417
+ }
418
+ /**
419
+ * Add a reaction to this message (as the bot).
420
+ * @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
421
+ */
422
+ async react(emoji) {
423
+ const emojiStr = await this.resolveEmojiForReaction(emoji);
424
+ const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
425
+ await this.client.rest.put(route);
426
+ }
427
+ /**
428
+ * Remove the bot's reaction, or a specific user's reaction if userId is provided.
429
+ * @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`
430
+ * @param userId - If provided, removes that user's reaction (requires moderator permissions)
431
+ */
432
+ async removeReaction(emoji, userId) {
433
+ const emojiStr = await this.resolveEmojiForReaction(emoji);
434
+ const route = `${Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
435
+ await this.client.rest.delete(route);
436
+ }
437
+ /**
438
+ * Remove all reactions from this message.
439
+ * Requires moderator permissions.
440
+ */
441
+ async removeAllReactions() {
442
+ await this.client.rest.delete(Routes.channelMessageReactions(this.channelId, this.id));
443
+ }
444
+ /**
445
+ * Remove all reactions of a specific emoji from this message.
446
+ * @param emoji - Unicode emoji, custom `{ name, id }`, `:name:`, `name:id`, or `<:name:id>`. Requires moderator permissions.
447
+ */
448
+ async removeReactionEmoji(emoji) {
449
+ const emojiStr = await this.resolveEmojiForReaction(emoji);
450
+ await this.client.rest.delete(Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
451
+ }
452
+ /**
453
+ * Fetch users who reacted with the given emoji.
454
+ * @param emoji - Unicode emoji or custom `{ name, id }`
455
+ * @param options - limit (1–100), after (user ID for pagination)
456
+ * @returns Array of User objects
457
+ */
458
+ async fetchReactionUsers(emoji, options) {
459
+ const emojiStr = await this.resolveEmojiForReaction(emoji);
460
+ const params = new URLSearchParams();
461
+ if (options?.limit != null) params.set("limit", String(options.limit));
462
+ if (options?.after) params.set("after", options.after);
463
+ const qs = params.toString();
464
+ const route = Routes.channelMessageReaction(this.channelId, this.id, emojiStr) + (qs ? `?${qs}` : "");
465
+ const data = await this.client.rest.get(route);
466
+ const list = Array.isArray(data) ? data : data?.users ?? [];
467
+ return list.map((u) => this.client.getOrCreateUser(u));
468
+ }
469
+ };
470
+
471
+ // src/client/MessageManager.ts
472
+ var MessageManager = class {
473
+ constructor(client, channelId) {
474
+ this.client = client;
475
+ this.channelId = channelId;
476
+ }
477
+ /**
478
+ * Fetch a message by ID from this channel.
479
+ * @param messageId - Snowflake of the message
480
+ * @returns The message
481
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
482
+ */
483
+ async fetch(messageId) {
484
+ try {
485
+ const data = await this.client.rest.get(
486
+ Routes2.channelMessage(this.channelId, messageId)
487
+ );
488
+ return new Message(this.client, data);
489
+ } catch (err) {
490
+ if (err instanceof RateLimitError) throw err;
491
+ if (err instanceof FluxerAPIError && err.statusCode === 404) {
492
+ throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
493
+ code: ErrorCodes.MessageNotFound,
494
+ cause: err
495
+ });
496
+ }
497
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
498
+ }
499
+ }
500
+ };
501
+
502
+ // src/util/MessageCollector.ts
503
+ import { EventEmitter as EventEmitter2 } from "events";
504
+ import { Collection as Collection3 } from "@fluxerjs/collection";
505
+ var MessageCollector = class extends EventEmitter2 {
506
+ client;
507
+ channelId;
508
+ options;
509
+ collected = new Collection3();
510
+ _timeout = null;
511
+ _ended = false;
512
+ _listener;
513
+ constructor(client, channelId, options = {}) {
514
+ super();
515
+ this.client = client;
516
+ this.channelId = channelId;
517
+ this.options = {
518
+ filter: options.filter ?? (() => true),
519
+ time: options.time ?? 0,
520
+ max: options.max ?? 0
521
+ };
522
+ this._listener = (message) => {
523
+ if (this._ended || message.channelId !== this.channelId) return;
524
+ if (!this.options.filter(message)) return;
525
+ this.collected.set(message.id, message);
526
+ this.emit("collect", message);
527
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
528
+ this.stop("limit");
529
+ }
530
+ };
531
+ this.client.on(Events.MessageCreate, this._listener);
532
+ if (this.options.time > 0) {
533
+ this._timeout = setTimeout(() => this.stop("time"), this.options.time);
534
+ }
535
+ }
536
+ stop(reason = "user") {
537
+ if (this._ended) return;
538
+ this._ended = true;
539
+ this.client.off(Events.MessageCreate, this._listener);
540
+ if (this._timeout) {
541
+ clearTimeout(this._timeout);
542
+ this._timeout = null;
543
+ }
544
+ this.emit("end", this.collected, reason);
545
+ }
546
+ on(event, listener) {
547
+ return super.on(event, listener);
548
+ }
549
+ emit(event, ...args) {
550
+ return super.emit(event, ...args);
551
+ }
552
+ };
553
+
554
+ // src/structures/Channel.ts
555
+ import { ChannelType, Routes as Routes5 } from "@fluxerjs/types";
84
556
  import { emitDeprecationWarning } from "@fluxerjs/util";
85
- import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
86
- var ChannelManager = class extends Collection {
87
- constructor(client) {
557
+
558
+ // src/structures/Webhook.ts
559
+ import { Routes as Routes3 } from "@fluxerjs/types";
560
+
561
+ // src/util/Constants.ts
562
+ var CDN_URL = "https://fluxerusercontent.com";
563
+ var STATIC_CDN_URL = "https://fluxerstatic.com";
564
+
565
+ // src/util/cdn.ts
566
+ function getExtension(hash, options) {
567
+ const ext = options?.extension ?? "png";
568
+ if (hash?.startsWith("a_")) return "gif";
569
+ return ext;
570
+ }
571
+ function appendSize(options) {
572
+ return options?.size ? `?size=${options.size}` : "";
573
+ }
574
+ function cdnAvatarURL(userId, avatarHash, options) {
575
+ if (!avatarHash) return null;
576
+ const ext = getExtension(avatarHash, options);
577
+ const size = appendSize(options);
578
+ return `${CDN_URL}/avatars/${userId}/${avatarHash}.${ext}${size}`;
579
+ }
580
+ function cdnDisplayAvatarURL(userId, avatarHash, options) {
581
+ return cdnAvatarURL(userId, avatarHash, options) ?? cdnDefaultAvatarURL(userId);
582
+ }
583
+ function cdnBannerURL(resourceId, bannerHash, options) {
584
+ if (!bannerHash) return null;
585
+ const ext = getExtension(bannerHash, options);
586
+ const size = appendSize(options);
587
+ return `${CDN_URL}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
588
+ }
589
+ function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
590
+ if (!avatarHash) return null;
591
+ const ext = getExtension(avatarHash, options);
592
+ const size = appendSize(options);
593
+ return `${CDN_URL}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
594
+ }
595
+ function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
596
+ if (!bannerHash) return null;
597
+ const ext = getExtension(bannerHash, options);
598
+ const size = appendSize(options);
599
+ return `${CDN_URL}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
600
+ }
601
+ function cdnDefaultAvatarURL(userIdOrIndex) {
602
+ const index = typeof userIdOrIndex === "string" ? Number(BigInt(userIdOrIndex) % 6n) : Math.abs(Math.floor(userIdOrIndex) % 6);
603
+ return `${STATIC_CDN_URL}/avatars/${index}.png`;
604
+ }
605
+
606
+ // src/structures/Webhook.ts
607
+ var Webhook = class _Webhook extends Base {
608
+ client;
609
+ id;
610
+ guildId;
611
+ channelId;
612
+ name;
613
+ avatar;
614
+ /** Present only when webhook was created via createWebhook(); not returned when fetching. */
615
+ token;
616
+ /** User who created the webhook. */
617
+ user;
618
+ /** @param data - API webhook from POST /channels/{id}/webhooks (has token) or GET /webhooks/{id} (no token) */
619
+ constructor(client, data) {
88
620
  super();
89
621
  this.client = client;
90
- this.maxSize = client.options?.cache?.channels ?? 0;
622
+ this.id = data.id;
623
+ this.guildId = data.guild_id;
624
+ this.channelId = data.channel_id;
625
+ this.name = data.name ?? "Unknown";
626
+ this.avatar = data.avatar ?? null;
627
+ this.token = data.token ?? null;
628
+ this.user = client.getOrCreateUser(data.user);
629
+ }
630
+ /**
631
+ * Get the URL for this webhook's avatar.
632
+ * Returns null if the webhook has no custom avatar.
633
+ */
634
+ avatarURL(options) {
635
+ return cdnAvatarURL(this.id, this.avatar, options);
636
+ }
637
+ /** Delete this webhook. Requires bot token with Manage Webhooks permission. */
638
+ async delete() {
639
+ await this.client.rest.delete(Routes3.webhook(this.id), { auth: true });
640
+ }
641
+ /**
642
+ * Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
643
+ * @param options - Fields to update (name, avatar, channel_id when using bot auth)
644
+ * @returns This webhook instance with updated fields
645
+ */
646
+ async edit(options) {
647
+ const body = {};
648
+ if (options.name !== void 0) body.name = options.name;
649
+ if (options.avatar !== void 0) body.avatar = options.avatar;
650
+ if ("channel_id" in options && options.channel_id !== void 0 && !this.token) {
651
+ body.channel_id = options.channel_id;
652
+ }
653
+ if (this.token) {
654
+ const data2 = await this.client.rest.patch(Routes3.webhookExecute(this.id, this.token), {
655
+ body,
656
+ auth: false
657
+ });
658
+ const w2 = data2;
659
+ this.name = w2.name ?? this.name;
660
+ this.avatar = w2.avatar ?? null;
661
+ return this;
662
+ }
663
+ const data = await this.client.rest.patch(Routes3.webhook(this.id), {
664
+ body,
665
+ auth: true
666
+ });
667
+ const w = data;
668
+ this.name = w.name ?? this.name;
669
+ this.avatar = w.avatar ?? null;
670
+ this.channelId = w.channel_id ?? this.channelId;
671
+ return this;
672
+ }
673
+ /**
674
+ * Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
675
+ * @param options - Text content or object with content, embeds, username, avatar_url, tts, files, attachments
676
+ * @param wait - If true, waits for the API and returns the created Message; otherwise returns void (204)
677
+ * @throws Error if token is not available
678
+ * @example
679
+ * await webhook.send('Hello!');
680
+ * await webhook.send({ embeds: [embed] });
681
+ * await webhook.send({ content: 'File attached', files: [{ name: 'data.txt', data: buffer }] });
682
+ * const msg = await webhook.send({ content: 'Hi' }, true);
683
+ */
684
+ async send(options, wait) {
685
+ if (!this.token) {
686
+ throw new Error(
687
+ "Webhook token is required to send. The token is only returned when creating a webhook; fetched webhooks cannot send."
688
+ );
689
+ }
690
+ const opts = typeof options === "string" ? { content: options } : options;
691
+ const body = buildSendBody(options);
692
+ if (opts.username !== void 0) body.username = opts.username;
693
+ if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
694
+ if (opts.tts !== void 0) body.tts = opts.tts;
695
+ const route = Routes3.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
696
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
697
+ const postOptions = files?.length ? { body, files, auth: false } : { body, auth: false };
698
+ const data = await this.client.rest.post(route, postOptions);
699
+ if (wait && data) {
700
+ return new Message(this.client, data);
701
+ }
702
+ return void 0;
703
+ }
704
+ /**
705
+ * Fetch a webhook by ID using bot auth.
706
+ * @param client - The client instance
707
+ * @param webhookId - The webhook ID
708
+ * @returns Webhook without token (cannot send)
709
+ */
710
+ static async fetch(client, webhookId) {
711
+ const data = await client.rest.get(Routes3.webhook(webhookId));
712
+ return new _Webhook(client, data);
713
+ }
714
+ /**
715
+ * Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
716
+ * @param client - The client instance
717
+ * @param webhookId - The webhook ID
718
+ * @param token - The webhook token (from createWebhook or stored)
719
+ * @param options - Optional channelId, guildId, name for display
720
+ */
721
+ static fromToken(client, webhookId, token, options) {
722
+ return new _Webhook(client, {
723
+ id: webhookId,
724
+ guild_id: options?.guildId ?? "",
725
+ channel_id: options?.channelId ?? "",
726
+ name: options?.name ?? "Webhook",
727
+ avatar: null,
728
+ token,
729
+ user: { id: "", username: "webhook", discriminator: "0" }
730
+ });
731
+ }
732
+ };
733
+
734
+ // src/structures/Invite.ts
735
+ import { Routes as Routes4 } from "@fluxerjs/types";
736
+ var Invite = class extends Base {
737
+ client;
738
+ code;
739
+ type;
740
+ guild;
741
+ channel;
742
+ inviter;
743
+ memberCount;
744
+ presenceCount;
745
+ expiresAt;
746
+ temporary;
747
+ createdAt;
748
+ uses;
749
+ maxUses;
750
+ maxAge;
751
+ /** @param data - API invite from GET /invites/{code}, channel/guild invite list, or gateway INVITE_CREATE */
752
+ constructor(client, data) {
753
+ super();
754
+ this.client = client;
755
+ this.code = data.code;
756
+ this.type = data.type;
757
+ this.guild = data.guild;
758
+ this.channel = data.channel;
759
+ this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
760
+ this.memberCount = data.member_count ?? null;
761
+ this.presenceCount = data.presence_count ?? null;
762
+ this.expiresAt = data.expires_at ?? null;
763
+ this.temporary = data.temporary ?? null;
764
+ this.createdAt = data.created_at ?? null;
765
+ this.uses = data.uses ?? null;
766
+ this.maxUses = data.max_uses ?? null;
767
+ this.maxAge = data.max_age ?? null;
768
+ }
769
+ /** Full invite URL (https://fluxer.gg/{code} or instance-specific). */
770
+ get url() {
771
+ return `https://fluxer.gg/${this.code}`;
772
+ }
773
+ /**
774
+ * Resolve the guild from cache if available.
775
+ * @returns The guild, or null if not cached
776
+ */
777
+ getGuild() {
778
+ return this.guild?.id ? this.client.guilds.get(this.guild.id) ?? null : null;
779
+ }
780
+ /**
781
+ * Delete this invite.
782
+ * Requires Manage Guild or Create Instant Invite permission.
783
+ */
784
+ async delete() {
785
+ await this.client.rest.delete(Routes4.invite(this.code), { auth: true });
786
+ }
787
+ };
788
+
789
+ // src/structures/Channel.ts
790
+ var Channel = class _Channel extends Base {
791
+ /** Whether this channel has a send method (TextChannel, DMChannel). */
792
+ isSendable() {
793
+ return "send" in this;
794
+ }
795
+ /** Whether this channel is a DM or Group DM. */
796
+ isDM() {
797
+ return this.type === ChannelType.DM || this.type === ChannelType.GroupDM;
798
+ }
799
+ /** Whether this channel is voice-based (VoiceChannel). */
800
+ isVoice() {
801
+ return "bitrate" in this;
802
+ }
803
+ /** Create a DM channel from API data (type DM or GroupDM). */
804
+ static createDM(client, data) {
805
+ return new DMChannel(client, data);
806
+ }
807
+ client;
808
+ id;
809
+ type;
810
+ /** Channel name. Guild channels and Group DMs have names; 1:1 DMs are typically null. */
811
+ name;
812
+ /** Channel icon hash (Group DMs). Null if none. */
813
+ icon;
814
+ /** ISO timestamp when the last message was pinned. Null if never pinned. */
815
+ lastPinTimestamp;
816
+ /** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
817
+ constructor(client, data) {
818
+ super();
819
+ this.client = client;
820
+ this.id = data.id;
821
+ this.type = data.type;
822
+ this.name = data.name ?? null;
823
+ this.icon = data.icon ?? null;
824
+ this.lastPinTimestamp = data.last_pin_timestamp ?? null;
825
+ }
826
+ /**
827
+ * Create the appropriate channel subclass from API data.
828
+ * @param client - The client instance
829
+ * @param data - Channel data from the API
830
+ */
831
+ static from(client, data) {
832
+ const type = data.type ?? 0;
833
+ if (type === ChannelType.GuildText) return new TextChannel(client, data);
834
+ if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data);
835
+ if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data);
836
+ if (type === ChannelType.GuildLink || type === ChannelType.GuildLinkExtended)
837
+ return new LinkChannel(client, data);
838
+ return new GuildChannel(client, data);
839
+ }
840
+ /**
841
+ * Create a channel from API data, including DM and GroupDM.
842
+ * Used by ChannelManager.fetch() for GET /channels/{id}.
843
+ */
844
+ static fromOrCreate(client, data) {
845
+ const type = data.type ?? 0;
846
+ if (type === ChannelType.DM || type === ChannelType.GroupDM)
847
+ return _Channel.createDM(client, data);
848
+ return _Channel.from(client, data);
849
+ }
850
+ /**
851
+ * Bulk delete messages. Requires Manage Messages permission.
852
+ * @param messageIds - Array of message IDs to delete (2–100)
853
+ */
854
+ async bulkDeleteMessages(messageIds) {
855
+ await this.client.rest.post(Routes5.channelBulkDelete(this.id), {
856
+ body: { message_ids: messageIds },
857
+ auth: true
858
+ });
859
+ }
860
+ /**
861
+ * Send a typing indicator to the channel. Lasts ~10 seconds.
862
+ */
863
+ async sendTyping() {
864
+ await this.client.rest.post(Routes5.channelTyping(this.id), { auth: true });
865
+ }
866
+ };
867
+ var GuildChannel = class extends Channel {
868
+ guildId;
869
+ name;
870
+ position;
871
+ parentId;
872
+ /** Permission overwrites for roles and members. */
873
+ permissionOverwrites;
874
+ constructor(client, data) {
875
+ super(client, data);
876
+ this.guildId = data.guild_id ?? "";
877
+ this.name = data.name ?? null;
878
+ this.position = data.position;
879
+ this.parentId = data.parent_id ?? null;
880
+ this.permissionOverwrites = data.permission_overwrites ?? [];
881
+ }
882
+ /**
883
+ * Create a webhook in this channel.
884
+ * @param options - Webhook name and optional avatar URL
885
+ * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
886
+ */
887
+ async createWebhook(options) {
888
+ const data = await this.client.rest.post(Routes5.channelWebhooks(this.id), {
889
+ body: options,
890
+ auth: true
891
+ });
892
+ return new Webhook(this.client, data);
893
+ }
894
+ /**
895
+ * Fetch all webhooks in this channel.
896
+ * @returns Webhooks (includes token when listing from channel; can send via send())
897
+ */
898
+ async fetchWebhooks() {
899
+ const data = await this.client.rest.get(Routes5.channelWebhooks(this.id));
900
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
901
+ return list.map((w) => new Webhook(this.client, w));
902
+ }
903
+ /**
904
+ * Create an invite for this channel.
905
+ * @param options - max_uses (0–100), max_age (0–604800 seconds), unique, temporary
906
+ * Requires Create Instant Invite permission.
907
+ */
908
+ async createInvite(options) {
909
+ const body = {};
910
+ if (options?.max_uses != null) body.max_uses = options.max_uses;
911
+ if (options?.max_age != null) body.max_age = options.max_age;
912
+ if (options?.unique != null) body.unique = options.unique;
913
+ if (options?.temporary != null) body.temporary = options.temporary;
914
+ const data = await this.client.rest.post(Routes5.channelInvites(this.id), {
915
+ body: Object.keys(body).length ? body : void 0,
916
+ auth: true
917
+ });
918
+ return new Invite(this.client, data);
919
+ }
920
+ /**
921
+ * Fetch invites for this channel.
922
+ * Requires Manage Channel permission.
923
+ */
924
+ async fetchInvites() {
925
+ const data = await this.client.rest.get(Routes5.channelInvites(this.id));
926
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
927
+ return list.map((i) => new Invite(this.client, i));
928
+ }
929
+ /**
930
+ * Set or update a permission overwrite. PUT /channels/{id}/permissions/{overwriteId}.
931
+ * @param overwriteId - Role or member ID
932
+ * @param options - type (0=role, 1=member), allow, deny (permission bitfields)
933
+ */
934
+ async editPermission(overwriteId, options) {
935
+ await this.client.rest.put(Routes5.channelPermission(this.id, overwriteId), {
936
+ body: options,
937
+ auth: true
938
+ });
939
+ const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
940
+ const entry = {
941
+ id: overwriteId,
942
+ type: options.type,
943
+ allow: options.allow ?? "0",
944
+ deny: options.deny ?? "0"
945
+ };
946
+ if (idx >= 0) this.permissionOverwrites[idx] = entry;
947
+ else this.permissionOverwrites.push(entry);
948
+ }
949
+ /**
950
+ * Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
951
+ */
952
+ async deletePermission(overwriteId) {
953
+ await this.client.rest.delete(Routes5.channelPermission(this.id, overwriteId), { auth: true });
954
+ const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
955
+ if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
956
+ }
957
+ /**
958
+ * Edit this channel. PATCH /channels/{id}.
959
+ * Requires Manage Channel permission.
960
+ */
961
+ async edit(options) {
962
+ const data = await this.client.rest.patch(Routes5.channel(this.id), {
963
+ body: options,
964
+ auth: true
965
+ });
966
+ this.name = data.name ?? this.name;
967
+ this.parentId = data.parent_id ?? this.parentId;
968
+ this.permissionOverwrites = data.permission_overwrites ?? this.permissionOverwrites;
969
+ const self = this;
970
+ if ("topic" in self && "topic" in data) self.topic = data.topic ?? null;
971
+ if ("nsfw" in self && "nsfw" in data) self.nsfw = data.nsfw ?? false;
972
+ if ("rate_limit_per_user" in data) self.rateLimitPerUser = data.rate_limit_per_user ?? 0;
973
+ if ("bitrate" in self && "bitrate" in data) self.bitrate = data.bitrate ?? null;
974
+ if ("user_limit" in data) self.userLimit = data.user_limit ?? null;
975
+ if ("rtc_region" in data) self.rtcRegion = data.rtc_region ?? null;
976
+ return this;
977
+ }
978
+ /**
979
+ * Delete this channel. Requires Manage Channel permission.
980
+ * @param options - silent: if true, does not send a system message (default false)
981
+ */
982
+ async delete(options) {
983
+ const url = Routes5.channel(this.id) + (options?.silent ? "?silent=true" : "");
984
+ await this.client.rest.delete(url, { auth: true });
985
+ this.client.channels.delete(this.id);
986
+ const guild = this.client.guilds.get(this.guildId);
987
+ if (guild) guild.channels.delete(this.id);
988
+ }
989
+ };
990
+ var TextChannel = class extends GuildChannel {
991
+ topic;
992
+ nsfw;
993
+ rateLimitPerUser;
994
+ lastMessageId;
995
+ constructor(client, data) {
996
+ super(client, data);
997
+ this.topic = data.topic ?? null;
998
+ this.nsfw = data.nsfw ?? false;
999
+ this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
1000
+ this.lastMessageId = data.last_message_id ?? null;
1001
+ }
1002
+ /**
1003
+ * Send a message to this channel.
1004
+ * @param options - Text content or object with content, embeds, and/or files
1005
+ */
1006
+ async send(options) {
1007
+ const opts = typeof options === "string" ? { content: options } : options;
1008
+ const body = buildSendBody(options);
1009
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
1010
+ const postOptions = files?.length ? { body, files } : { body };
1011
+ const data = await this.client.rest.post(Routes5.channelMessages(this.id), postOptions);
1012
+ return new Message(this.client, data);
1013
+ }
1014
+ /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1015
+ get messages() {
1016
+ return new MessageManager(this.client, this.id);
1017
+ }
1018
+ /**
1019
+ * Create a message collector for this channel.
1020
+ * Collects messages matching the filter until time expires or max is reached.
1021
+ * @param options - Filter, time (ms), and max count
1022
+ * @example
1023
+ * const collector = channel.createMessageCollector({ filter: m => m.author.id === userId, time: 10000 });
1024
+ * collector.on('collect', m => console.log(m.content));
1025
+ * collector.on('end', (collected, reason) => { ... });
1026
+ */
1027
+ createMessageCollector(options) {
1028
+ return new MessageCollector(this.client, this.id, options);
1029
+ }
1030
+ /**
1031
+ * Fetch pinned messages in this channel.
1032
+ * @returns Pinned messages
1033
+ */
1034
+ async fetchPinnedMessages() {
1035
+ const data = await this.client.rest.get(Routes5.channelPins(this.id));
1036
+ const list = Array.isArray(data) ? data : data?.items ?? [];
1037
+ return list.map((item) => {
1038
+ const msg = typeof item === "object" && item && "message" in item ? item.message : item;
1039
+ return new Message(this.client, msg);
1040
+ });
1041
+ }
1042
+ /**
1043
+ * Fetch a message by ID from this channel.
1044
+ * @param messageId - Snowflake of the message
1045
+ * @returns The message, or null if not found
1046
+ * @deprecated Use channel.messages.fetch(messageId) instead.
1047
+ */
1048
+ async fetchMessage(messageId) {
1049
+ emitDeprecationWarning(
1050
+ "Channel.fetchMessage()",
1051
+ "Use channel.messages.fetch(messageId) instead."
1052
+ );
1053
+ return this.client.channels.fetchMessage(this.id, messageId);
1054
+ }
1055
+ };
1056
+ var CategoryChannel = class extends GuildChannel {
1057
+ };
1058
+ var VoiceChannel = class extends GuildChannel {
1059
+ bitrate;
1060
+ userLimit;
1061
+ rtcRegion;
1062
+ constructor(client, data) {
1063
+ super(client, data);
1064
+ this.bitrate = data.bitrate ?? null;
1065
+ this.userLimit = data.user_limit ?? null;
1066
+ this.rtcRegion = data.rtc_region ?? null;
1067
+ }
1068
+ };
1069
+ var LinkChannel = class extends GuildChannel {
1070
+ url;
1071
+ constructor(client, data) {
1072
+ super(client, data);
1073
+ this.url = data.url ?? null;
1074
+ }
1075
+ };
1076
+ var DMChannel = class extends Channel {
1077
+ lastMessageId;
1078
+ /** Group DM creator ID. Null for 1:1 DMs. */
1079
+ ownerId;
1080
+ /** Group DM recipients as User objects. Empty for 1:1 DMs. */
1081
+ recipients;
1082
+ /** Group DM member display names (userId -> nickname). */
1083
+ nicks;
1084
+ constructor(client, data) {
1085
+ super(client, data);
1086
+ this.lastMessageId = data.last_message_id ?? null;
1087
+ this.ownerId = data.owner_id ?? null;
1088
+ this.recipients = (data.recipients ?? []).map(
1089
+ (u) => client.getOrCreateUser(u)
1090
+ );
1091
+ this.nicks = data.nicks ?? {};
1092
+ }
1093
+ /**
1094
+ * Send a message to this DM channel.
1095
+ * @param options - Text content or object with content, embeds, and/or files
1096
+ */
1097
+ async send(options) {
1098
+ const opts = typeof options === "string" ? { content: options } : options;
1099
+ const body = buildSendBody(options);
1100
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
1101
+ const postOptions = files?.length ? { body, files } : { body };
1102
+ const data = await this.client.rest.post(Routes5.channelMessages(this.id), postOptions);
1103
+ return new Message(this.client, data);
1104
+ }
1105
+ /** Message manager for this channel. Use channel.messages.fetch(messageId). */
1106
+ get messages() {
1107
+ return new MessageManager(this.client, this.id);
1108
+ }
1109
+ /**
1110
+ * Create a message collector for this DM channel.
1111
+ * @param options - Filter, time (ms), and max count
1112
+ */
1113
+ createMessageCollector(options) {
1114
+ return new MessageCollector(this.client, this.id, options);
1115
+ }
1116
+ /**
1117
+ * Fetch pinned messages in this DM channel.
1118
+ * @returns Pinned messages
1119
+ */
1120
+ async fetchPinnedMessages() {
1121
+ const data = await this.client.rest.get(Routes5.channelPins(this.id));
1122
+ const list = Array.isArray(data) ? data : data?.items ?? [];
1123
+ return list.map((item) => {
1124
+ const msg = typeof item === "object" && item && "message" in item ? item.message : item;
1125
+ return new Message(this.client, msg);
1126
+ });
1127
+ }
1128
+ /**
1129
+ * Fetch a message by ID from this DM channel.
1130
+ * @param messageId - Snowflake of the message
1131
+ * @returns The message, or null if not found
1132
+ * @deprecated Use channel.messages.fetch(messageId) instead.
1133
+ */
1134
+ async fetchMessage(messageId) {
1135
+ emitDeprecationWarning(
1136
+ "Channel.fetchMessage()",
1137
+ "Use channel.messages.fetch(messageId) instead."
1138
+ );
1139
+ return this.client.channels.fetchMessage(this.id, messageId);
1140
+ }
1141
+ /**
1142
+ * Add a recipient to this Group DM. Requires Group DM (type GroupDM).
1143
+ * PUT /channels/{id}/recipients/{userId}.
1144
+ */
1145
+ async addRecipient(userId) {
1146
+ await this.client.rest.put(Routes5.channelRecipient(this.id, userId), { auth: true });
1147
+ const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
1148
+ if (user) this.recipients.push(user);
1149
+ }
1150
+ /**
1151
+ * Remove a recipient from this Group DM. Requires Group DM (type GroupDM).
1152
+ * DELETE /channels/{id}/recipients/{userId}.
1153
+ * @param options - silent: if true, does not send a system message (default false)
1154
+ */
1155
+ async removeRecipient(userId, options) {
1156
+ const url = Routes5.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
1157
+ await this.client.rest.delete(url, { auth: true });
1158
+ const idx = this.recipients.findIndex((u) => u.id === userId);
1159
+ if (idx >= 0) this.recipients.splice(idx, 1);
1160
+ }
1161
+ };
1162
+
1163
+ // src/client/ChannelManager.ts
1164
+ var ChannelManager = class extends Collection4 {
1165
+ constructor(client) {
1166
+ super();
1167
+ this.client = client;
1168
+ this.maxSize = client.options?.cache?.channels ?? 0;
1169
+ }
1170
+ maxSize;
1171
+ set(key, value) {
1172
+ if (this.maxSize > 0 && this.size >= this.maxSize && !this.has(key)) {
1173
+ const firstKey = this.keys().next().value;
1174
+ if (firstKey !== void 0) this.delete(firstKey);
1175
+ }
1176
+ return super.set(key, value);
1177
+ }
1178
+ /**
1179
+ * Get a channel from cache or fetch from the API if not present.
1180
+ * Convenience helper to avoid repeating `client.channels.get(id) ?? (await client.channels.fetch(id))`.
1181
+ * @param channelId - Snowflake of the channel
1182
+ * @returns The channel
1183
+ * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
1184
+ * @example
1185
+ * const channel = await client.channels.resolve(message.channelId);
1186
+ * if (channel?.isSendable()) await channel.send('Hello!');
1187
+ */
1188
+ async resolve(channelId) {
1189
+ return this.get(channelId) ?? this.fetch(channelId);
1190
+ }
1191
+ /**
1192
+ * Fetch a channel by ID from the API (or return from cache if present).
1193
+ * @param channelId - Snowflake of the channel
1194
+ * @returns The channel
1195
+ * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
1196
+ * @example
1197
+ * const channel = await client.channels.fetch(channelId);
1198
+ * if (channel?.isSendable()) await channel.send('Hello!');
1199
+ */
1200
+ async fetch(channelId) {
1201
+ const cached = this.get(channelId);
1202
+ if (cached) return cached;
1203
+ try {
1204
+ const data = await this.client.rest.get(Routes6.channel(channelId));
1205
+ const channel = Channel.fromOrCreate(this.client, data);
1206
+ if (!channel) {
1207
+ throw new FluxerError("Channel data invalid or unsupported type", {
1208
+ code: ErrorCodes.ChannelNotFound
1209
+ });
1210
+ }
1211
+ this.set(channel.id, channel);
1212
+ if ("guildId" in channel) {
1213
+ const guild = this.client.guilds.get(channel.guildId);
1214
+ if (guild) guild.channels.set(channel.id, channel);
1215
+ }
1216
+ return channel;
1217
+ } catch (err) {
1218
+ if (err instanceof RateLimitError2) throw err;
1219
+ if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
1220
+ throw new FluxerError(`Channel ${channelId} not found`, {
1221
+ code: ErrorCodes.ChannelNotFound,
1222
+ cause: err
1223
+ });
1224
+ }
1225
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
1226
+ }
1227
+ }
1228
+ /**
1229
+ * Fetch a message by ID from the API.
1230
+ * @param channelId - Snowflake of the channel
1231
+ * @param messageId - Snowflake of the message
1232
+ * @returns The message
1233
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
1234
+ * @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.resolve(channelId))?.messages?.fetch(messageId).
1235
+ * @example
1236
+ * const channel = await client.channels.resolve(channelId);
1237
+ * const message = await channel?.messages?.fetch(messageId);
1238
+ */
1239
+ async fetchMessage(channelId, messageId) {
1240
+ emitDeprecationWarning2(
1241
+ "ChannelManager.fetchMessage()",
1242
+ "Use channel.messages.fetch(messageId). Prefer (await client.channels.resolve(channelId))?.messages?.fetch(messageId)."
1243
+ );
1244
+ try {
1245
+ const data = await this.client.rest.get(
1246
+ Routes6.channelMessage(channelId, messageId)
1247
+ );
1248
+ return new Message(this.client, data);
1249
+ } catch (err) {
1250
+ if (err instanceof RateLimitError2) throw err;
1251
+ if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
1252
+ throw new FluxerError(`Message ${messageId} not found in channel ${channelId}`, {
1253
+ code: ErrorCodes.MessageNotFound,
1254
+ cause: err
1255
+ });
1256
+ }
1257
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
1258
+ }
1259
+ }
1260
+ /**
1261
+ * Send a message to a channel by ID. Works even when the channel is not cached.
1262
+ * Skips the fetch when you only need to send.
1263
+ * @param channelId - Snowflake of the channel (text channel or DM)
1264
+ * @param payload - Text content or object with content, embeds, and/or files
1265
+ * @returns The created message
1266
+ * @example
1267
+ * await client.channels.send(logChannelId, 'User joined!');
1268
+ * await client.channels.send(channelId, { embeds: [embed] });
1269
+ * await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
1270
+ */
1271
+ async send(channelId, payload) {
1272
+ const opts = typeof payload === "string" ? { content: payload } : payload;
1273
+ const body = buildSendBody(payload);
1274
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
1275
+ const postOptions = files?.length ? { body, files } : { body };
1276
+ const data = await this.client.rest.post(Routes6.channelMessages(channelId), postOptions);
1277
+ return new Message(this.client, data);
1278
+ }
1279
+ };
1280
+
1281
+ // src/client/GuildManager.ts
1282
+ import { Collection as Collection8 } from "@fluxerjs/collection";
1283
+ import { Routes as Routes15 } from "@fluxerjs/types";
1284
+
1285
+ // src/structures/Guild.ts
1286
+ import {
1287
+ parseRoleMention,
1288
+ resolvePermissionsToBitfield as resolvePermissionsToBitfield2
1289
+ } from "@fluxerjs/util";
1290
+ import { FluxerAPIError as FluxerAPIError3 } from "@fluxerjs/rest";
1291
+ import { Collection as Collection7 } from "@fluxerjs/collection";
1292
+
1293
+ // src/client/GuildMemberManager.ts
1294
+ import { Collection as Collection6 } from "@fluxerjs/collection";
1295
+ import { Routes as Routes9 } from "@fluxerjs/types";
1296
+
1297
+ // src/structures/GuildMember.ts
1298
+ import { PermissionFlagsMap } from "@fluxerjs/util";
1299
+ import { Routes as Routes8 } from "@fluxerjs/types";
1300
+
1301
+ // src/util/permissions.ts
1302
+ import { OverwriteType } from "@fluxerjs/types";
1303
+ import { ALL_PERMISSIONS_BIGINT } from "@fluxerjs/util";
1304
+ function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
1305
+ if (isOwner) return ALL_PERMISSIONS_BIGINT;
1306
+ let perms = basePermissions;
1307
+ for (const overwrite of overwrites ?? []) {
1308
+ const applies = overwrite.type === OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === OverwriteType.Member && overwrite.id === memberId;
1309
+ if (!applies) continue;
1310
+ const allow = BigInt(overwrite.allow || "0");
1311
+ const deny = BigInt(overwrite.deny || "0");
1312
+ perms = perms & ~deny | allow;
1313
+ }
1314
+ return perms;
1315
+ }
1316
+ function hasPermission(bitfield, permission) {
1317
+ const Administrator = 1n << 3n;
1318
+ if ((bitfield & Administrator) !== 0n) return true;
1319
+ return (bitfield & permission) === permission;
1320
+ }
1321
+
1322
+ // src/structures/GuildMemberRoleManager.ts
1323
+ import { Collection as Collection5 } from "@fluxerjs/collection";
1324
+ import { Routes as Routes7 } from "@fluxerjs/types";
1325
+ var GuildMemberRoleManager = class {
1326
+ constructor(member, initialRoleIds = []) {
1327
+ this.member = member;
1328
+ this._roleIds = [...initialRoleIds];
1329
+ }
1330
+ _roleIds = [];
1331
+ /** Role IDs for this member. Used by permissions; prefer cache for Role objects. */
1332
+ get roleIds() {
1333
+ return this._roleIds;
1334
+ }
1335
+ /** Check if the member has a role. Discord.js parity: member.roles.cache.has(roleId) */
1336
+ has(roleOrId) {
1337
+ return this._roleIds.includes(this._resolveId(roleOrId));
1338
+ }
1339
+ /**
1340
+ * Collection of Role objects for this member's roles (from guild.roles).
1341
+ * Discord.js parity: member.roles.cache
1342
+ * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
1343
+ */
1344
+ get cache() {
1345
+ const coll = new Collection5();
1346
+ for (const id of this._roleIds) {
1347
+ const role = this.member.guild.roles.get(id);
1348
+ if (role) coll.set(id, role);
1349
+ }
1350
+ return coll;
1351
+ }
1352
+ /** Resolve role ID from RoleResolvable. */
1353
+ _resolveId(roleOrId) {
1354
+ return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
1355
+ }
1356
+ /**
1357
+ * Add a role to this member.
1358
+ * Discord.js parity: member.roles.add(roleId)
1359
+ * Requires Manage Roles permission.
1360
+ * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
1361
+ */
1362
+ async add(roleOrId) {
1363
+ const roleId = this._resolveId(roleOrId);
1364
+ if (this._roleIds.includes(roleId)) return;
1365
+ await this.member.client.rest.put(
1366
+ Routes7.guildMemberRole(this.member.guild.id, this.member.id, roleId)
1367
+ );
1368
+ this._roleIds.push(roleId);
1369
+ }
1370
+ /**
1371
+ * Remove a role from this member.
1372
+ * Discord.js parity: member.roles.remove(roleId)
1373
+ * Requires Manage Roles permission.
1374
+ * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
1375
+ */
1376
+ async remove(roleOrId) {
1377
+ const roleId = this._resolveId(roleOrId);
1378
+ const idx = this._roleIds.indexOf(roleId);
1379
+ if (idx === -1) return;
1380
+ await this.member.client.rest.delete(
1381
+ Routes7.guildMemberRole(this.member.guild.id, this.member.id, roleId)
1382
+ );
1383
+ this._roleIds.splice(idx, 1);
1384
+ }
1385
+ /**
1386
+ * Replace all roles for this member. PATCH /guilds/{id}/members/{userId}
1387
+ * Discord.js parity: member.roles.set(roleIds)
1388
+ * Requires Manage Roles permission.
1389
+ * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
1390
+ */
1391
+ async set(roleIds) {
1392
+ const data = await this.member.client.rest.patch(
1393
+ Routes7.guildMember(this.member.guild.id, this.member.id),
1394
+ { body: { roles: roleIds }, auth: true }
1395
+ );
1396
+ this._roleIds = data.roles ? [...data.roles] : [];
1397
+ }
1398
+ /**
1399
+ * Update internal role IDs from API response. Called by GuildMember.edit().
1400
+ * @internal
1401
+ */
1402
+ _patch(roleIds) {
1403
+ this._roleIds = [...roleIds];
1404
+ }
1405
+ };
1406
+
1407
+ // src/structures/GuildMember.ts
1408
+ var GuildMember = class extends Base {
1409
+ client;
1410
+ id;
1411
+ user;
1412
+ guild;
1413
+ nick;
1414
+ /**
1415
+ * Role manager with add/remove/set and cache. Discord.js parity: member.roles.add(), member.roles.cache
1416
+ * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
1417
+ */
1418
+ roles;
1419
+ joinedAt;
1420
+ communicationDisabledUntil;
1421
+ mute;
1422
+ deaf;
1423
+ avatar;
1424
+ banner;
1425
+ accentColor;
1426
+ profileFlags;
1427
+ /** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
1428
+ constructor(client, data, guild) {
1429
+ super();
1430
+ this.client = client;
1431
+ this.user = client.getOrCreateUser(data.user);
1432
+ this.id = data.user.id;
1433
+ this.guild = guild;
1434
+ this.nick = data.nick ?? null;
1435
+ this.roles = new GuildMemberRoleManager(this, data.roles ?? []);
1436
+ this.joinedAt = new Date(data.joined_at);
1437
+ this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
1438
+ this.mute = data.mute ?? false;
1439
+ this.deaf = data.deaf ?? false;
1440
+ this.avatar = data.avatar ?? null;
1441
+ this.banner = data.banner ?? null;
1442
+ this.accentColor = data.accent_color ?? null;
1443
+ this.profileFlags = data.profile_flags ?? null;
1444
+ }
1445
+ /** Nickname, or global name, or username. */
1446
+ get displayName() {
1447
+ return this.nick ?? this.user.globalName ?? this.user.username;
1448
+ }
1449
+ /**
1450
+ * Get the guild-specific avatar URL for this member.
1451
+ * Returns null if the member has no guild avatar (use displayAvatarURL for fallback).
1452
+ */
1453
+ avatarURL(options) {
1454
+ return cdnMemberAvatarURL(this.guild.id, this.id, this.avatar, options);
1455
+ }
1456
+ /**
1457
+ * Get the avatar URL to display for this member.
1458
+ * Uses guild-specific avatar if set, otherwise falls back to the user's avatar.
1459
+ */
1460
+ displayAvatarURL(options) {
1461
+ return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
1462
+ }
1463
+ /**
1464
+ * Get the guild-specific banner URL for this member.
1465
+ * Returns null if the member has no guild banner.
1466
+ */
1467
+ bannerURL(options) {
1468
+ return cdnMemberBannerURL(this.guild.id, this.id, this.banner, options);
1469
+ }
1470
+ /**
1471
+ * Add a role to this member.
1472
+ * Prefer member.roles.add(roleId) for Discord.js parity.
1473
+ * @param roleId - The role ID to add
1474
+ * Requires Manage Roles permission.
1475
+ */
1476
+ async addRole(roleId) {
1477
+ await this.roles.add(roleId);
1478
+ }
1479
+ /**
1480
+ * Remove a role from this member.
1481
+ * Prefer member.roles.remove(roleId) for Discord.js parity.
1482
+ * @param roleId - The role ID to remove
1483
+ * Requires Manage Roles permission.
1484
+ */
1485
+ async removeRole(roleId) {
1486
+ await this.roles.remove(roleId);
1487
+ }
1488
+ /**
1489
+ * Edit this guild member. PATCH /guilds/{id}/members/{userId} or /members/@me for the bot.
1490
+ * For @me: nick, avatar, banner, bio, pronouns, accent_color, profile_flags, mute, deaf,
1491
+ * communication_disabled_until, timeout_reason, channel_id, connection_id.
1492
+ * For other members: same plus roles (array of role IDs).
1493
+ */
1494
+ async edit(options) {
1495
+ const isMe = this.client.user?.id === this.id;
1496
+ const route = isMe ? `/guilds/${this.guild.id}/members/@me` : Routes8.guildMember(this.guild.id, this.id);
1497
+ const data = await this.client.rest.patch(route, {
1498
+ body: options,
1499
+ auth: true
1500
+ });
1501
+ this.nick = data.nick ?? this.nick;
1502
+ if (data.roles) this.roles._patch(data.roles);
1503
+ if (data.communication_disabled_until != null) {
1504
+ this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
1505
+ }
1506
+ return this;
1507
+ }
1508
+ /**
1509
+ * Get the member's guild-level permissions (from roles only, no channel overwrites).
1510
+ * Use this for server-wide permission checks (e.g. ban, kick, manage roles).
1511
+ * @returns Object with has(permission) to check specific permissions
1512
+ * @example
1513
+ * const perms = member.permissions;
1514
+ * if (perms.has(PermissionFlags.BanMembers)) { ... }
1515
+ */
1516
+ get permissions() {
1517
+ const base = this._computeBasePermissions();
1518
+ const ownerId = this.guild.ownerId;
1519
+ const isOwner = ownerId != null && ownerId !== "" && String(ownerId) === String(this.id);
1520
+ const perms = computePermissions(base, [], [], this.id, isOwner);
1521
+ return {
1522
+ has(permission) {
1523
+ const perm = typeof permission === "number" ? permission : PermissionFlagsMap[String(permission)];
1524
+ if (perm === void 0) return false;
1525
+ return hasPermission(perms, BigInt(perm));
1526
+ }
1527
+ };
1528
+ }
1529
+ /**
1530
+ * Compute the member's effective permissions in a guild channel.
1531
+ * Applies role permissions and channel overwrites.
1532
+ * @param channel - The guild channel to check permissions for
1533
+ * @returns Object with has(permission) to check specific permissions
1534
+ * @example
1535
+ * const perms = member.permissionsIn(channel);
1536
+ * if (perms.has(PermissionFlags.SendMessages)) { ... }
1537
+ */
1538
+ permissionsIn(channel) {
1539
+ const base = this._computeBasePermissions();
1540
+ const ownerId = this.guild.ownerId;
1541
+ const isOwner = ownerId != null && ownerId !== "" && String(ownerId) === String(this.id);
1542
+ const perms = computePermissions(
1543
+ base,
1544
+ channel.permissionOverwrites,
1545
+ [...this.roles.roleIds],
1546
+ this.id,
1547
+ isOwner
1548
+ );
1549
+ return {
1550
+ has(permission) {
1551
+ const perm = typeof permission === "number" ? permission : PermissionFlagsMap[String(permission)];
1552
+ if (perm === void 0) return false;
1553
+ return hasPermission(perms, BigInt(perm));
1554
+ }
1555
+ };
1556
+ }
1557
+ _computeBasePermissions() {
1558
+ let base = 0n;
1559
+ const everyone = this.guild.roles.get(this.guild.id);
1560
+ if (everyone) base |= BigInt(everyone.permissions);
1561
+ for (const roleId of this.roles.roleIds) {
1562
+ if (roleId === this.guild.id) continue;
1563
+ const role = this.guild.roles.get(roleId);
1564
+ if (role) base |= BigInt(role.permissions);
1565
+ }
1566
+ return base;
1567
+ }
1568
+ };
1569
+
1570
+ // src/client/GuildMemberManager.ts
1571
+ var GuildMemberManager = class extends Collection6 {
1572
+ constructor(guild) {
1573
+ super();
1574
+ this.guild = guild;
1575
+ }
1576
+ /**
1577
+ * Get a guild member from cache or fetch from the API if not present.
1578
+ * Convenience helper to avoid repeating `guild.members.get(userId) ?? (await guild.fetchMember(userId))`.
1579
+ * @param userId - Snowflake of the user
1580
+ * @returns The guild member
1581
+ * @throws FluxerError with MEMBER_NOT_FOUND if user is not in the guild (404)
1582
+ * @example
1583
+ * const member = await guild.members.resolve(userId);
1584
+ * console.log(member.displayName);
1585
+ */
1586
+ async resolve(userId) {
1587
+ return this.get(userId) ?? this.guild.fetchMember(userId);
1588
+ }
1589
+ /**
1590
+ * The current bot user as a GuildMember in this guild.
1591
+ * Returns null if the bot's member is not cached or client.user is null.
1592
+ * Use fetchMe() to load the bot's member when not cached.
1593
+ *
1594
+ * @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberManager
1595
+ * @example
1596
+ * const perms = guild.members.me?.permissions;
1597
+ * if (perms?.has(PermissionFlags.BanMembers)) { ... }
1598
+ */
1599
+ get me() {
1600
+ const userId = this.guild.client.user?.id;
1601
+ return userId ? this.get(userId) ?? null : null;
1602
+ }
1603
+ /**
1604
+ * Fetch the current bot user as a GuildMember in this guild.
1605
+ * Caches the result in guild.members.
1606
+ *
1607
+ * @throws Error if client.user is null (client not ready)
1608
+ * @example
1609
+ * const me = await guild.members.fetchMe();
1610
+ * console.log(me.displayName);
1611
+ */
1612
+ async fetchMe() {
1613
+ const userId = this.guild.client.user?.id;
1614
+ if (!userId) {
1615
+ throw new Error("Cannot fetch me: client.user is null (client not ready)");
1616
+ }
1617
+ return this.guild.fetchMember(userId);
1618
+ }
1619
+ /**
1620
+ * Fetch guild members with pagination. GET /guilds/{id}/members.
1621
+ * @param options - limit (1-1000), after (user ID for pagination)
1622
+ * @returns Array of GuildMember objects (cached in guild.members)
1623
+ */
1624
+ async fetch(options) {
1625
+ const params = new URLSearchParams();
1626
+ if (options?.limit != null) params.set("limit", String(options.limit));
1627
+ if (options?.after) params.set("after", options.after);
1628
+ const qs = params.toString();
1629
+ const url = Routes9.guildMembers(this.guild.id) + (qs ? `?${qs}` : "");
1630
+ const data = await this.guild.client.rest.get(url, { auth: true });
1631
+ const list = Array.isArray(data) ? data : data?.members ?? [];
1632
+ const members = [];
1633
+ for (const m of list) {
1634
+ const member = new GuildMember(
1635
+ this.guild.client,
1636
+ { ...m, guild_id: this.guild.id },
1637
+ this.guild
1638
+ );
1639
+ this.set(member.id, member);
1640
+ members.push(member);
1641
+ }
1642
+ return members;
1643
+ }
1644
+ };
1645
+
1646
+ // src/structures/Role.ts
1647
+ import { Routes as Routes10 } from "@fluxerjs/types";
1648
+ import {
1649
+ PermissionFlags,
1650
+ resolvePermissionsToBitfield
1651
+ } from "@fluxerjs/util";
1652
+ var Role = class extends Base {
1653
+ client;
1654
+ id;
1655
+ guildId;
1656
+ name;
1657
+ color;
1658
+ position;
1659
+ permissions;
1660
+ hoist;
1661
+ mentionable;
1662
+ unicodeEmoji;
1663
+ /** Separately sorted position for hoisted roles. Null if not set. */
1664
+ hoistPosition;
1665
+ /** @param client - The client instance */
1666
+ /** @param data - API role from GET /guilds/{id}/roles or gateway role events */
1667
+ /** @param guildId - The guild this role belongs to */
1668
+ constructor(client, data, guildId) {
1669
+ super();
1670
+ this.client = client;
1671
+ this.id = data.id;
1672
+ this.guildId = guildId;
1673
+ this.name = data.name;
1674
+ this.color = data.color;
1675
+ this.position = data.position;
1676
+ this.permissions = data.permissions;
1677
+ this.hoist = !!data.hoist;
1678
+ this.mentionable = !!data.mentionable;
1679
+ this.unicodeEmoji = data.unicode_emoji ?? null;
1680
+ this.hoistPosition = data.hoist_position ?? null;
1681
+ }
1682
+ /** Update mutable fields from fresh API data. Used by edit and gateway events. */
1683
+ _patch(data) {
1684
+ if (data.name !== void 0) this.name = data.name;
1685
+ if (data.color !== void 0) this.color = data.color;
1686
+ if (data.position !== void 0) this.position = data.position;
1687
+ if (data.permissions !== void 0) this.permissions = data.permissions;
1688
+ if (data.hoist !== void 0) this.hoist = !!data.hoist;
1689
+ if (data.mentionable !== void 0) this.mentionable = !!data.mentionable;
1690
+ if (data.unicode_emoji !== void 0) this.unicodeEmoji = data.unicode_emoji ?? null;
1691
+ if (data.hoist_position !== void 0) this.hoistPosition = data.hoist_position ?? null;
1692
+ }
1693
+ /** Returns a mention string (e.g. `<@&123456>`). */
1694
+ toString() {
1695
+ return `<@&${this.id}>`;
1696
+ }
1697
+ /**
1698
+ * Check if this role has a permission. Administrator grants all permissions.
1699
+ * @param permission - Permission flag, name, or resolvable
1700
+ * @returns true if the role has the permission
1701
+ * @example
1702
+ * if (role.has(PermissionFlags.BanMembers)) { ... }
1703
+ * if (role.has('ManageChannels')) { ... }
1704
+ */
1705
+ has(permission) {
1706
+ const perm = typeof permission === "number" ? permission : PermissionFlags[permission];
1707
+ if (perm === void 0) return false;
1708
+ const permNum = Number(perm);
1709
+ const rolePerms = BigInt(this.permissions);
1710
+ const permBig = BigInt(permNum);
1711
+ if (permBig < 0) return false;
1712
+ if ((rolePerms & BigInt(PermissionFlags.Administrator)) !== 0n) return true;
1713
+ return (rolePerms & permBig) === permBig;
1714
+ }
1715
+ /**
1716
+ * Edit this role.
1717
+ * Requires Manage Roles permission.
1718
+ * @param options - Role updates (permissions accepts PermissionResolvable for convenience)
1719
+ * @returns This role (updated in place)
1720
+ * @example
1721
+ * await role.edit({ name: 'Moderator', permissions: ['BanMembers', 'KickMembers'] });
1722
+ */
1723
+ async edit(options) {
1724
+ const body = {};
1725
+ if (options.name !== void 0) body.name = options.name;
1726
+ if (options.permissions !== void 0) {
1727
+ body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield(options.permissions);
1728
+ }
1729
+ if (options.color !== void 0) body.color = options.color;
1730
+ if (options.hoist !== void 0) body.hoist = options.hoist;
1731
+ if (options.mentionable !== void 0) body.mentionable = options.mentionable;
1732
+ if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
1733
+ if (options.position !== void 0) body.position = options.position;
1734
+ if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
1735
+ const data = await this.client.rest.patch(Routes10.guildRole(this.guildId, this.id), {
1736
+ body: Object.keys(body).length ? body : void 0,
1737
+ auth: true
1738
+ });
1739
+ this._patch(data);
1740
+ return this;
1741
+ }
1742
+ /**
1743
+ * Delete this role.
1744
+ * Requires Manage Roles permission.
1745
+ */
1746
+ async delete() {
1747
+ await this.client.rest.delete(Routes10.guildRole(this.guildId, this.id), { auth: true });
1748
+ const guild = this.client.guilds.get(this.guildId);
1749
+ if (guild) guild.roles.delete(this.id);
1750
+ }
1751
+ };
1752
+
1753
+ // src/structures/Guild.ts
1754
+ import { Routes as Routes14 } from "@fluxerjs/types";
1755
+
1756
+ // src/structures/GuildBan.ts
1757
+ import { Routes as Routes11 } from "@fluxerjs/types";
1758
+ var GuildBan = class extends Base {
1759
+ client;
1760
+ guildId;
1761
+ user;
1762
+ reason;
1763
+ /** ISO timestamp when a temporary ban expires. Null for permanent bans. */
1764
+ expiresAt;
1765
+ /** @param data - API ban from GET /guilds/{id}/bans or gateway GUILD_BAN_ADD */
1766
+ constructor(client, data, guildId) {
1767
+ super();
1768
+ this.client = client;
1769
+ this.guildId = data.guild_id ?? guildId;
1770
+ this.user = client.getOrCreateUser(data.user);
1771
+ this.reason = data.reason ?? null;
1772
+ this.expiresAt = data.expires_at ?? null;
1773
+ }
1774
+ /**
1775
+ * Remove this ban (unban the user).
1776
+ * Requires Ban Members permission.
1777
+ */
1778
+ async unban() {
1779
+ await this.client.rest.delete(Routes11.guildBan(this.guildId, this.user.id), {
1780
+ auth: true
1781
+ });
1782
+ }
1783
+ };
1784
+
1785
+ // src/structures/GuildEmoji.ts
1786
+ import { Routes as Routes12 } from "@fluxerjs/types";
1787
+ var GuildEmoji = class extends Base {
1788
+ client;
1789
+ id;
1790
+ guildId;
1791
+ name;
1792
+ animated;
1793
+ /** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
1794
+ constructor(client, data, guildId) {
1795
+ super();
1796
+ this.client = client;
1797
+ this.id = data.id;
1798
+ this.guildId = data.guild_id ?? guildId;
1799
+ this.name = data.name;
1800
+ this.animated = data.animated ?? false;
1801
+ }
1802
+ /** CDN URL for this emoji image. */
1803
+ get url() {
1804
+ const ext = this.animated ? "gif" : "png";
1805
+ return `${CDN_URL}/emojis/${this.id}.${ext}`;
1806
+ }
1807
+ /** Emoji identifier for use in reactions: `name:id` */
1808
+ get identifier() {
1809
+ return `${this.name}:${this.id}`;
1810
+ }
1811
+ /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
1812
+ async delete() {
1813
+ await this.client.rest.delete(Routes12.guildEmoji(this.guildId, this.id), {
1814
+ auth: true
1815
+ });
1816
+ const guild = this.client.guilds.get(this.guildId);
1817
+ if (guild) guild.emojis.delete(this.id);
1818
+ }
1819
+ /**
1820
+ * Edit this emoji's name.
1821
+ * Requires Manage Emojis and Stickers permission.
1822
+ */
1823
+ async edit(options) {
1824
+ const data = await this.client.rest.patch(Routes12.guildEmoji(this.guildId, this.id), {
1825
+ body: options,
1826
+ auth: true
1827
+ });
1828
+ this.name = data.name;
1829
+ return this;
1830
+ }
1831
+ };
1832
+
1833
+ // src/structures/GuildSticker.ts
1834
+ import { Routes as Routes13 } from "@fluxerjs/types";
1835
+ var GuildSticker = class extends Base {
1836
+ client;
1837
+ id;
1838
+ guildId;
1839
+ name;
1840
+ description;
1841
+ tags;
1842
+ animated;
1843
+ /** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
1844
+ constructor(client, data, guildId) {
1845
+ super();
1846
+ this.client = client;
1847
+ this.id = data.id;
1848
+ this.guildId = data.guild_id ?? guildId;
1849
+ this.name = data.name;
1850
+ this.description = data.description ?? "";
1851
+ this.tags = data.tags ?? [];
1852
+ this.animated = data.animated ?? false;
1853
+ }
1854
+ /** CDN URL for this sticker image. */
1855
+ get url() {
1856
+ const ext = this.animated ? "gif" : "png";
1857
+ return `${CDN_URL}/stickers/${this.id}.${ext}`;
1858
+ }
1859
+ /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
1860
+ async delete() {
1861
+ await this.client.rest.delete(Routes13.guildSticker(this.guildId, this.id), {
1862
+ auth: true
1863
+ });
1864
+ }
1865
+ /**
1866
+ * Edit this sticker's name and/or description.
1867
+ * Requires Manage Emojis and Stickers permission.
1868
+ */
1869
+ async edit(options) {
1870
+ const data = await this.client.rest.patch(Routes13.guildSticker(this.guildId, this.id), {
1871
+ body: options,
1872
+ auth: true
1873
+ });
1874
+ const s = data;
1875
+ this.name = s.name;
1876
+ this.description = s.description ?? "";
1877
+ return this;
1878
+ }
1879
+ };
1880
+
1881
+ // src/structures/Guild.ts
1882
+ var Guild = class extends Base {
1883
+ client;
1884
+ id;
1885
+ name;
1886
+ icon;
1887
+ banner;
1888
+ ownerId;
1889
+ /** Invite splash image hash. Null if none. */
1890
+ splash;
1891
+ /** Custom vanity URL code (e.g. fluxer.gg/code). Null if none. */
1892
+ vanityURLCode;
1893
+ /** Enabled guild features. */
1894
+ features;
1895
+ verificationLevel;
1896
+ defaultMessageNotifications;
1897
+ explicitContentFilter;
1898
+ /** AFK voice channel ID. Null if none. */
1899
+ afkChannelId;
1900
+ /** AFK timeout in seconds. */
1901
+ afkTimeout;
1902
+ /** System messages channel ID. Null if none. */
1903
+ systemChannelId;
1904
+ /** Rules/guidelines channel ID. Null if none. */
1905
+ rulesChannelId;
1906
+ nsfwLevel;
1907
+ mfaLevel;
1908
+ /** Banner image width. Optional. */
1909
+ bannerWidth;
1910
+ /** Banner image height. Optional. */
1911
+ bannerHeight;
1912
+ /** Splash image width. Optional. */
1913
+ splashWidth;
1914
+ /** Splash image height. Optional. */
1915
+ splashHeight;
1916
+ members;
1917
+ channels = new Collection7();
1918
+ roles = new Collection7();
1919
+ emojis = new Collection7();
1920
+ /** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
1921
+ constructor(client, data) {
1922
+ super();
1923
+ this.client = client;
1924
+ this.id = data.id;
1925
+ this.members = new GuildMemberManager(this);
1926
+ this.name = data.name;
1927
+ this.icon = data.icon ?? null;
1928
+ this.banner = data.banner ?? null;
1929
+ this.ownerId = data.owner_id ?? data.ownerId ?? "";
1930
+ this.splash = data.splash ?? null;
1931
+ this.vanityURLCode = data.vanity_url_code ?? null;
1932
+ this.features = data.features ?? [];
1933
+ this.verificationLevel = data.verification_level ?? 0;
1934
+ this.defaultMessageNotifications = data.default_message_notifications ?? 0;
1935
+ this.explicitContentFilter = data.explicit_content_filter ?? 0;
1936
+ this.afkChannelId = data.afk_channel_id ?? null;
1937
+ this.afkTimeout = data.afk_timeout ?? 0;
1938
+ this.systemChannelId = data.system_channel_id ?? null;
1939
+ this.rulesChannelId = data.rules_channel_id ?? null;
1940
+ this.nsfwLevel = data.nsfw_level ?? 0;
1941
+ this.mfaLevel = data.mfa_level ?? 0;
1942
+ this.bannerWidth = data.banner_width ?? null;
1943
+ this.bannerHeight = data.banner_height ?? null;
1944
+ this.splashWidth = data.splash_width ?? null;
1945
+ this.splashHeight = data.splash_height ?? null;
1946
+ for (const r of data.roles ?? []) {
1947
+ this.roles.set(r.id, new Role(client, r, this.id));
1948
+ }
1949
+ }
1950
+ /** Get the guild icon URL, or null if no icon. */
1951
+ iconURL(options) {
1952
+ if (!this.icon) return null;
1953
+ const size = options?.size ? `?size=${options.size}` : "";
1954
+ return `${CDN_URL}/icons/${this.id}/${this.icon}.png${size}`;
1955
+ }
1956
+ /** Get the guild banner URL, or null if no banner. */
1957
+ bannerURL(options) {
1958
+ if (!this.banner) return null;
1959
+ const size = options?.size ? `?size=${options.size}` : "";
1960
+ return `${CDN_URL}/banners/${this.id}/${this.banner}.png${size}`;
1961
+ }
1962
+ /** Get the guild splash (invite background) URL, or null if no splash. */
1963
+ splashURL(options) {
1964
+ if (!this.splash) return null;
1965
+ const size = options?.size ? `?size=${options.size}` : "";
1966
+ return `${CDN_URL}/splashes/${this.id}/${this.splash}.png${size}`;
1967
+ }
1968
+ /**
1969
+ * Add a role to a member by user ID. Does not require fetching the member first.
1970
+ * @param userId - The user ID of the member
1971
+ * @param roleId - The role ID to add (or use guild.resolveRoleId for mention/name resolution)
1972
+ * Requires Manage Roles permission.
1973
+ */
1974
+ async addRoleToMember(userId, roleId) {
1975
+ await this.client.rest.put(Routes14.guildMemberRole(this.id, userId, roleId));
1976
+ }
1977
+ /**
1978
+ * Remove a role from a member by user ID. Does not require fetching the member first.
1979
+ * @param userId - The user ID of the member
1980
+ * @param roleId - The role ID to remove
1981
+ * Requires Manage Roles permission.
1982
+ */
1983
+ async removeRoleFromMember(userId, roleId) {
1984
+ await this.client.rest.delete(Routes14.guildMemberRole(this.id, userId, roleId));
1985
+ }
1986
+ /**
1987
+ * Create a role in this guild.
1988
+ * Requires Manage Roles permission.
1989
+ * @param options - Role data (permissions accepts PermissionResolvable for convenience)
1990
+ * @returns The created role
1991
+ * @example
1992
+ * const role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });
1993
+ */
1994
+ async createRole(options) {
1995
+ const body = {};
1996
+ if (options.name !== void 0) body.name = options.name;
1997
+ if (options.permissions !== void 0) {
1998
+ body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield2(options.permissions);
1999
+ }
2000
+ if (options.color !== void 0) body.color = options.color;
2001
+ if (options.hoist !== void 0) body.hoist = options.hoist;
2002
+ if (options.mentionable !== void 0) body.mentionable = options.mentionable;
2003
+ if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
2004
+ if (options.position !== void 0) body.position = options.position;
2005
+ if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
2006
+ const data = await this.client.rest.post(Routes14.guildRoles(this.id), {
2007
+ body: Object.keys(body).length ? body : void 0,
2008
+ auth: true
2009
+ });
2010
+ const role = new Role(this.client, data, this.id);
2011
+ this.roles.set(role.id, role);
2012
+ return role;
2013
+ }
2014
+ /**
2015
+ * Fetch all roles in this guild.
2016
+ * @returns Array of Role objects (cached in guild.roles)
2017
+ */
2018
+ async fetchRoles() {
2019
+ const data = await this.client.rest.get(
2020
+ Routes14.guildRoles(this.id)
2021
+ );
2022
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
2023
+ const roles = [];
2024
+ for (const r of list) {
2025
+ const role = new Role(this.client, r, this.id);
2026
+ this.roles.set(role.id, role);
2027
+ roles.push(role);
2028
+ }
2029
+ return roles;
2030
+ }
2031
+ /**
2032
+ * Fetch a role by ID.
2033
+ * @param roleId - The role ID to fetch
2034
+ * @returns The role
2035
+ * @throws FluxerError with ROLE_NOT_FOUND if role does not exist (404)
2036
+ */
2037
+ async fetchRole(roleId) {
2038
+ try {
2039
+ const data = await this.client.rest.get(Routes14.guildRole(this.id, roleId));
2040
+ const role = new Role(this.client, data, this.id);
2041
+ this.roles.set(role.id, role);
2042
+ return role;
2043
+ } catch (err) {
2044
+ const statusCode = err instanceof FluxerAPIError3 ? err.statusCode : err?.statusCode;
2045
+ if (statusCode === 404) {
2046
+ throw new FluxerError(`Role ${roleId} not found in guild`, {
2047
+ code: ErrorCodes.RoleNotFound,
2048
+ cause: err
2049
+ });
2050
+ }
2051
+ throw err instanceof FluxerError ? err : new FluxerError("Failed to fetch guild role", { cause: err });
2052
+ }
91
2053
  }
92
- maxSize;
93
- set(key, value) {
94
- if (this.maxSize > 0 && this.size >= this.maxSize && !this.has(key)) {
95
- const firstKey = this.keys().next().value;
96
- if (firstKey !== void 0) this.delete(firstKey);
2054
+ /**
2055
+ * Resolve a role ID from an argument (role mention, raw ID, or name).
2056
+ * Fetches guild roles if name is provided.
2057
+ * @param arg - Role mention (@role), role ID, or role name
2058
+ * @returns The role ID, or null if not found
2059
+ */
2060
+ async resolveRoleId(arg) {
2061
+ const parsed = parseRoleMention(arg);
2062
+ if (parsed) return parsed;
2063
+ if (/^\d{17,19}$/.test(arg.trim())) return arg.trim();
2064
+ const cached = this.roles.find(
2065
+ (r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
2066
+ );
2067
+ if (cached) return cached.id;
2068
+ const roles = await this.client.rest.get(Routes14.guildRoles(this.id));
2069
+ const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
2070
+ const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
2071
+ if (role) {
2072
+ this.roles.set(role.id, new Role(this.client, role, this.id));
2073
+ return role.id;
97
2074
  }
98
- return super.set(key, value);
2075
+ return null;
99
2076
  }
100
2077
  /**
101
- * Get a channel from cache or fetch from the API if not present.
102
- * Convenience helper to avoid repeating `client.channels.get(id) ?? (await client.channels.fetch(id))`.
103
- * @param channelId - Snowflake of the channel
104
- * @returns The channel
105
- * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
106
- * @example
107
- * const channel = await client.channels.resolve(message.channelId);
108
- * if (channel?.isSendable()) await channel.send('Hello!');
2078
+ * Ban a user from this guild.
2079
+ * @param userId - The user ID to ban
2080
+ * @param options - Optional reason, delete_message_days (0–7), and ban_duration_seconds (temporary ban).
2081
+ * ban_duration_seconds: 0 = permanent, or use 3600, 43200, 86400, 259200, 432000, 604800, 1209600, 2592000.
2082
+ * Requires Ban Members permission.
109
2083
  */
110
- async resolve(channelId) {
111
- return this.get(channelId) ?? this.fetch(channelId);
2084
+ async ban(userId, options) {
2085
+ const body = {};
2086
+ if (options?.reason) body.reason = options.reason;
2087
+ if (options?.delete_message_days != null)
2088
+ body.delete_message_days = options.delete_message_days;
2089
+ if (options?.ban_duration_seconds != null)
2090
+ body.ban_duration_seconds = options.ban_duration_seconds;
2091
+ await this.client.rest.put(Routes14.guildBan(this.id, userId), {
2092
+ body: Object.keys(body).length ? body : void 0,
2093
+ auth: true
2094
+ });
112
2095
  }
113
2096
  /**
114
- * Fetch a channel by ID from the API (or return from cache if present).
115
- * @param channelId - Snowflake of the channel
116
- * @returns The channel
117
- * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
118
- * @example
119
- * const channel = await client.channels.fetch(channelId);
120
- * if (channel?.isSendable()) await channel.send('Hello!');
2097
+ * Fetch guild bans. Requires Ban Members permission.
2098
+ * @returns List of GuildBan objects
121
2099
  */
122
- async fetch(channelId) {
123
- const cached = this.get(channelId);
124
- if (cached) return cached;
2100
+ async fetchBans() {
2101
+ const data = await this.client.rest.get(
2102
+ Routes14.guildBans(this.id)
2103
+ );
2104
+ const list = Array.isArray(data) ? data : data?.bans ?? [];
2105
+ return list.map((b) => new GuildBan(this.client, { ...b, guild_id: this.id }, this.id));
2106
+ }
2107
+ /**
2108
+ * Remove a ban (unban a user).
2109
+ * @param userId - The user ID to unban
2110
+ * Requires Ban Members permission.
2111
+ */
2112
+ async unban(userId) {
2113
+ await this.client.rest.delete(Routes14.guildBan(this.id, userId), { auth: true });
2114
+ }
2115
+ /**
2116
+ * Kick a member from this guild.
2117
+ * @param userId - The user ID to kick
2118
+ * Requires Kick Members permission.
2119
+ */
2120
+ async kick(userId) {
2121
+ await this.client.rest.delete(Routes14.guildMember(this.id, userId), { auth: true });
2122
+ }
2123
+ /**
2124
+ * Fetch a guild member by user ID.
2125
+ * @param userId - The user ID of the member to fetch
2126
+ * @returns The guild member
2127
+ * @throws FluxerError with MEMBER_NOT_FOUND if user is not in the guild (404)
2128
+ * @throws FluxerError with cause for permission denied (403) or other REST errors
2129
+ */
2130
+ async fetchMember(userId) {
125
2131
  try {
126
- const { Channel: Channel2 } = await import("./Channel-4YUSB2MM.mjs");
127
2132
  const data = await this.client.rest.get(
128
- Routes.channel(channelId)
2133
+ Routes14.guildMember(this.id, userId)
129
2134
  );
130
- const channel = Channel2.fromOrCreate(this.client, data);
131
- if (!channel) {
132
- throw new FluxerError("Channel data invalid or unsupported type", {
133
- code: ErrorCodes.ChannelNotFound
134
- });
135
- }
136
- this.set(channel.id, channel);
137
- if ("guildId" in channel && channel.guildId) {
138
- const guild = this.client.guilds.get(channel.guildId);
139
- if (guild) guild.channels.set(channel.id, channel);
140
- }
141
- return channel;
2135
+ const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
2136
+ this.members.set(member.id, member);
2137
+ return member;
142
2138
  } catch (err) {
143
- if (err instanceof RateLimitError) throw err;
144
- if (err instanceof FluxerAPIError && err.statusCode === 404) {
145
- throw new FluxerError(`Channel ${channelId} not found`, {
146
- code: ErrorCodes.ChannelNotFound,
2139
+ const statusCode = err instanceof FluxerAPIError3 ? err.statusCode : err?.statusCode;
2140
+ if (statusCode === 404) {
2141
+ throw new FluxerError(`Member ${userId} not found in guild`, {
2142
+ code: ErrorCodes.MemberNotFound,
147
2143
  cause: err
148
2144
  });
149
2145
  }
150
- throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
2146
+ throw err instanceof FluxerError ? err : new FluxerError("Failed to fetch guild member", { cause: err });
151
2147
  }
152
2148
  }
153
2149
  /**
154
- * Fetch a message by ID from the API.
155
- * @param channelId - Snowflake of the channel
156
- * @param messageId - Snowflake of the message
157
- * @returns The message
158
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
159
- * @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.resolve(channelId))?.messages?.fetch(messageId).
160
- * @example
161
- * const channel = await client.channels.resolve(channelId);
162
- * const message = await channel?.messages?.fetch(messageId);
2150
+ * Fetch guild audit logs. Requires View Audit Log permission.
2151
+ * @param options - Optional limit, before, after, user_id, action_type for filtering
163
2152
  */
164
- async fetchMessage(channelId, messageId) {
165
- emitDeprecationWarning(
166
- "ChannelManager.fetchMessage()",
167
- "Use channel.messages.fetch(messageId). Prefer (await client.channels.resolve(channelId))?.messages?.fetch(messageId)."
2153
+ async fetchAuditLogs(options) {
2154
+ const params = new URLSearchParams();
2155
+ if (options?.limit != null) params.set("limit", String(options.limit));
2156
+ if (options?.before) params.set("before", options.before);
2157
+ if (options?.after) params.set("after", options.after);
2158
+ if (options?.userId) params.set("user_id", options.userId);
2159
+ if (options?.actionType != null) params.set("action_type", String(options.actionType));
2160
+ const qs = params.toString();
2161
+ const url = Routes14.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
2162
+ return this.client.rest.get(url);
2163
+ }
2164
+ /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
2165
+ async fetchWebhooks() {
2166
+ const data = await this.client.rest.get(Routes14.guildWebhooks(this.id));
2167
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
2168
+ return list.map((w) => new Webhook(this.client, w));
2169
+ }
2170
+ /**
2171
+ * Create a channel in this guild.
2172
+ * @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
2173
+ * Requires Manage Channels permission.
2174
+ */
2175
+ async createChannel(data) {
2176
+ const created = await this.client.rest.post(Routes14.guildChannels(this.id), {
2177
+ body: data,
2178
+ auth: true
2179
+ });
2180
+ const channel = Channel.from(this.client, created);
2181
+ if (channel) {
2182
+ this.client.channels.set(channel.id, channel);
2183
+ this.channels.set(channel.id, channel);
2184
+ }
2185
+ return channel;
2186
+ }
2187
+ /**
2188
+ * Fetch all channels in this guild.
2189
+ * @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
2190
+ */
2191
+ async fetchChannels() {
2192
+ const data = await this.client.rest.get(Routes14.guildChannels(this.id));
2193
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
2194
+ const channels = [];
2195
+ for (const ch of list) {
2196
+ const channel = Channel.from(this.client, ch);
2197
+ if (channel) {
2198
+ this.client.channels.set(channel.id, channel);
2199
+ this.channels.set(channel.id, channel);
2200
+ channels.push(channel);
2201
+ }
2202
+ }
2203
+ return channels;
2204
+ }
2205
+ /**
2206
+ * Edit this guild. PATCH /guilds/{id}.
2207
+ * Requires guild owner or Administrator.
2208
+ */
2209
+ async edit(options) {
2210
+ const data = await this.client.rest.patch(Routes14.guild(this.id), {
2211
+ body: options,
2212
+ auth: true
2213
+ });
2214
+ this.name = data.name;
2215
+ this.icon = data.icon ?? this.icon;
2216
+ this.banner = data.banner ?? this.banner;
2217
+ this.splash = data.splash ?? this.splash;
2218
+ this.systemChannelId = data.system_channel_id ?? this.systemChannelId;
2219
+ this.afkChannelId = data.afk_channel_id ?? this.afkChannelId;
2220
+ this.afkTimeout = data.afk_timeout ?? this.afkTimeout;
2221
+ this.verificationLevel = data.verification_level ?? this.verificationLevel;
2222
+ this.mfaLevel = data.mfa_level ?? this.mfaLevel;
2223
+ this.explicitContentFilter = data.explicit_content_filter ?? this.explicitContentFilter;
2224
+ this.defaultMessageNotifications = data.default_message_notifications ?? this.defaultMessageNotifications;
2225
+ this.features = data.features ?? this.features;
2226
+ return this;
2227
+ }
2228
+ /**
2229
+ * Delete this guild. POST /guilds/{id}/delete.
2230
+ * Must be the guild owner.
2231
+ */
2232
+ async delete() {
2233
+ await this.client.rest.post(Routes14.guildDelete(this.id), { auth: true });
2234
+ this.client.guilds.delete(this.id);
2235
+ }
2236
+ /**
2237
+ * Fetch vanity URL for this guild. GET /guilds/{id}/vanity-url.
2238
+ * Requires Manage Guild permission.
2239
+ */
2240
+ async fetchVanityURL() {
2241
+ return this.client.rest.get(Routes14.guildVanityUrl(this.id), { auth: true });
2242
+ }
2243
+ /**
2244
+ * Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
2245
+ * Must be the guild owner.
2246
+ */
2247
+ async transferOwnership(newOwnerId, password) {
2248
+ await this.client.rest.post(Routes14.guildTransferOwnership(this.id), {
2249
+ body: { new_owner_id: newOwnerId, ...password != null && { password } },
2250
+ auth: true
2251
+ });
2252
+ }
2253
+ /**
2254
+ * Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
2255
+ */
2256
+ setTextChannelFlexibleNames(enabled) {
2257
+ return this.client.rest.patch(Routes14.guildTextChannelFlexibleNames(this.id), {
2258
+ body: { enabled },
2259
+ auth: true
2260
+ }).then(() => this);
2261
+ }
2262
+ /**
2263
+ * Set detached banner feature. PATCH /guilds/{id}/detached-banner.
2264
+ */
2265
+ setDetachedBanner(enabled) {
2266
+ return this.client.rest.patch(Routes14.guildDetachedBanner(this.id), {
2267
+ body: { enabled },
2268
+ auth: true
2269
+ }).then(() => this);
2270
+ }
2271
+ /**
2272
+ * Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
2273
+ */
2274
+ setDisallowUnclaimedAccounts(enabled) {
2275
+ return this.client.rest.patch(Routes14.guildDisallowUnclaimedAccounts(this.id), {
2276
+ body: { enabled },
2277
+ auth: true
2278
+ }).then(() => this);
2279
+ }
2280
+ /**
2281
+ * Update role positions. PATCH /guilds/{id}/roles.
2282
+ * @param updates - Array of { id, position? }
2283
+ */
2284
+ async setRolePositions(updates) {
2285
+ const data = await this.client.rest.patch(
2286
+ Routes14.guildRoles(this.id),
2287
+ { body: updates, auth: true }
2288
+ );
2289
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
2290
+ for (const r of list) {
2291
+ this.roles.set(r.id, new Role(this.client, r, this.id));
2292
+ }
2293
+ return list;
2294
+ }
2295
+ /**
2296
+ * Update role hoist positions. PATCH /guilds/{id}/roles/hoist-positions.
2297
+ */
2298
+ async setRoleHoistPositions(updates) {
2299
+ const data = await this.client.rest.patch(
2300
+ Routes14.guildRolesHoistPositions(this.id),
2301
+ { body: updates, auth: true }
2302
+ );
2303
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
2304
+ for (const r of list) {
2305
+ this.roles.set(r.id, new Role(this.client, r, this.id));
2306
+ }
2307
+ return list;
2308
+ }
2309
+ /**
2310
+ * Reset role hoist positions. DELETE /guilds/{id}/roles/hoist-positions.
2311
+ */
2312
+ async resetRoleHoistPositions() {
2313
+ const data = await this.client.rest.delete(
2314
+ Routes14.guildRolesHoistPositions(this.id),
2315
+ { auth: true }
2316
+ );
2317
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
2318
+ for (const r of list) {
2319
+ this.roles.set(r.id, new Role(this.client, r, this.id));
2320
+ }
2321
+ return list;
2322
+ }
2323
+ /**
2324
+ * Update channel positions.
2325
+ * @param updates - Array of { id, position?, parent_id?, lock_permissions? }
2326
+ * Requires Manage Channels permission.
2327
+ */
2328
+ async setChannelPositions(updates) {
2329
+ await this.client.rest.patch(Routes14.guildChannels(this.id), {
2330
+ body: updates,
2331
+ auth: true
2332
+ });
2333
+ }
2334
+ /**
2335
+ * Fetch all emojis in this guild.
2336
+ * @returns Array of GuildEmoji objects (cached in guild.emojis)
2337
+ */
2338
+ async fetchEmojis() {
2339
+ const data = await this.client.rest.get(
2340
+ Routes14.guildEmojis(this.id)
168
2341
  );
2342
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
2343
+ const emojis = [];
2344
+ for (const e of list) {
2345
+ const emoji = new GuildEmoji(this.client, { ...e, guild_id: this.id }, this.id);
2346
+ this.emojis.set(emoji.id, emoji);
2347
+ emojis.push(emoji);
2348
+ }
2349
+ return emojis;
2350
+ }
2351
+ /**
2352
+ * Fetch a single emoji by ID.
2353
+ * @param emojiId - The emoji ID to fetch
2354
+ * @returns The guild emoji
2355
+ * @throws FluxerError if emoji not found (404)
2356
+ */
2357
+ async fetchEmoji(emojiId) {
169
2358
  try {
170
- const { Message: Message2 } = await import("./Message-R7KSI5YU.mjs");
171
- const data = await this.client.rest.get(
172
- Routes.channelMessage(channelId, messageId)
173
- );
174
- return new Message2(this.client, data);
2359
+ const data = await this.client.rest.get(Routes14.guildEmoji(this.id, emojiId));
2360
+ const emoji = new GuildEmoji(this.client, { ...data, guild_id: this.id }, this.id);
2361
+ this.emojis.set(emoji.id, emoji);
2362
+ return emoji;
175
2363
  } catch (err) {
176
- if (err instanceof RateLimitError) throw err;
177
- if (err instanceof FluxerAPIError && err.statusCode === 404) {
178
- throw new FluxerError(`Message ${messageId} not found in channel ${channelId}`, {
179
- code: ErrorCodes.MessageNotFound,
2364
+ const statusCode = err instanceof FluxerAPIError3 ? err.statusCode : err?.statusCode;
2365
+ if (statusCode === 404) {
2366
+ throw new FluxerError(`Emoji ${emojiId} not found in guild`, {
2367
+ code: ErrorCodes.EmojiNotFound,
180
2368
  cause: err
181
2369
  });
182
2370
  }
183
- throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
2371
+ throw err instanceof FluxerError ? err : new FluxerError("Failed to fetch guild emoji", { cause: err });
184
2372
  }
185
2373
  }
186
2374
  /**
187
- * Send a message to a channel by ID. Works even when the channel is not cached.
188
- * Skips the fetch when you only need to send.
189
- * @param channelId - Snowflake of the channel (text channel or DM)
190
- * @param payload - Text content or object with content, embeds, and/or files
191
- * @returns The created message
192
- * @example
193
- * await client.channels.send(logChannelId, 'User joined!');
194
- * await client.channels.send(channelId, { embeds: [embed] });
195
- * await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
2375
+ * Bulk create emojis. POST /guilds/{id}/emojis/bulk.
2376
+ * @param emojis - Array of { name, image } (base64), 1-50 emojis
2377
+ * @returns Array of created GuildEmoji objects
196
2378
  */
197
- async send(channelId, payload) {
198
- const opts = typeof payload === "string" ? { content: payload } : payload;
199
- const body = buildSendBody(payload);
200
- const { Message: Message2 } = await import("./Message-R7KSI5YU.mjs");
201
- const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
202
- const postOptions = files?.length ? { body, files } : { body };
203
- const data = await this.client.rest.post(Routes.channelMessages(channelId), postOptions);
204
- return new Message2(this.client, data);
2379
+ async createEmojisBulk(emojis) {
2380
+ const data = await this.client.rest.post(
2381
+ Routes14.guildEmojisBulk(this.id),
2382
+ {
2383
+ body: { emojis },
2384
+ auth: true
2385
+ }
2386
+ );
2387
+ const list = Array.isArray(data) ? data : data?.emojis ?? [];
2388
+ return list.map((e) => new GuildEmoji(this.client, { ...e, guild_id: this.id }, this.id));
2389
+ }
2390
+ /**
2391
+ * Bulk create stickers. POST /guilds/{id}/stickers/bulk.
2392
+ * @param stickers - Array of { name, image, description?, tags? }, 1-50 stickers
2393
+ * @returns Array of created GuildSticker objects
2394
+ */
2395
+ async createStickersBulk(stickers) {
2396
+ const data = await this.client.rest.post(
2397
+ Routes14.guildStickersBulk(this.id),
2398
+ {
2399
+ body: { stickers },
2400
+ auth: true
2401
+ }
2402
+ );
2403
+ const list = Array.isArray(data) ? data : data?.stickers ?? [];
2404
+ return list.map((s) => new GuildSticker(this.client, { ...s, guild_id: this.id }, this.id));
205
2405
  }
206
2406
  };
207
2407
 
208
2408
  // src/client/GuildManager.ts
209
- import { Collection as Collection2 } from "@fluxerjs/collection";
210
- import { Routes as Routes2 } from "@fluxerjs/types";
211
- var GuildManager = class extends Collection2 {
2409
+ var GuildManager = class extends Collection8 {
212
2410
  constructor(client) {
213
2411
  super();
214
2412
  this.client = client;
@@ -240,12 +2438,11 @@ var GuildManager = class extends Collection2 {
240
2438
  * @returns The created guild
241
2439
  */
242
2440
  async create(options) {
243
- const { Guild: Guild2 } = await import("./Guild-4U4U422Z.mjs");
244
- const data = await this.client.rest.post(Routes2.guilds(), {
2441
+ const data = await this.client.rest.post(Routes15.guilds(), {
245
2442
  body: options,
246
2443
  auth: true
247
2444
  });
248
- const guild = new Guild2(this.client, data);
2445
+ const guild = new Guild(this.client, data);
249
2446
  this.set(guild.id, guild);
250
2447
  return guild;
251
2448
  }
@@ -261,11 +2458,8 @@ var GuildManager = class extends Collection2 {
261
2458
  const cached = this.get(guildId);
262
2459
  if (cached) return cached;
263
2460
  try {
264
- const { Guild: Guild2 } = await import("./Guild-4U4U422Z.mjs");
265
- const data = await this.client.rest.get(
266
- Routes2.guild(guildId)
267
- );
268
- const guild = new Guild2(this.client, data);
2461
+ const data = await this.client.rest.get(Routes15.guild(guildId));
2462
+ const guild = new Guild(this.client, data);
269
2463
  this.set(guild.id, guild);
270
2464
  return guild;
271
2465
  } catch {
@@ -274,18 +2468,144 @@ var GuildManager = class extends Collection2 {
274
2468
  }
275
2469
  };
276
2470
 
2471
+ // src/structures/User.ts
2472
+ import { Routes as Routes16 } from "@fluxerjs/types";
2473
+ var User = class extends Base {
2474
+ client;
2475
+ id;
2476
+ username;
2477
+ discriminator;
2478
+ globalName;
2479
+ avatar;
2480
+ bot;
2481
+ /** RGB avatar color (e.g. 7577782). Null if not set. */
2482
+ avatarColor;
2483
+ /** Public flags bitfield. Null if not set. */
2484
+ flags;
2485
+ /** Whether this is an official system user. */
2486
+ system;
2487
+ /** Banner hash (from profile, member, or invite context). Null when not available. */
2488
+ banner;
2489
+ /** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
2490
+ constructor(client, data) {
2491
+ super();
2492
+ this.client = client;
2493
+ this.id = data.id;
2494
+ this.username = data.username;
2495
+ this.discriminator = data.discriminator;
2496
+ this.globalName = data.global_name ?? null;
2497
+ this.avatar = data.avatar ?? null;
2498
+ this.bot = !!data.bot;
2499
+ this.avatarColor = data.avatar_color ?? null;
2500
+ this.flags = data.flags ?? data.public_flags ?? null;
2501
+ this.system = !!data.system;
2502
+ this.banner = data.banner ?? null;
2503
+ }
2504
+ /** Update mutable fields from fresh API data. Used by getOrCreateUser cache. */
2505
+ _patch(data) {
2506
+ this.username = data.username;
2507
+ this.discriminator = data.discriminator;
2508
+ this.globalName = data.global_name ?? null;
2509
+ this.avatar = data.avatar ?? null;
2510
+ if (data.avatar_color !== void 0) this.avatarColor = data.avatar_color;
2511
+ if (data.flags !== void 0) this.flags = data.flags;
2512
+ if (data.banner !== void 0) this.banner = data.banner;
2513
+ }
2514
+ /**
2515
+ * Get the URL for this user's avatar.
2516
+ * Auto-detects animated avatars (hash starting with `a_`) and uses gif extension.
2517
+ * @param options - Optional `size` and `extension` (default: png, or gif for animated)
2518
+ */
2519
+ avatarURL(options) {
2520
+ if (!this.avatar) return null;
2521
+ const ext = this.avatar.startsWith("a_") ? "gif" : options?.extension ?? "png";
2522
+ const size = options?.size ? `?size=${options.size}` : "";
2523
+ return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
2524
+ }
2525
+ /** Get the avatar URL, or the default avatar if none set (Fluxer: fluxerstatic.com). */
2526
+ displayAvatarURL(options) {
2527
+ return this.avatarURL(options) ?? cdnDefaultAvatarURL(this.id);
2528
+ }
2529
+ /**
2530
+ * Get the URL for this user's banner.
2531
+ * Returns null if the user has no banner (only available when fetched from profile/member context).
2532
+ */
2533
+ bannerURL(options) {
2534
+ if (!this.banner) return null;
2535
+ const ext = this.banner.startsWith("a_") ? "gif" : options?.extension ?? "png";
2536
+ const size = options?.size ? `?size=${options.size}` : "";
2537
+ return `${CDN_URL}/banners/${this.id}/${this.banner}.${ext}${size}`;
2538
+ }
2539
+ /** Returns a mention string (e.g. `<@123456>`). */
2540
+ toString() {
2541
+ return `<@${this.id}>`;
2542
+ }
2543
+ /**
2544
+ * Create or get a DM channel with this user.
2545
+ * Returns the DM channel; use {@link DMChannel.send} to send messages.
2546
+ */
2547
+ async createDM() {
2548
+ const data = await this.client.rest.post(Routes16.userMeChannels(), {
2549
+ body: { recipient_id: this.id },
2550
+ auth: true
2551
+ });
2552
+ return new DMChannel(this.client, data);
2553
+ }
2554
+ /**
2555
+ * Send a DM to this user.
2556
+ * Convenience method that creates the DM channel and sends the message.
2557
+ */
2558
+ async send(options) {
2559
+ const dm = await this.createDM();
2560
+ return dm.send(options);
2561
+ }
2562
+ };
2563
+
2564
+ // src/client/ClientUser.ts
2565
+ import { Routes as Routes17 } from "@fluxerjs/types";
2566
+ var ClientUser = class extends User {
2567
+ constructor(client, data) {
2568
+ super(client, { ...data });
2569
+ }
2570
+ /**
2571
+ * Fetch guilds the bot is a member of.
2572
+ * @returns Array of Guild objects (cached in client.guilds)
2573
+ */
2574
+ async fetchGuilds() {
2575
+ const data = await this.client.rest.get(
2576
+ Routes17.currentUserGuilds()
2577
+ );
2578
+ const list = Array.isArray(data) ? data : data?.guilds ?? [];
2579
+ const guilds = [];
2580
+ for (const g of list) {
2581
+ const guild = new Guild(this.client, g);
2582
+ this.client.guilds.set(guild.id, guild);
2583
+ guilds.push(guild);
2584
+ }
2585
+ return guilds;
2586
+ }
2587
+ /**
2588
+ * Leave a guild. Requires the bot to be a member.
2589
+ * @param guildId - The guild ID to leave
2590
+ */
2591
+ async leaveGuild(guildId) {
2592
+ await this.client.rest.delete(Routes17.leaveGuild(guildId), { auth: true });
2593
+ this.client.guilds.delete(guildId);
2594
+ }
2595
+ };
2596
+
277
2597
  // src/client/Client.ts
278
2598
  import {
279
- emitDeprecationWarning as emitDeprecationWarning2,
2599
+ emitDeprecationWarning as emitDeprecationWarning3,
280
2600
  formatEmoji,
281
2601
  getUnicodeFromShortcode,
282
2602
  parseEmoji
283
2603
  } from "@fluxerjs/util";
284
2604
 
285
2605
  // src/client/UsersManager.ts
286
- import { Collection as Collection3 } from "@fluxerjs/collection";
287
- import { Routes as Routes3 } from "@fluxerjs/types";
288
- var UsersManager = class extends Collection3 {
2606
+ import { Collection as Collection9 } from "@fluxerjs/collection";
2607
+ import { Routes as Routes18 } from "@fluxerjs/types";
2608
+ var UsersManager = class extends Collection9 {
289
2609
  constructor(client) {
290
2610
  super();
291
2611
  this.client = client;
@@ -310,7 +2630,7 @@ var UsersManager = class extends Collection3 {
310
2630
  * console.log(user.username);
311
2631
  */
312
2632
  async fetch(userId) {
313
- const data = await this.client.rest.get(Routes3.user(userId));
2633
+ const data = await this.client.rest.get(Routes18.user(userId));
314
2634
  return this.client.getOrCreateUser(data);
315
2635
  }
316
2636
  /**
@@ -330,10 +2650,10 @@ var UsersManager = class extends Collection3 {
330
2650
  async fetchWithProfile(userId, options) {
331
2651
  const guildId = options?.guildId ?? void 0;
332
2652
  const [userData, globalProfileData, serverProfileData, memberData] = await Promise.all([
333
- this.client.rest.get(Routes3.user(userId)),
334
- this.client.rest.get(Routes3.userProfile(userId)).catch(() => null),
335
- guildId ? this.client.rest.get(Routes3.userProfile(userId, guildId)).catch(() => null) : Promise.resolve(null),
336
- guildId ? this.client.rest.get(Routes3.guildMember(guildId, userId)).catch(() => null) : Promise.resolve(null)
2653
+ this.client.rest.get(Routes18.user(userId)),
2654
+ this.client.rest.get(Routes18.userProfile(userId)).catch(() => null),
2655
+ guildId ? this.client.rest.get(Routes18.userProfile(userId, guildId)).catch(() => null) : Promise.resolve(null),
2656
+ guildId ? this.client.rest.get(Routes18.guildMember(guildId, userId)).catch(() => null) : Promise.resolve(null)
337
2657
  ]);
338
2658
  const user = this.client.getOrCreateUser(userData);
339
2659
  const globalProfile = globalProfileData && typeof globalProfileData === "object" ? globalProfileData : null;
@@ -357,25 +2677,89 @@ var UsersManager = class extends Collection3 {
357
2677
  }
358
2678
  };
359
2679
 
2680
+ // src/util/guildUtils.ts
2681
+ function normalizeGuildPayload(raw) {
2682
+ if (!raw || typeof raw !== "object") {
2683
+ return null;
2684
+ }
2685
+ if ("properties" in raw && raw.properties != null && typeof raw.properties === "object") {
2686
+ const r = raw;
2687
+ return {
2688
+ ...r.properties,
2689
+ roles: r.roles
2690
+ };
2691
+ }
2692
+ return raw;
2693
+ }
2694
+
2695
+ // src/structures/MessageReaction.ts
2696
+ import { Routes as Routes19 } from "@fluxerjs/types";
2697
+ import { FluxerAPIError as FluxerAPIError4, RateLimitError as RateLimitError3 } from "@fluxerjs/rest";
2698
+ var MessageReaction = class extends Base {
2699
+ client;
2700
+ messageId;
2701
+ channelId;
2702
+ guildId;
2703
+ emoji;
2704
+ /** Raw gateway payload for low-level access. */
2705
+ _data;
2706
+ constructor(client, data) {
2707
+ super();
2708
+ this.client = client;
2709
+ this._data = data;
2710
+ this.messageId = data.message_id;
2711
+ this.channelId = data.channel_id;
2712
+ this.guildId = data.guild_id ?? null;
2713
+ this.emoji = data.emoji;
2714
+ }
2715
+ /** Emoji as a string: unicode or "name:id" for custom. */
2716
+ get emojiIdentifier() {
2717
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
2718
+ }
2719
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
2720
+ get guild() {
2721
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
2722
+ }
2723
+ /**
2724
+ * Fetch the message this reaction belongs to.
2725
+ * Use when you need to edit, delete, or otherwise interact with the message.
2726
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
2727
+ */
2728
+ async fetchMessage() {
2729
+ try {
2730
+ const data = await this.client.rest.get(
2731
+ Routes19.channelMessage(this.channelId, this.messageId)
2732
+ );
2733
+ return new Message(this.client, data);
2734
+ } catch (err) {
2735
+ if (err instanceof RateLimitError3) throw err;
2736
+ if (err instanceof FluxerAPIError4 && err.statusCode === 404) {
2737
+ throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
2738
+ code: ErrorCodes.MessageNotFound,
2739
+ cause: err
2740
+ });
2741
+ }
2742
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
2743
+ }
2744
+ }
2745
+ };
2746
+
360
2747
  // src/client/EventHandlerRegistry.ts
361
2748
  var handlers = /* @__PURE__ */ new Map();
362
2749
  handlers.set("MESSAGE_CREATE", async (client, d) => {
363
- const { Message: Message2 } = await import("./Message-R7KSI5YU.mjs");
364
- const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
365
2750
  const data = d;
366
2751
  if (data.guild_id && data.member && data.author) {
367
2752
  const guild = client.guilds.get(data.guild_id);
368
2753
  if (guild) {
369
2754
  const memberData = { ...data.member, user: data.author, guild_id: data.guild_id };
370
- const member = new GuildMember2(client, memberData, guild);
2755
+ const member = new GuildMember(client, memberData, guild);
371
2756
  guild.members.set(member.id, member);
372
2757
  }
373
2758
  }
374
- client.emit(Events.MessageCreate, new Message2(client, data));
2759
+ client.emit(Events.MessageCreate, new Message(client, data));
375
2760
  });
376
2761
  handlers.set("MESSAGE_UPDATE", async (client, d) => {
377
- const { Message: Message2 } = await import("./Message-R7KSI5YU.mjs");
378
- client.emit(Events.MessageUpdate, null, new Message2(client, d));
2762
+ client.emit(Events.MessageUpdate, null, new Message(client, d));
379
2763
  });
380
2764
  handlers.set("MESSAGE_DELETE", async (client, d) => {
381
2765
  const data = d;
@@ -390,41 +2774,23 @@ handlers.set("MESSAGE_DELETE", async (client, d) => {
390
2774
  });
391
2775
  handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
392
2776
  const data = d;
393
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-EYO7AJTL.mjs");
394
- const reaction = new MessageReaction2(client, data);
2777
+ const reaction = new MessageReaction(client, data);
395
2778
  const user = client.getOrCreateUser({
396
2779
  id: data.user_id,
397
2780
  username: "Unknown",
398
2781
  discriminator: "0"
399
2782
  });
400
- client.emit(
401
- Events.MessageReactionAdd,
402
- reaction,
403
- user,
404
- reaction.messageId,
405
- reaction.channelId,
406
- reaction.emoji,
407
- user.id
408
- );
2783
+ client.emit(Events.MessageReactionAdd, reaction, user);
409
2784
  });
410
2785
  handlers.set("MESSAGE_REACTION_REMOVE", async (client, d) => {
411
2786
  const data = d;
412
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-EYO7AJTL.mjs");
413
- const reaction = new MessageReaction2(client, data);
2787
+ const reaction = new MessageReaction(client, data);
414
2788
  const user = client.getOrCreateUser({
415
2789
  id: data.user_id,
416
2790
  username: "Unknown",
417
2791
  discriminator: "0"
418
2792
  });
419
- client.emit(
420
- Events.MessageReactionRemove,
421
- reaction,
422
- user,
423
- reaction.messageId,
424
- reaction.channelId,
425
- reaction.emoji,
426
- user.id
427
- );
2793
+ client.emit(Events.MessageReactionRemove, reaction, user);
428
2794
  });
429
2795
  handlers.set("MESSAGE_REACTION_REMOVE_ALL", async (client, d) => {
430
2796
  client.emit(Events.MessageReactionRemoveAll, d);
@@ -436,17 +2802,13 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
436
2802
  );
437
2803
  });
438
2804
  handlers.set("GUILD_CREATE", async (client, d) => {
439
- const { Guild: Guild2 } = await import("./Guild-4U4U422Z.mjs");
440
- const { Channel: Channel2 } = await import("./Channel-4YUSB2MM.mjs");
441
- const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
442
- const { normalizeGuildPayload } = await import("./guildUtils-FTEGCNNJ.mjs");
443
2805
  const guildData = normalizeGuildPayload(d);
444
2806
  if (!guildData) return;
445
- const guild = new Guild2(client, guildData);
2807
+ const guild = new Guild(client, guildData);
446
2808
  client.guilds.set(guild.id, guild);
447
2809
  const g = d;
448
2810
  for (const ch of g.channels ?? []) {
449
- const channel = Channel2.from(client, ch);
2811
+ const channel = Channel.from(client, ch);
450
2812
  if (channel) {
451
2813
  client.channels.set(channel.id, channel);
452
2814
  guild.channels.set(channel.id, channel);
@@ -455,7 +2817,7 @@ handlers.set("GUILD_CREATE", async (client, d) => {
455
2817
  for (const m of g.members ?? []) {
456
2818
  if (m?.user?.id) {
457
2819
  const memberData = { ...m, guild_id: guild.id };
458
- const member = new GuildMember2(client, memberData, guild);
2820
+ const member = new GuildMember(client, memberData, guild);
459
2821
  guild.members.set(member.id, member);
460
2822
  }
461
2823
  }
@@ -465,12 +2827,10 @@ handlers.set("GUILD_CREATE", async (client, d) => {
465
2827
  }
466
2828
  });
467
2829
  handlers.set("GUILD_UPDATE", async (client, d) => {
468
- const { Guild: Guild2 } = await import("./Guild-4U4U422Z.mjs");
469
- const { normalizeGuildPayload } = await import("./guildUtils-FTEGCNNJ.mjs");
470
2830
  const guildData = normalizeGuildPayload(d);
471
2831
  if (!guildData) return;
472
2832
  const old = client.guilds.get(guildData.id);
473
- const updated = new Guild2(client, guildData);
2833
+ const updated = new Guild(client, guildData);
474
2834
  client.guilds.set(updated.id, updated);
475
2835
  client.emit(Events.GuildUpdate, old ?? updated, updated);
476
2836
  });
@@ -483,8 +2843,7 @@ handlers.set("GUILD_DELETE", async (client, d) => {
483
2843
  }
484
2844
  });
485
2845
  handlers.set("CHANNEL_CREATE", async (client, d) => {
486
- const { Channel: Channel2 } = await import("./Channel-4YUSB2MM.mjs");
487
- const ch = Channel2.from(client, d);
2846
+ const ch = Channel.from(client, d);
488
2847
  if (ch) {
489
2848
  client.channels.set(ch.id, ch);
490
2849
  if ("guildId" in ch && ch.guildId) {
@@ -495,10 +2854,9 @@ handlers.set("CHANNEL_CREATE", async (client, d) => {
495
2854
  }
496
2855
  });
497
2856
  handlers.set("CHANNEL_UPDATE", async (client, d) => {
498
- const { Channel: Channel2 } = await import("./Channel-4YUSB2MM.mjs");
499
2857
  const ch = d;
500
2858
  const oldCh = client.channels.get(ch.id);
501
- const newCh = Channel2.from(client, ch);
2859
+ const newCh = Channel.from(client, ch);
502
2860
  if (newCh) {
503
2861
  client.channels.set(newCh.id, newCh);
504
2862
  if ("guildId" in newCh && newCh.guildId) {
@@ -521,22 +2879,20 @@ handlers.set("CHANNEL_DELETE", async (client, d) => {
521
2879
  }
522
2880
  });
523
2881
  handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
524
- const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
525
2882
  const data = d;
526
2883
  const guild = client.guilds.get(data.guild_id);
527
2884
  if (guild) {
528
- const member = new GuildMember2(client, data, guild);
2885
+ const member = new GuildMember(client, data, guild);
529
2886
  guild.members.set(member.id, member);
530
2887
  client.emit(Events.GuildMemberAdd, member);
531
2888
  }
532
2889
  });
533
2890
  handlers.set("GUILD_MEMBER_UPDATE", async (client, d) => {
534
- const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
535
2891
  const data = d;
536
2892
  const guild = client.guilds.get(data.guild_id);
537
2893
  if (guild) {
538
2894
  const oldM = guild.members.get(data.user.id);
539
- const newM = new GuildMember2(client, data, guild);
2895
+ const newM = new GuildMember(client, data, guild);
540
2896
  guild.members.set(newM.id, newM);
541
2897
  client.emit(Events.GuildMemberUpdate, oldM ?? newM, newM);
542
2898
  }
@@ -545,7 +2901,6 @@ handlers.set("GUILD_MEMBER_REMOVE", async (client, d) => {
545
2901
  const data = d;
546
2902
  const guild = client.guilds.get(data.guild_id);
547
2903
  if (!guild || !data.user?.id) return;
548
- const { GuildMember: GuildMember2 } = await import("./GuildMember-FSGDPKUU.mjs");
549
2904
  let member = guild.members.get(data.user.id);
550
2905
  if (member) {
551
2906
  guild.members.delete(data.user.id);
@@ -562,7 +2917,7 @@ handlers.set("GUILD_MEMBER_REMOVE", async (client, d) => {
562
2917
  joined_at: (/* @__PURE__ */ new Date(0)).toISOString(),
563
2918
  nick: null
564
2919
  };
565
- member = new GuildMember2(client, memberData, guild);
2920
+ member = new GuildMember(client, memberData, guild);
566
2921
  }
567
2922
  client.emit(Events.GuildMemberRemove, member);
568
2923
  });
@@ -580,22 +2935,32 @@ handlers.set("MESSAGE_DELETE_BULK", async (client, d) => {
580
2935
  });
581
2936
  handlers.set("GUILD_BAN_ADD", async (client, d) => {
582
2937
  const data = d;
583
- const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
584
2938
  const banData = {
585
2939
  user: data.user,
586
2940
  reason: data.reason ?? null,
587
2941
  guild_id: data.guild_id
588
2942
  };
589
- const ban = new GuildBan2(client, banData, data.guild_id);
2943
+ const ban = new GuildBan(client, banData, data.guild_id);
590
2944
  client.emit(Events.GuildBanAdd, ban);
591
2945
  });
592
2946
  handlers.set("GUILD_BAN_REMOVE", async (client, d) => {
593
2947
  const data = d;
594
- const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
595
- const ban = new GuildBan2(client, { ...data, reason: null }, data.guild_id);
2948
+ const ban = new GuildBan(client, { ...data, reason: null }, data.guild_id);
596
2949
  client.emit(Events.GuildBanRemove, ban);
597
2950
  });
598
2951
  handlers.set("GUILD_EMOJIS_UPDATE", async (client, d) => {
2952
+ const data = d;
2953
+ const guild = client.guilds.get(data.guild_id);
2954
+ if (guild) {
2955
+ guild.emojis.clear();
2956
+ for (const e of data.emojis ?? []) {
2957
+ if (!e.id || e.name == null) continue;
2958
+ guild.emojis.set(
2959
+ e.id,
2960
+ new GuildEmoji(client, { id: e.id, name: e.name, animated: e.animated ?? false, guild_id: guild.id }, guild.id)
2961
+ );
2962
+ }
2963
+ }
599
2964
  client.emit(Events.GuildEmojisUpdate, d);
600
2965
  });
601
2966
  handlers.set("GUILD_STICKERS_UPDATE", async (client, d) => {
@@ -608,8 +2973,7 @@ handlers.set("GUILD_ROLE_CREATE", async (client, d) => {
608
2973
  const data = d;
609
2974
  const guild = client.guilds.get(data.guild_id);
610
2975
  if (guild) {
611
- const { Role: Role2 } = await import("./Role-SERSJFJC.mjs");
612
- guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
2976
+ guild.roles.set(data.role.id, new Role(client, data.role, guild.id));
613
2977
  }
614
2978
  client.emit(Events.GuildRoleCreate, data);
615
2979
  });
@@ -621,8 +2985,7 @@ handlers.set("GUILD_ROLE_UPDATE", async (client, d) => {
621
2985
  if (existing) {
622
2986
  existing._patch(data.role);
623
2987
  } else {
624
- const { Role: Role2 } = await import("./Role-SERSJFJC.mjs");
625
- guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
2988
+ guild.roles.set(data.role.id, new Role(client, data.role, guild.id));
626
2989
  }
627
2990
  }
628
2991
  client.emit(Events.GuildRoleUpdate, data);
@@ -647,8 +3010,7 @@ handlers.set("CHANNEL_PINS_UPDATE", async (client, d) => {
647
3010
  });
648
3011
  handlers.set("INVITE_CREATE", async (client, d) => {
649
3012
  const data = d;
650
- const { Invite: Invite2 } = await import("./Invite-UM5BU5A6.mjs");
651
- client.emit(Events.InviteCreate, new Invite2(client, data));
3013
+ client.emit(Events.InviteCreate, new Invite(client, data));
652
3014
  });
653
3015
  handlers.set("INVITE_DELETE", async (client, d) => {
654
3016
  client.emit(Events.InviteDelete, d);
@@ -686,7 +3048,7 @@ function createEventMethods(client) {
686
3048
  }
687
3049
  return result;
688
3050
  }
689
- var Client = class extends EventEmitter {
3051
+ var Client = class extends EventEmitter3 {
690
3052
  /** @param options - Token, REST config, WebSocket, presence, etc. */
691
3053
  constructor(options = {}) {
692
3054
  super();
@@ -751,7 +3113,7 @@ var Client = class extends EventEmitter {
751
3113
  const unicodeFromShortcode = getUnicodeFromShortcode(parsed.name);
752
3114
  if (unicodeFromShortcode) return unicodeFromShortcode;
753
3115
  if (guildId) {
754
- const emojis = await this.rest.get(Routes4.guildEmojis(guildId));
3116
+ const emojis = await this.rest.get(Routes20.guildEmojis(guildId));
755
3117
  const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
756
3118
  const found = list.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
757
3119
  if (found) return formatEmoji({ ...parsed, id: found.id, animated: found.animated });
@@ -772,7 +3134,7 @@ var Client = class extends EventEmitter {
772
3134
  * @throws FluxerError with EMOJI_NOT_IN_GUILD if the emoji is not in the guild
773
3135
  */
774
3136
  async assertEmojiInGuild(emojiId, guildId) {
775
- const emojis = await this.rest.get(Routes4.guildEmojis(guildId));
3137
+ const emojis = await this.rest.get(Routes20.guildEmojis(guildId));
776
3138
  const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
777
3139
  const found = list.some((e) => e.id === emojiId);
778
3140
  if (!found) {
@@ -786,7 +3148,7 @@ var Client = class extends EventEmitter {
786
3148
  * Does not require authentication.
787
3149
  */
788
3150
  async fetchInstance() {
789
- return this.rest.get(Routes4.instance(), { auth: false });
3151
+ return this.rest.get(Routes20.instance(), { auth: false });
790
3152
  }
791
3153
  /**
792
3154
  * Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
@@ -800,7 +3162,7 @@ var Client = class extends EventEmitter {
800
3162
  * const message = await channel?.messages?.fetch(messageId);
801
3163
  */
802
3164
  async fetchMessage(channelId, messageId) {
803
- emitDeprecationWarning2(
3165
+ emitDeprecationWarning3(
804
3166
  "Client.fetchMessage()",
805
3167
  "Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.resolve(channelId))?.messages?.fetch(messageId)"
806
3168
  );
@@ -892,19 +3254,15 @@ var Client = class extends EventEmitter {
892
3254
  async ({
893
3255
  data
894
3256
  }) => {
895
- const { ClientUser: ClientUser2 } = await import("./ClientUser-ET7FW3XL.mjs");
896
- const { Guild: Guild2 } = await import("./Guild-4U4U422Z.mjs");
897
- const { Channel: Channel2 } = await import("./Channel-4YUSB2MM.mjs");
898
- this.user = new ClientUser2(this, data.user);
899
- const { normalizeGuildPayload } = await import("./guildUtils-FTEGCNNJ.mjs");
3257
+ this.user = new ClientUser(this, data.user);
900
3258
  for (const g of data.guilds ?? []) {
901
3259
  const guildData = normalizeGuildPayload(g);
902
3260
  if (!guildData) continue;
903
- const guild = new Guild2(this, guildData);
3261
+ const guild = new Guild(this, guildData);
904
3262
  this.guilds.set(guild.id, guild);
905
3263
  const withCh = g;
906
3264
  for (const ch of withCh.channels ?? []) {
907
- const channel = Channel2.from(this, ch);
3265
+ const channel = Channel.from(this, ch);
908
3266
  if (channel) {
909
3267
  this.channels.set(channel.id, channel);
910
3268
  guild.channels.set(channel.id, channel);
@@ -949,24 +3307,27 @@ var Client = class extends EventEmitter {
949
3307
  */
950
3308
  assertReady() {
951
3309
  if (!this.isReady()) {
952
- throw new FluxerError("Client is not ready yet. Wait for the Ready event before accessing client.user.", {
953
- code: ErrorCodes.ClientNotReady
954
- });
3310
+ throw new FluxerError(
3311
+ "Client is not ready yet. Wait for the Ready event before accessing client.user.",
3312
+ {
3313
+ code: ErrorCodes.ClientNotReady
3314
+ }
3315
+ );
955
3316
  }
956
3317
  }
957
3318
  static get Routes() {
958
- return Routes4;
3319
+ return Routes20;
959
3320
  }
960
3321
  };
961
3322
 
962
3323
  // src/index.ts
963
- import { EmbedBuilder, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
964
- import { Routes as Routes5, GatewayOpcodes, MessageAttachmentFlags } from "@fluxerjs/types";
3324
+ import { EmbedBuilder as EmbedBuilder3, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
3325
+ import { Routes as Routes21, GatewayOpcodes, MessageAttachmentFlags } from "@fluxerjs/types";
965
3326
  import { resolveTenorToImageUrl, parseUserMention, parsePrefixCommand } from "@fluxerjs/util";
966
3327
  import {
967
3328
  PermissionsBitField,
968
- PermissionFlags,
969
- resolvePermissionsToBitfield,
3329
+ PermissionFlags as PermissionFlags2,
3330
+ resolvePermissionsToBitfield as resolvePermissionsToBitfield3,
970
3331
  UserFlagsBitField,
971
3332
  UserFlagsBits
972
3333
  } from "@fluxerjs/util";
@@ -980,7 +3341,7 @@ export {
980
3341
  Client,
981
3342
  ClientUser,
982
3343
  DMChannel,
983
- EmbedBuilder,
3344
+ EmbedBuilder3 as EmbedBuilder,
984
3345
  ErrorCodes,
985
3346
  Events,
986
3347
  FluxerError,
@@ -991,6 +3352,7 @@ export {
991
3352
  GuildEmoji,
992
3353
  GuildMember,
993
3354
  GuildMemberManager,
3355
+ GuildMemberRoleManager,
994
3356
  GuildSticker,
995
3357
  Invite,
996
3358
  LinkChannel,
@@ -1000,11 +3362,11 @@ export {
1000
3362
  MessageManager,
1001
3363
  MessagePayload,
1002
3364
  MessageReaction,
1003
- PermissionFlags,
3365
+ PermissionFlags2 as PermissionFlags,
1004
3366
  PermissionsBitField,
1005
3367
  ReactionCollector,
1006
3368
  Role,
1007
- Routes5 as Routes,
3369
+ Routes21 as Routes,
1008
3370
  STATIC_CDN_URL,
1009
3371
  TextChannel,
1010
3372
  User,
@@ -1021,6 +3383,6 @@ export {
1021
3383
  cdnMemberBannerURL,
1022
3384
  parsePrefixCommand,
1023
3385
  parseUserMention,
1024
- resolvePermissionsToBitfield,
3386
+ resolvePermissionsToBitfield3 as resolvePermissionsToBitfield,
1025
3387
  resolveTenorToImageUrl
1026
3388
  };