@fluxerjs/core 2.0.1 → 2.0.3

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/cluster.mjs CHANGED
@@ -20,6 +20,8 @@ var Events = {
20
20
  MessageReactionRemoveAll: "messageReactionRemoveAll",
21
21
  MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
22
22
  GuildCreate: "guildCreate",
23
+ GuildAvailable: "guildAvailable",
24
+ GuildUnavailable: "guildUnavailable",
23
25
  GuildUpdate: "guildUpdate",
24
26
  GuildDelete: "guildDelete",
25
27
  GuildBanAdd: "guildBanAdd",
@@ -66,8 +68,8 @@ import { Routes as Routes34 } from "@fluxerjs/types";
66
68
 
67
69
  // src/client/ChannelManager.ts
68
70
  import { Collection as Collection5 } from "@fluxerjs/collection";
69
- import { Routes as Routes12 } from "@fluxerjs/types";
70
- import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
71
+ import { Routes as Routes13 } from "@fluxerjs/types";
72
+ import { FluxerAPIError as FluxerAPIError3, RateLimitError as RateLimitError3 } from "@fluxerjs/rest";
71
73
 
72
74
  // src/util/messageUtils/files.ts
73
75
  var FILE_FETCH_TIMEOUT_MS = 3e4;
@@ -249,19 +251,19 @@ async function prepareMessagePostPayload(options, defaults) {
249
251
  }
250
252
 
251
253
  // src/structures/channel/base.ts
252
- import { ChannelType, Routes as Routes6 } from "@fluxerjs/types";
254
+ import { ChannelType, Routes as Routes7 } from "@fluxerjs/types";
253
255
 
254
256
  // src/client/MessageManager.ts
255
- import { Routes as Routes4 } from "@fluxerjs/types";
257
+ import { Routes as Routes5 } from "@fluxerjs/types";
256
258
  import { Collection as Collection3 } from "@fluxerjs/collection";
257
- import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
259
+ import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
258
260
 
259
261
  // src/structures/message/Message.ts
260
262
  import { Collection as Collection2 } from "@fluxerjs/collection";
261
263
  import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
262
264
  import {
263
265
  MessageType,
264
- Routes as Routes3
266
+ Routes as Routes4
265
267
  } from "@fluxerjs/types";
266
268
 
267
269
  // src/client/sdkOptions.ts
@@ -502,6 +504,70 @@ function toProfilePayload(data) {
502
504
  // src/util/ReactionCollector.ts
503
505
  import { EventEmitter } from "events";
504
506
  import { Collection } from "@fluxerjs/collection";
507
+
508
+ // src/structures/MessageReaction.ts
509
+ import { Routes } from "@fluxerjs/types";
510
+ import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
511
+
512
+ // src/structures/Base.ts
513
+ var Base = class {
514
+ };
515
+
516
+ // src/structures/MessageReaction.ts
517
+ var MessageReaction = class extends Base {
518
+ client;
519
+ messageId;
520
+ channelId;
521
+ guildId;
522
+ emoji;
523
+ /** Raw gateway payload for low-level access. */
524
+ _data;
525
+ constructor(client, data) {
526
+ super();
527
+ this.client = client;
528
+ this._data = data;
529
+ this.messageId = data.message_id;
530
+ this.channelId = data.channel_id;
531
+ this.guildId = data.guild_id ?? null;
532
+ this.emoji = {
533
+ name: data.emoji.name,
534
+ ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
535
+ ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
536
+ };
537
+ }
538
+ /** Emoji as a string: unicode or "name:id" for custom. */
539
+ get emojiIdentifier() {
540
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
541
+ }
542
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
543
+ get guild() {
544
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
545
+ }
546
+ /**
547
+ * Fetch the message this reaction belongs to.
548
+ * Use when you need to edit, delete, or otherwise interact with the message.
549
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
550
+ */
551
+ async fetchMessage() {
552
+ try {
553
+ const data = await this.client.rest.get(
554
+ Routes.channelMessage(this.channelId, this.messageId)
555
+ );
556
+ return new Message(this.client, data);
557
+ } catch (err) {
558
+ if (err instanceof RateLimitError) throw err;
559
+ if (err instanceof FluxerAPIError && err.statusCode === 404) {
560
+ throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
561
+ code: ErrorCodes.MessageNotFound,
562
+ cause: err
563
+ });
564
+ }
565
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
566
+ }
567
+ }
568
+ };
569
+
570
+ // src/util/ReactionCollector.ts
505
571
  var ReactionCollector = class extends EventEmitter {
506
572
  client;
507
573
  messageId;
@@ -510,7 +576,8 @@ var ReactionCollector = class extends EventEmitter {
510
576
  collected = new Collection();
511
577
  _timeout = null;
512
578
  _ended = false;
513
- _listener;
579
+ _onAdd;
580
+ _onAddMany;
514
581
  constructor(client, messageId, channelId, options = {}) {
515
582
  super();
516
583
  this.client = client;
@@ -521,27 +588,58 @@ var ReactionCollector = class extends EventEmitter {
521
588
  time: options.time ?? 0,
522
589
  max: options.max ?? 0
523
590
  };
524
- this._listener = (payload) => {
591
+ this._onAdd = (payload) => {
525
592
  if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
526
593
  return;
527
594
  }
528
- if (!this.options.filter(payload.reaction, payload.user)) return;
529
- const key = `${payload.userId}:${payload.reaction.emoji.id ?? payload.reaction.emoji.name}`;
530
- this.collected.set(key, { reaction: payload.reaction, user: payload.user });
531
- this.emit("collect", payload.reaction, payload.user);
532
- if (this.options.max > 0 && this.collected.size >= this.options.max) {
533
- this.stop("limit");
595
+ this._collect(payload.reaction, payload.user, payload.userId);
596
+ };
597
+ this._onAddMany = (payload) => {
598
+ if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
599
+ return;
600
+ }
601
+ for (const entry of payload.reactions) {
602
+ if (this._ended) return;
603
+ const reaction = new MessageReaction(this.client, {
604
+ message_id: payload.messageId,
605
+ channel_id: payload.channelId,
606
+ guild_id: payload.guildId ?? void 0,
607
+ user_id: entry.userId,
608
+ emoji: {
609
+ name: entry.emoji.name,
610
+ ...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
611
+ ...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
612
+ }
613
+ });
614
+ const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
615
+ id: entry.userId,
616
+ username: "Unknown",
617
+ discriminator: "0"
618
+ });
619
+ this._collect(reaction, user, entry.userId);
534
620
  }
535
621
  };
536
- this.client.on(Events.MessageReactionAdd, this._listener);
622
+ this.client.on(Events.MessageReactionAdd, this._onAdd);
623
+ this.client.on(Events.MessageReactionAddMany, this._onAddMany);
537
624
  if (this.options.time > 0) {
538
625
  this._timeout = setTimeout(() => this.stop("time"), this.options.time);
539
626
  }
540
627
  }
628
+ _collect(reaction, user, userId) {
629
+ if (this._ended) return;
630
+ if (!this.options.filter(reaction, user)) return;
631
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
632
+ this.collected.set(key, { reaction, user });
633
+ this.emit("collect", reaction, user);
634
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
635
+ this.stop("limit");
636
+ }
637
+ }
541
638
  stop(reason = "user") {
542
639
  if (this._ended) return;
543
640
  this._ended = true;
544
- this.client.off(Events.MessageReactionAdd, this._listener);
641
+ this.client.off(Events.MessageReactionAdd, this._onAdd);
642
+ this.client.off(Events.MessageReactionAddMany, this._onAddMany);
545
643
  if (this._timeout) {
546
644
  clearTimeout(this._timeout);
547
645
  this._timeout = null;
@@ -556,30 +654,26 @@ var ReactionCollector = class extends EventEmitter {
556
654
  }
557
655
  };
558
656
 
559
- // src/structures/Base.ts
560
- var Base = class {
561
- };
562
-
563
657
  // src/structures/message/reactions.ts
564
- import { Routes } from "@fluxerjs/types";
658
+ import { Routes as Routes2 } from "@fluxerjs/types";
565
659
  async function emojiPath(message, emoji) {
566
660
  return message.client.resolveEmoji(emoji, message.guildId);
567
661
  }
568
662
  async function reactToMessage(message, emoji) {
569
663
  const e = await emojiPath(message, emoji);
570
- await message.client.rest.put(Routes.channelMessageReactionMe(message.channelId, message.id, e));
664
+ await message.client.rest.put(Routes2.channelMessageReactionMe(message.channelId, message.id, e));
571
665
  }
572
666
  async function removeMessageReaction(message, emoji, userId) {
573
667
  const e = await emojiPath(message, emoji);
574
- const route = userId ? Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes.channelMessageReactionMe(message.channelId, message.id, e);
668
+ const route = userId ? Routes2.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes2.channelMessageReactionMe(message.channelId, message.id, e);
575
669
  await message.client.rest.delete(route);
576
670
  }
577
671
  async function removeAllMessageReactions(message) {
578
- await message.client.rest.delete(Routes.channelMessageReactions(message.channelId, message.id));
672
+ await message.client.rest.delete(Routes2.channelMessageReactions(message.channelId, message.id));
579
673
  }
580
674
  async function removeMessageReactionEmoji(message, emoji) {
581
675
  const e = await emojiPath(message, emoji);
582
- await message.client.rest.delete(Routes.channelMessageReaction(message.channelId, message.id, e));
676
+ await message.client.rest.delete(Routes2.channelMessageReaction(message.channelId, message.id, e));
583
677
  }
584
678
  async function fetchMessageReactionUsers(message, emoji, options) {
585
679
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -590,7 +684,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
590
684
  if (options?.limit != null) params.set("limit", String(options.limit));
591
685
  if (options?.after) params.set("after", options.after);
592
686
  const qs2 = params.toString();
593
- const route = Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
687
+ const route = Routes2.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
594
688
  const data = await message.client.rest.get(route);
595
689
  if (Array.isArray(data)) {
596
690
  return {
@@ -609,7 +703,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
609
703
 
610
704
  // src/structures/message/send.ts
611
705
  import { MessagePayload as MessagePayloadBuilder } from "@fluxerjs/builders";
612
- import { Routes as Routes2 } from "@fluxerjs/types";
706
+ import { Routes as Routes3 } from "@fluxerjs/types";
613
707
  function toReplyTarget(ref) {
614
708
  return {
615
709
  channelId: ref.channel_id,
@@ -643,7 +737,7 @@ function asReplyTarget(value) {
643
737
  }
644
738
  async function sendPrepared(message, payload) {
645
739
  const data = await message.client.rest.post(
646
- Routes2.channelMessages(message.channelId),
740
+ Routes3.channelMessages(message.channelId),
647
741
  payload
648
742
  );
649
743
  message.client._addMessageToCache(message.channelId, data);
@@ -820,7 +914,7 @@ var Message = class _Message extends Base {
820
914
  if (options.attachments !== void 0) {
821
915
  body.attachments = toMessageAttachmentEditWire(options.attachments);
822
916
  }
823
- const data = await this.client.rest.patch(Routes3.channelMessage(this.channelId, this.id), {
917
+ const data = await this.client.rest.patch(Routes4.channelMessage(this.channelId, this.id), {
824
918
  body
825
919
  });
826
920
  const updated = new _Message(this.client, data);
@@ -837,25 +931,25 @@ var Message = class _Message extends Base {
837
931
  }
838
932
  /** Delete this message. */
839
933
  async delete() {
840
- await this.client.rest.delete(Routes3.channelMessage(this.channelId, this.id));
934
+ await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id));
841
935
  this.client._removeMessageFromCache(this.channelId, this.id);
842
936
  }
843
937
  /** Delete a specific attachment from this message. */
844
938
  async deleteAttachment(attachmentId) {
845
939
  await this.client.rest.delete(
846
- Routes3.channelMessageAttachment(this.channelId, this.id, attachmentId),
940
+ Routes4.channelMessageAttachment(this.channelId, this.id, attachmentId),
847
941
  { auth: true }
848
942
  );
849
943
  this.attachments.delete(attachmentId);
850
944
  }
851
945
  /** Pin this message in the channel. */
852
946
  async pin() {
853
- await this.client.rest.put(Routes3.channelPinMessage(this.channelId, this.id));
947
+ await this.client.rest.put(Routes4.channelPinMessage(this.channelId, this.id));
854
948
  this.pinned = true;
855
949
  }
856
950
  /** Unpin this message from the channel. */
857
951
  async unpin() {
858
- await this.client.rest.delete(Routes3.channelPinMessage(this.channelId, this.id));
952
+ await this.client.rest.delete(Routes4.channelPinMessage(this.channelId, this.id));
859
953
  this.pinned = false;
860
954
  }
861
955
  /** React to this message with an emoji. */
@@ -936,12 +1030,12 @@ var MessageManager = class {
936
1030
  async fetchOne(messageId) {
937
1031
  try {
938
1032
  const data = await this.client.rest.get(
939
- Routes4.channelMessage(this.channelId, messageId)
1033
+ Routes5.channelMessage(this.channelId, messageId)
940
1034
  );
941
1035
  return this.wrap(data);
942
1036
  } catch (err) {
943
- if (err instanceof RateLimitError) throw err;
944
- if (err instanceof FluxerAPIError && err.statusCode === 404) {
1037
+ if (err instanceof RateLimitError2) throw err;
1038
+ if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
945
1039
  throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
946
1040
  code: ErrorCodes.MessageNotFound,
947
1041
  cause: err
@@ -962,7 +1056,7 @@ var MessageManager = class {
962
1056
  const value = options[key];
963
1057
  if (value != null && value !== "") qs2.set(key, String(value));
964
1058
  }
965
- const base = Routes4.channelMessages(this.channelId);
1059
+ const base = Routes5.channelMessages(this.channelId);
966
1060
  const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
967
1061
  const collection = new Collection3();
968
1062
  for (const msg of data) collection.set(msg.id, this.wrap(msg));
@@ -971,7 +1065,7 @@ var MessageManager = class {
971
1065
  };
972
1066
 
973
1067
  // src/structures/channel/attachments.ts
974
- import { Routes as Routes5 } from "@fluxerjs/types";
1068
+ import { Routes as Routes6 } from "@fluxerjs/types";
975
1069
  function asBytes(data) {
976
1070
  const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
977
1071
  const out = new Uint8Array(src.byteLength);
@@ -992,7 +1086,7 @@ async function putBlob(url, body, contentType) {
992
1086
  }
993
1087
  async function uploadAttachmentsForSend(client, channelId, files) {
994
1088
  const plan = await client.rest.post(
995
- Routes5.channelAttachments(channelId),
1089
+ Routes6.channelAttachments(channelId),
996
1090
  {
997
1091
  body: {
998
1092
  attachments: files.map((f) => ({
@@ -1038,7 +1132,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
1038
1132
  });
1039
1133
  }
1040
1134
  if (multipart.length) {
1041
- await client.rest.post(Routes5.channelAttachmentsComplete(channelId), {
1135
+ await client.rest.post(Routes6.channelAttachmentsComplete(channelId), {
1042
1136
  body: { uploads: multipart },
1043
1137
  auth: true
1044
1138
  });
@@ -1132,7 +1226,7 @@ var Channel = class extends Base {
1132
1226
  }
1133
1227
  if (ids.length === 0) return [];
1134
1228
  if (ids.length === 1) {
1135
- await this.client.rest.delete(Routes6.channelMessage(this.id, ids[0]), { auth: true });
1229
+ await this.client.rest.delete(Routes7.channelMessage(this.id, ids[0]), { auth: true });
1136
1230
  this.client._removeMessageFromCache(this.id, ids[0]);
1137
1231
  return ids;
1138
1232
  }
@@ -1141,7 +1235,7 @@ var Channel = class extends Base {
1141
1235
  code: ErrorCodes.InvalidBulkDelete
1142
1236
  });
1143
1237
  }
1144
- await this.client.rest.post(Routes6.channelBulkDelete(this.id), {
1238
+ await this.client.rest.post(Routes7.channelBulkDelete(this.id), {
1145
1239
  body: { message_ids: ids },
1146
1240
  auth: true
1147
1241
  });
@@ -1151,23 +1245,23 @@ var Channel = class extends Base {
1151
1245
  /** Delete all messages sent by the bot in this channel (user account feature). */
1152
1246
  async bulkDeleteMyMessages(options) {
1153
1247
  const body = options ? toSudoBody(options) : void 0;
1154
- await this.client.rest.post(Routes6.channelBulkDeleteMine(this.id), {
1248
+ await this.client.rest.post(Routes7.channelBulkDeleteMine(this.id), {
1155
1249
  body: body && Object.keys(body).length ? body : void 0,
1156
1250
  auth: true
1157
1251
  });
1158
1252
  }
1159
1253
  /** Mark all pinned messages as read in this channel. */
1160
1254
  async acknowledgePins() {
1161
- await this.client.rest.post(Routes6.channelPinsAck(this.id), { auth: true });
1255
+ await this.client.rest.post(Routes7.channelPinsAck(this.id), { auth: true });
1162
1256
  }
1163
1257
  /** Clear the read state for this channel. */
1164
1258
  async clearReadState() {
1165
- await this.client.rest.delete(Routes6.channelMessagesAck(this.id), { auth: true });
1259
+ await this.client.rest.delete(Routes7.channelMessagesAck(this.id), { auth: true });
1166
1260
  }
1167
1261
  /** Request upload URLs for attachments before sending a message. */
1168
1262
  async requestAttachmentUploads(attachments) {
1169
1263
  const data = await this.client.rest.post(
1170
- Routes6.channelAttachments(this.id),
1264
+ Routes7.channelAttachments(this.id),
1171
1265
  {
1172
1266
  body: toAttachmentUploadPlanBody(attachments),
1173
1267
  auth: true
@@ -1178,7 +1272,7 @@ var Channel = class extends Base {
1178
1272
  /** Complete the attachment upload flow after uploading to the CDN. */
1179
1273
  async completeAttachmentUploads(uploads) {
1180
1274
  const data = await this.client.rest.post(
1181
- Routes6.channelAttachmentsComplete(this.id),
1275
+ Routes7.channelAttachmentsComplete(this.id),
1182
1276
  {
1183
1277
  body: toAttachmentUploadCompleteBody(uploads),
1184
1278
  auth: true
@@ -1194,11 +1288,11 @@ var Channel = class extends Base {
1194
1288
  }
1195
1289
  /** Trigger the typing indicator in this channel. */
1196
1290
  async sendTyping() {
1197
- await this.client.rest.post(Routes6.channelTyping(this.id), { auth: true });
1291
+ await this.client.rest.post(Routes7.channelTyping(this.id), { auth: true });
1198
1292
  }
1199
1293
  /** Fetch available RTC regions for voice channels. */
1200
1294
  async fetchRtcRegions() {
1201
- const data = await this.client.rest.get(Routes6.channelRtcRegions(this.id), {
1295
+ const data = await this.client.rest.get(Routes7.channelRtcRegions(this.id), {
1202
1296
  auth: true
1203
1297
  });
1204
1298
  return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
@@ -1206,7 +1300,7 @@ var Channel = class extends Base {
1206
1300
  /** Fetch slowmode state for this channel. */
1207
1301
  async fetchSlowmode() {
1208
1302
  const data = await this.client.rest.get(
1209
- Routes6.channelSlowmode(this.id),
1303
+ Routes7.channelSlowmode(this.id),
1210
1304
  { auth: true }
1211
1305
  );
1212
1306
  return {
@@ -1222,7 +1316,7 @@ var Channel = class extends Base {
1222
1316
  };
1223
1317
 
1224
1318
  // src/structures/channel/guild.ts
1225
- import { Routes as Routes10 } from "@fluxerjs/types";
1319
+ import { Routes as Routes11 } from "@fluxerjs/types";
1226
1320
  import { PermissionFlags } from "@fluxerjs/util";
1227
1321
 
1228
1322
  // src/structures/Invite.ts
@@ -1231,7 +1325,7 @@ import {
1231
1325
  isGroupDmInvite,
1232
1326
  isGuildInvite,
1233
1327
  isPackInvite,
1234
- Routes as Routes7
1328
+ Routes as Routes8
1235
1329
  } from "@fluxerjs/types";
1236
1330
 
1237
1331
  // src/util/Constants.ts
@@ -1451,19 +1545,19 @@ var Invite = class _Invite extends Base {
1451
1545
  }
1452
1546
  /** Fetch invite metadata by code or URL (does not join). */
1453
1547
  static async fetch(client, codeOrUrl) {
1454
- const data = await client.rest.get(Routes7.invite(parseInviteCode(codeOrUrl)));
1548
+ const data = await client.rest.get(Routes8.invite(parseInviteCode(codeOrUrl)));
1455
1549
  return new _Invite(client, data);
1456
1550
  }
1457
1551
  /** Delete this invite. Requires Manage Guild or Create Instant Invite. */
1458
1552
  async delete() {
1459
- await this.client.rest.delete(Routes7.invite(this.code), { auth: true });
1553
+ await this.client.rest.delete(Routes8.invite(this.code), { auth: true });
1460
1554
  }
1461
1555
  };
1462
1556
 
1463
1557
  // src/structures/Webhook.ts
1464
1558
  import { EmbedBuilder as EmbedBuilder3 } from "@fluxerjs/builders";
1465
1559
  import {
1466
- Routes as Routes8
1560
+ Routes as Routes9
1467
1561
  } from "@fluxerjs/types";
1468
1562
 
1469
1563
  // src/util/cdn.ts
@@ -1556,10 +1650,10 @@ var Webhook = class _Webhook extends Base {
1556
1650
  /** Delete this webhook (token auth when available, otherwise bot auth). */
1557
1651
  async delete() {
1558
1652
  if (this.token) {
1559
- await this.client.rest.delete(Routes8.webhookExecute(this.id, this.token), { auth: false });
1653
+ await this.client.rest.delete(Routes9.webhookExecute(this.id, this.token), { auth: false });
1560
1654
  return;
1561
1655
  }
1562
- await this.client.rest.delete(Routes8.webhook(this.id), { auth: true });
1656
+ await this.client.rest.delete(Routes9.webhook(this.id), { auth: true });
1563
1657
  }
1564
1658
  /**
1565
1659
  * Edit name/avatar. With bot auth (no token), `channelId` may also be set.
@@ -1571,10 +1665,10 @@ var Webhook = class _Webhook extends Base {
1571
1665
  if (!this.token && options.channelId !== void 0) {
1572
1666
  body.channel_id = options.channelId;
1573
1667
  }
1574
- const data = this.token ? await this.client.rest.patch(Routes8.webhookExecute(this.id, this.token), {
1668
+ const data = this.token ? await this.client.rest.patch(Routes9.webhookExecute(this.id, this.token), {
1575
1669
  body,
1576
1670
  auth: false
1577
- }) : await this.client.rest.patch(Routes8.webhook(this.id), { body, auth: true });
1671
+ }) : await this.client.rest.patch(Routes9.webhook(this.id), { body, auth: true });
1578
1672
  this.name = data.name ?? this.name;
1579
1673
  this.avatar = data.avatar ?? null;
1580
1674
  if (!this.token) this.channelId = data.channel_id ?? this.channelId;
@@ -1595,7 +1689,7 @@ var Webhook = class _Webhook extends Base {
1595
1689
  if (overrides.avatarUrl !== void 0) {
1596
1690
  body.avatar_url = overrides.avatarUrl;
1597
1691
  }
1598
- const route = `${Routes8.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1692
+ const route = `${Routes9.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1599
1693
  const data = await this.client.rest.post(route, {
1600
1694
  body,
1601
1695
  ...files?.length ? { files } : {},
@@ -1636,7 +1730,7 @@ var Webhook = class _Webhook extends Base {
1636
1730
  }
1637
1731
  /** Fetch a webhook by ID (bot auth; no token). */
1638
1732
  static async fetch(client, webhookId) {
1639
- const data = await client.rest.get(Routes8.webhook(webhookId));
1733
+ const data = await client.rest.get(Routes9.webhook(webhookId));
1640
1734
  return new _Webhook(client, data);
1641
1735
  }
1642
1736
  /** Build a webhook from a stored id + token (e.g. webhook URL). */
@@ -1661,12 +1755,12 @@ var Webhook = class _Webhook extends Base {
1661
1755
  return this.token;
1662
1756
  }
1663
1757
  messageRoute(messageId) {
1664
- return Routes8.webhookMessage(this.id, this.requireToken(), messageId);
1758
+ return Routes9.webhookMessage(this.id, this.requireToken(), messageId);
1665
1759
  }
1666
1760
  };
1667
1761
 
1668
1762
  // src/structures/channel/textCapable.ts
1669
- import { Routes as Routes9 } from "@fluxerjs/types";
1763
+ import { Routes as Routes10 } from "@fluxerjs/types";
1670
1764
 
1671
1765
  // src/util/MessageCollector.ts
1672
1766
  import { EventEmitter as EventEmitter2 } from "events";
@@ -1727,7 +1821,7 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
1727
1821
  if (options?.before) params.set("before", options.before);
1728
1822
  const qs2 = params.toString();
1729
1823
  const data = await client.rest.get(
1730
- Routes9.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1824
+ Routes10.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1731
1825
  );
1732
1826
  const items = data.items ?? [];
1733
1827
  return {
@@ -1743,7 +1837,7 @@ function TextCapable(Base2) {
1743
1837
  const payload = await prepareMessagePostPayload(options, {
1744
1838
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
1745
1839
  });
1746
- const data = await this.client.rest.post(Routes9.channelMessages(this.id), payload);
1840
+ const data = await this.client.rest.post(Routes10.channelMessages(this.id), payload);
1747
1841
  this.client._addMessageToCache(this.id, data);
1748
1842
  return new Message(this.client, data);
1749
1843
  }
@@ -1800,7 +1894,7 @@ var GuildChannel = class extends Channel {
1800
1894
  }
1801
1895
  /** Create a webhook for this channel. Requires Manage Webhooks. */
1802
1896
  async createWebhook(options) {
1803
- const data = await this.client.rest.post(Routes10.channelWebhooks(this.id), {
1897
+ const data = await this.client.rest.post(Routes11.channelWebhooks(this.id), {
1804
1898
  body: options,
1805
1899
  auth: true
1806
1900
  });
@@ -1808,13 +1902,13 @@ var GuildChannel = class extends Channel {
1808
1902
  }
1809
1903
  /** Fetch all webhooks in this channel. Requires Manage Webhooks. */
1810
1904
  async fetchWebhooks() {
1811
- const data = await this.client.rest.get(Routes10.channelWebhooks(this.id));
1905
+ const data = await this.client.rest.get(Routes11.channelWebhooks(this.id));
1812
1906
  return data.map((w) => new Webhook(this.client, w));
1813
1907
  }
1814
1908
  /** Create an invite for this channel. Requires Create Instant Invite. */
1815
1909
  async createInvite(options) {
1816
1910
  const body = options ? toChannelInviteBody(options) : {};
1817
- const data = await this.client.rest.post(Routes10.channelInvites(this.id), {
1911
+ const data = await this.client.rest.post(Routes11.channelInvites(this.id), {
1818
1912
  body: Object.keys(body).length ? body : void 0,
1819
1913
  auth: true
1820
1914
  });
@@ -1822,12 +1916,12 @@ var GuildChannel = class extends Channel {
1822
1916
  }
1823
1917
  /** Fetch all invites for this channel. Requires Manage Channels. */
1824
1918
  async fetchInvites() {
1825
- const data = await this.client.rest.get(Routes10.channelInvites(this.id));
1919
+ const data = await this.client.rest.get(Routes11.channelInvites(this.id));
1826
1920
  return data.map((i) => new Invite(this.client, i));
1827
1921
  }
1828
1922
  /** Edit or create a permission overwrite. Requires Manage Roles. */
1829
1923
  async editPermission(overwriteId, options) {
1830
- await this.client.rest.put(Routes10.channelPermission(this.id, overwriteId), {
1924
+ await this.client.rest.put(Routes11.channelPermission(this.id, overwriteId), {
1831
1925
  body: options,
1832
1926
  auth: true
1833
1927
  });
@@ -1843,7 +1937,7 @@ var GuildChannel = class extends Channel {
1843
1937
  }
1844
1938
  /** Delete a permission overwrite. Requires Manage Roles. */
1845
1939
  async deletePermission(overwriteId) {
1846
- await this.client.rest.delete(Routes10.channelPermission(this.id, overwriteId), { auth: true });
1940
+ await this.client.rest.delete(Routes11.channelPermission(this.id, overwriteId), { auth: true });
1847
1941
  const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
1848
1942
  if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
1849
1943
  }
@@ -1856,7 +1950,7 @@ var GuildChannel = class extends Channel {
1856
1950
  }
1857
1951
  /** Edit this channel's settings. Requires Manage Channels. */
1858
1952
  async edit(options) {
1859
- const data = await this.client.rest.patch(Routes10.channel(this.id), {
1953
+ const data = await this.client.rest.patch(Routes11.channel(this.id), {
1860
1954
  body: toChannelEditBody(options),
1861
1955
  auth: true
1862
1956
  });
@@ -1876,7 +1970,7 @@ var GuildChannel = class extends Channel {
1876
1970
  const qs2 = params.toString();
1877
1971
  const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
1878
1972
  const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
1879
- await this.client.rest.delete(Routes10.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1973
+ await this.client.rest.delete(Routes11.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1880
1974
  body,
1881
1975
  auth: true
1882
1976
  });
@@ -1938,7 +2032,7 @@ var LinkChannel = class extends GuildChannel {
1938
2032
  };
1939
2033
 
1940
2034
  // src/structures/channel/dm.ts
1941
- import { ChannelType as ChannelType2, Routes as Routes11 } from "@fluxerjs/types";
2035
+ import { ChannelType as ChannelType2, Routes as Routes12 } from "@fluxerjs/types";
1942
2036
  var DMChannel = class extends TextCapable(Channel) {
1943
2037
  /** ID of the last message sent in this channel. */
1944
2038
  lastMessageId;
@@ -1964,28 +2058,28 @@ var DMChannel = class extends TextCapable(Channel) {
1964
2058
  });
1965
2059
  }
1966
2060
  const data = await this.client.rest.post(
1967
- Routes11.channelMessagesPurge(this.id),
2061
+ Routes12.channelMessagesPurge(this.id),
1968
2062
  { auth: true }
1969
2063
  );
1970
2064
  return data.deleted_count;
1971
2065
  }
1972
2066
  /** Pin this DM channel to the top of the DM list. */
1973
2067
  async pinInList() {
1974
- await this.client.rest.put(Routes11.userMeChannelPin(this.id), { auth: true });
2068
+ await this.client.rest.put(Routes12.userMeChannelPin(this.id), { auth: true });
1975
2069
  }
1976
2070
  /** Unpin this DM channel from the DM list. */
1977
2071
  async unpinFromList() {
1978
- await this.client.rest.delete(Routes11.userMeChannelPin(this.id), { auth: true });
2072
+ await this.client.rest.delete(Routes12.userMeChannelPin(this.id), { auth: true });
1979
2073
  }
1980
2074
  /** Add a user to this group DM. */
1981
2075
  async addRecipient(userId) {
1982
- await this.client.rest.put(Routes11.channelRecipient(this.id, userId), { auth: true });
2076
+ await this.client.rest.put(Routes12.channelRecipient(this.id, userId), { auth: true });
1983
2077
  const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
1984
2078
  if (user) this.recipients.push(user);
1985
2079
  }
1986
2080
  /** Remove a user from this group DM. */
1987
2081
  async removeRecipient(userId, options) {
1988
- const url = Routes11.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2082
+ const url = Routes12.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
1989
2083
  await this.client.rest.delete(url, { auth: true });
1990
2084
  const idx = this.recipients.findIndex((u) => u.id === userId);
1991
2085
  if (idx >= 0) this.recipients.splice(idx, 1);
@@ -2023,8 +2117,8 @@ Channel.createDM = createDM;
2023
2117
 
2024
2118
  // src/client/ChannelManager.ts
2025
2119
  function rethrowNotFound(err, message, code) {
2026
- if (err instanceof RateLimitError2) throw err;
2027
- if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
2120
+ if (err instanceof RateLimitError3) throw err;
2121
+ if (err instanceof FluxerAPIError3 && err.statusCode === 404) {
2028
2122
  throw new FluxerError(message, { code, cause: err });
2029
2123
  }
2030
2124
  throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
@@ -2056,7 +2150,7 @@ var ChannelManager = class extends Collection5 {
2056
2150
  const cached = this.get(channelId);
2057
2151
  if (cached) return cached;
2058
2152
  try {
2059
- const data = await this.client.rest.get(Routes12.channel(channelId));
2153
+ const data = await this.client.rest.get(Routes13.channel(channelId));
2060
2154
  const channel = Channel.fromOrCreate(this.client, data);
2061
2155
  if (!channel) {
2062
2156
  throw new FluxerError("Channel data invalid or unsupported type", {
@@ -2089,7 +2183,7 @@ var ChannelManager = class extends Collection5 {
2089
2183
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
2090
2184
  });
2091
2185
  const data = await this.client.rest.post(
2092
- Routes12.channelMessages(channelId),
2186
+ Routes13.channelMessages(channelId),
2093
2187
  postPayload
2094
2188
  );
2095
2189
  this.client._addMessageToCache(channelId, data);
@@ -2099,8 +2193,8 @@ var ChannelManager = class extends Collection5 {
2099
2193
 
2100
2194
  // src/client/GuildManager.ts
2101
2195
  import { Collection as Collection9 } from "@fluxerjs/collection";
2102
- import { Routes as Routes27 } from "@fluxerjs/types";
2103
- import { FluxerAPIError as FluxerAPIError4, RateLimitError as RateLimitError3 } from "@fluxerjs/rest";
2196
+ import { Routes as Routes28 } from "@fluxerjs/types";
2197
+ import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
2104
2198
 
2105
2199
  // src/structures/guild/Guild.ts
2106
2200
  import { Collection as Collection8 } from "@fluxerjs/collection";
@@ -2108,10 +2202,10 @@ import { GuildNSFWLevel } from "@fluxerjs/types";
2108
2202
 
2109
2203
  // src/client/GuildMemberManager.ts
2110
2204
  import { Collection as Collection7 } from "@fluxerjs/collection";
2111
- import { Routes as Routes15 } from "@fluxerjs/types";
2205
+ import { Routes as Routes16 } from "@fluxerjs/types";
2112
2206
 
2113
2207
  // src/structures/GuildMember.ts
2114
- import { Routes as Routes14 } from "@fluxerjs/types";
2208
+ import { Routes as Routes15 } from "@fluxerjs/types";
2115
2209
  import { PermissionsBitField } from "@fluxerjs/util";
2116
2210
 
2117
2211
  // src/util/permissions.ts
@@ -2132,7 +2226,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
2132
2226
 
2133
2227
  // src/structures/GuildMemberRoleManager.ts
2134
2228
  import { Collection as Collection6 } from "@fluxerjs/collection";
2135
- import { Routes as Routes13 } from "@fluxerjs/types";
2229
+ import { Routes as Routes14 } from "@fluxerjs/types";
2136
2230
  function roleId(roleOrId) {
2137
2231
  return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
2138
2232
  }
@@ -2161,7 +2255,7 @@ var GuildMemberRoleManager = class {
2161
2255
  const id = roleId(roleOrId);
2162
2256
  if (this.ids.includes(id)) return;
2163
2257
  await this.member.client.rest.put(
2164
- Routes13.guildMemberRole(this.member.guild.id, this.member.id, id)
2258
+ Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
2165
2259
  );
2166
2260
  this.ids.push(id);
2167
2261
  }
@@ -2170,13 +2264,13 @@ var GuildMemberRoleManager = class {
2170
2264
  const idx = this.ids.indexOf(id);
2171
2265
  if (idx === -1) return;
2172
2266
  await this.member.client.rest.delete(
2173
- Routes13.guildMemberRole(this.member.guild.id, this.member.id, id)
2267
+ Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
2174
2268
  );
2175
2269
  this.ids.splice(idx, 1);
2176
2270
  }
2177
2271
  async set(roleIds) {
2178
2272
  const data = await this.member.client.rest.patch(
2179
- Routes13.guildMember(this.member.guild.id, this.member.id),
2273
+ Routes14.guildMember(this.member.guild.id, this.member.id),
2180
2274
  { body: { roles: roleIds }, auth: true }
2181
2275
  );
2182
2276
  this.ids = data.roles ? [...data.roles] : [];
@@ -2303,7 +2397,7 @@ var GuildMember = class _GuildMember extends Base {
2303
2397
  /** PATCH member (`/members/@me` when editing the bot). */
2304
2398
  async edit(options) {
2305
2399
  const isMe = this.client.user?.id === this.id;
2306
- const route = isMe ? Routes14.guildMemberMe(this.guild.id) : Routes14.guildMember(this.guild.id, this.id);
2400
+ const route = isMe ? Routes15.guildMemberMe(this.guild.id) : Routes15.guildMember(this.guild.id, this.id);
2307
2401
  const data = await this.client.rest.patch(route, {
2308
2402
  body: toMemberEditBody(options),
2309
2403
  auth: true
@@ -2432,7 +2526,7 @@ var GuildMemberManager = class extends Collection7 {
2432
2526
  if (options?.limit != null) params.set("limit", String(options.limit));
2433
2527
  if (options?.after) params.set("after", options.after);
2434
2528
  const qs2 = params.toString();
2435
- const url = Routes15.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2529
+ const url = Routes16.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2436
2530
  const data = await this.guild.client.rest.get(url, { auth: true });
2437
2531
  const members = [];
2438
2532
  for (const m of data) {
@@ -2455,7 +2549,7 @@ var GuildMemberManager = class extends Collection7 {
2455
2549
  */
2456
2550
  async search(options = {}) {
2457
2551
  const data = await this.guild.client.rest.post(
2458
- Routes15.guildMembersSearch(this.guild.id),
2552
+ Routes16.guildMembersSearch(this.guild.id),
2459
2553
  { body: toMemberSearchBody(options), auth: true }
2460
2554
  );
2461
2555
  const offset = options.offset ?? 0;
@@ -2481,7 +2575,7 @@ var GuildMemberManager = class extends Collection7 {
2481
2575
  };
2482
2576
 
2483
2577
  // src/structures/Role.ts
2484
- import { Routes as Routes16 } from "@fluxerjs/types";
2578
+ import { Routes as Routes17 } from "@fluxerjs/types";
2485
2579
  import { ALL_PERMISSIONS_BIGINT as ALL_PERMISSIONS_BIGINT2, PermissionFlags as PermissionFlags4, PermissionsBitField as PermissionsBitField2 } from "@fluxerjs/util";
2486
2580
 
2487
2581
  // src/structures/roleOptions.ts
@@ -2594,7 +2688,7 @@ var Role = class _Role extends Base {
2594
2688
  */
2595
2689
  async edit(options) {
2596
2690
  const body = toRoleRequestBody(options);
2597
- const data = await this.client.rest.patch(Routes16.guildRole(this.guildId, this.id), {
2691
+ const data = await this.client.rest.patch(Routes17.guildRole(this.guildId, this.id), {
2598
2692
  body: Object.keys(body).length ? body : void 0,
2599
2693
  auth: true
2600
2694
  });
@@ -2605,18 +2699,18 @@ var Role = class _Role extends Base {
2605
2699
  * DELETE role. Requires Manage Roles.
2606
2700
  */
2607
2701
  async delete() {
2608
- await this.client.rest.delete(Routes16.guildRole(this.guildId, this.id), { auth: true });
2702
+ await this.client.rest.delete(Routes17.guildRole(this.guildId, this.id), { auth: true });
2609
2703
  this.client.guilds.get(this.guildId)?.roles.delete(this.id);
2610
2704
  }
2611
2705
  };
2612
2706
 
2613
2707
  // src/structures/guild/admin.ts
2614
- import { Routes as Routes17 } from "@fluxerjs/types";
2708
+ import { Routes as Routes18 } from "@fluxerjs/types";
2615
2709
 
2616
2710
  // src/structures/guild/http.ts
2617
- import { FluxerAPIError as FluxerAPIError3 } from "@fluxerjs/rest";
2711
+ import { FluxerAPIError as FluxerAPIError4 } from "@fluxerjs/rest";
2618
2712
  function httpStatus(err) {
2619
- if (err instanceof FluxerAPIError3) return err.statusCode;
2713
+ if (err instanceof FluxerAPIError4) return err.statusCode;
2620
2714
  if (typeof err === "object" && err !== null && "statusCode" in err) {
2621
2715
  const code = err.statusCode;
2622
2716
  return typeof code === "number" ? code : void 0;
@@ -2716,7 +2810,7 @@ function toVanityPayload(data) {
2716
2810
  return { code: data.code ?? null, uses: data.uses };
2717
2811
  }
2718
2812
  async function fetchAuditLogs(guild, options) {
2719
- const url = Routes17.guildAuditLogs(guild.id) + qs({
2813
+ const url = Routes18.guildAuditLogs(guild.id) + qs({
2720
2814
  limit: options?.limit,
2721
2815
  before: options?.before,
2722
2816
  after: options?.after,
@@ -2737,7 +2831,7 @@ async function fetchAuditLogs(guild, options) {
2737
2831
  };
2738
2832
  }
2739
2833
  async function editGuild(guild, options) {
2740
- const data = await guild.client.rest.patch(Routes17.guild(guild.id), {
2834
+ const data = await guild.client.rest.patch(Routes18.guild(guild.id), {
2741
2835
  body: toGuildEditBody(options),
2742
2836
  auth: true
2743
2837
  });
@@ -2745,13 +2839,13 @@ async function editGuild(guild, options) {
2745
2839
  return guild;
2746
2840
  }
2747
2841
  async function fetchVanityURL(guild) {
2748
- const data = await guild.client.rest.get(Routes17.guildVanityUrl(guild.id), {
2842
+ const data = await guild.client.rest.get(Routes18.guildVanityUrl(guild.id), {
2749
2843
  auth: true
2750
2844
  });
2751
2845
  return toVanityPayload(data);
2752
2846
  }
2753
2847
  async function editVanityURL(guild, code) {
2754
- const data = await guild.client.rest.patch(Routes17.guildVanityUrl(guild.id), {
2848
+ const data = await guild.client.rest.patch(Routes18.guildVanityUrl(guild.id), {
2755
2849
  body: { code },
2756
2850
  auth: true
2757
2851
  });
@@ -2759,14 +2853,14 @@ async function editVanityURL(guild, code) {
2759
2853
  return toVanityPayload(data);
2760
2854
  }
2761
2855
  async function fetchDiscoveryStatus(guild) {
2762
- const data = await guild.client.rest.get(Routes17.guildDiscovery(guild.id), {
2856
+ const data = await guild.client.rest.get(Routes18.guildDiscovery(guild.id), {
2763
2857
  auth: true
2764
2858
  });
2765
2859
  return toDiscoveryStatusPayload(data);
2766
2860
  }
2767
2861
  async function applyForDiscovery(guild, options) {
2768
2862
  const data = await guild.client.rest.post(
2769
- Routes17.guildDiscovery(guild.id),
2863
+ Routes18.guildDiscovery(guild.id),
2770
2864
  {
2771
2865
  body: toDiscoveryBody(options),
2772
2866
  auth: true
@@ -2776,7 +2870,7 @@ async function applyForDiscovery(guild, options) {
2776
2870
  }
2777
2871
  async function editDiscoveryApplication(guild, options) {
2778
2872
  const data = await guild.client.rest.patch(
2779
- Routes17.guildDiscovery(guild.id),
2873
+ Routes18.guildDiscovery(guild.id),
2780
2874
  {
2781
2875
  body: toDiscoveryBody(options),
2782
2876
  auth: true
@@ -2785,28 +2879,28 @@ async function editDiscoveryApplication(guild, options) {
2785
2879
  return toDiscoveryApplicationPayload(data);
2786
2880
  }
2787
2881
  async function withdrawDiscoveryApplication(guild) {
2788
- await guild.client.rest.delete(Routes17.guildDiscovery(guild.id), { auth: true });
2882
+ await guild.client.rest.delete(Routes18.guildDiscovery(guild.id), { auth: true });
2789
2883
  }
2790
2884
  async function deleteGuild(guild, options) {
2791
2885
  const body = options ? toSudoBody(options) : {};
2792
- await guild.client.rest.post(Routes17.guildDelete(guild.id), {
2886
+ await guild.client.rest.post(Routes18.guildDelete(guild.id), {
2793
2887
  body,
2794
2888
  auth: true
2795
2889
  });
2796
2890
  guild.client.guilds.delete(guild.id);
2797
2891
  }
2798
2892
  async function transferOwnership(guild, newOwnerId, password) {
2799
- await guild.client.rest.post(Routes17.guildTransferOwnership(guild.id), {
2893
+ await guild.client.rest.post(Routes18.guildTransferOwnership(guild.id), {
2800
2894
  body: { new_owner_id: newOwnerId, ...password != null && { password } },
2801
2895
  auth: true
2802
2896
  });
2803
2897
  }
2804
2898
 
2805
2899
  // src/structures/guild/channels.ts
2806
- import { Routes as Routes20 } from "@fluxerjs/types";
2900
+ import { Routes as Routes21 } from "@fluxerjs/types";
2807
2901
 
2808
2902
  // src/structures/GuildEmoji.ts
2809
- import { Routes as Routes18 } from "@fluxerjs/types";
2903
+ import { Routes as Routes19 } from "@fluxerjs/types";
2810
2904
  var GuildEmoji = class extends Base {
2811
2905
  client;
2812
2906
  id;
@@ -2834,7 +2928,7 @@ var GuildEmoji = class extends Base {
2834
2928
  }
2835
2929
  /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
2836
2930
  async delete() {
2837
- await this.client.rest.delete(Routes18.guildEmoji(this.guildId, this.id), {
2931
+ await this.client.rest.delete(Routes19.guildEmoji(this.guildId, this.id), {
2838
2932
  auth: true
2839
2933
  });
2840
2934
  const guild = this.client.guilds.get(this.guildId);
@@ -2845,7 +2939,7 @@ var GuildEmoji = class extends Base {
2845
2939
  * Requires Manage Emojis and Stickers permission.
2846
2940
  */
2847
2941
  async edit(options) {
2848
- const data = await this.client.rest.patch(Routes18.guildEmoji(this.guildId, this.id), {
2942
+ const data = await this.client.rest.patch(Routes19.guildEmoji(this.guildId, this.id), {
2849
2943
  body: options,
2850
2944
  auth: true
2851
2945
  });
@@ -2855,7 +2949,7 @@ var GuildEmoji = class extends Base {
2855
2949
  };
2856
2950
 
2857
2951
  // src/structures/GuildSticker.ts
2858
- import { Routes as Routes19 } from "@fluxerjs/types";
2952
+ import { Routes as Routes20 } from "@fluxerjs/types";
2859
2953
  var GuildSticker = class extends Base {
2860
2954
  client;
2861
2955
  id;
@@ -2886,7 +2980,7 @@ var GuildSticker = class extends Base {
2886
2980
  }
2887
2981
  /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
2888
2982
  async delete() {
2889
- await this.client.rest.delete(Routes19.guildSticker(this.guildId, this.id), {
2983
+ await this.client.rest.delete(Routes20.guildSticker(this.guildId, this.id), {
2890
2984
  auth: true
2891
2985
  });
2892
2986
  }
@@ -2895,7 +2989,7 @@ var GuildSticker = class extends Base {
2895
2989
  * Requires Manage Emojis and Stickers permission.
2896
2990
  */
2897
2991
  async edit(options) {
2898
- const data = await this.client.rest.patch(Routes19.guildSticker(this.guildId, this.id), {
2992
+ const data = await this.client.rest.patch(Routes20.guildSticker(this.guildId, this.id), {
2899
2993
  body: options,
2900
2994
  auth: true
2901
2995
  });
@@ -2950,14 +3044,14 @@ function cacheSticker(guild, data) {
2950
3044
 
2951
3045
  // src/structures/guild/channels.ts
2952
3046
  async function createChannel(guild, data) {
2953
- const created = await guild.client.rest.post(Routes20.guildChannels(guild.id), {
3047
+ const created = await guild.client.rest.post(Routes21.guildChannels(guild.id), {
2954
3048
  body: data,
2955
3049
  auth: true
2956
3050
  });
2957
3051
  return cacheChannel(guild, created);
2958
3052
  }
2959
3053
  async function fetchChannels(guild) {
2960
- const data = await guild.client.rest.get(Routes20.guildChannels(guild.id));
3054
+ const data = await guild.client.rest.get(Routes21.guildChannels(guild.id));
2961
3055
  const channels = [];
2962
3056
  for (const ch of data) {
2963
3057
  const channel = cacheChannel(guild, ch);
@@ -2966,17 +3060,17 @@ async function fetchChannels(guild) {
2966
3060
  return channels;
2967
3061
  }
2968
3062
  async function setChannelPositions(guild, updates) {
2969
- await guild.client.rest.patch(Routes20.guildChannels(guild.id), {
3063
+ await guild.client.rest.patch(Routes21.guildChannels(guild.id), {
2970
3064
  body: toChannelPositionBody(updates),
2971
3065
  auth: true
2972
3066
  });
2973
3067
  }
2974
3068
  async function fetchWebhooks(guild) {
2975
- const data = await guild.client.rest.get(Routes20.guildWebhooks(guild.id));
3069
+ const data = await guild.client.rest.get(Routes21.guildWebhooks(guild.id));
2976
3070
  return data.map((w) => new Webhook(guild.client, w));
2977
3071
  }
2978
3072
  async function fetchInvites(guild) {
2979
- const data = await guild.client.rest.get(Routes20.guildInvites(guild.id));
3073
+ const data = await guild.client.rest.get(Routes21.guildInvites(guild.id));
2980
3074
  return data.map((invite) => new Invite(guild.client, invite));
2981
3075
  }
2982
3076
  async function fetchInvite(guild, codeOrUrl) {
@@ -2984,14 +3078,14 @@ async function fetchInvite(guild, codeOrUrl) {
2984
3078
  }
2985
3079
 
2986
3080
  // src/structures/guild/emojis.ts
2987
- import { Routes as Routes21 } from "@fluxerjs/types";
3081
+ import { Routes as Routes22 } from "@fluxerjs/types";
2988
3082
  async function fetchEmojis(guild) {
2989
- const data = await guild.client.rest.get(Routes21.guildEmojis(guild.id));
3083
+ const data = await guild.client.rest.get(Routes22.guildEmojis(guild.id));
2990
3084
  return data.map((e) => cacheEmoji(guild, e));
2991
3085
  }
2992
3086
  async function fetchEmoji(guild, emojiId) {
2993
3087
  try {
2994
- const data = await guild.client.rest.get(Routes21.guildEmoji(guild.id, emojiId));
3088
+ const data = await guild.client.rest.get(Routes22.guildEmoji(guild.id, emojiId));
2995
3089
  return cacheEmoji(guild, data);
2996
3090
  } catch (err) {
2997
3091
  rethrowNotFound2(
@@ -3002,14 +3096,14 @@ async function fetchEmoji(guild, emojiId) {
3002
3096
  }
3003
3097
  }
3004
3098
  async function createEmoji(guild, options) {
3005
- const data = await guild.client.rest.post(Routes21.guildEmojis(guild.id), {
3099
+ const data = await guild.client.rest.post(Routes22.guildEmojis(guild.id), {
3006
3100
  body: options,
3007
3101
  auth: true
3008
3102
  });
3009
3103
  return cacheEmoji(guild, data);
3010
3104
  }
3011
3105
  async function cloneEmoji(guild, sourceEmojiId) {
3012
- const data = await guild.client.rest.post(Routes21.guildEmojisClone(guild.id), {
3106
+ const data = await guild.client.rest.post(Routes22.guildEmojisClone(guild.id), {
3013
3107
  body: { source_emoji_id: sourceEmojiId },
3014
3108
  auth: true
3015
3109
  });
@@ -3017,18 +3111,18 @@ async function cloneEmoji(guild, sourceEmojiId) {
3017
3111
  }
3018
3112
  async function createEmojisBulk(guild, emojis) {
3019
3113
  const data = await guild.client.rest.post(
3020
- Routes21.guildEmojisBulk(guild.id),
3114
+ Routes22.guildEmojisBulk(guild.id),
3021
3115
  { body: { emojis }, auth: true }
3022
3116
  );
3023
3117
  return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
3024
3118
  }
3025
3119
 
3026
3120
  // src/structures/guild/members.ts
3027
- import { Routes as Routes22 } from "@fluxerjs/types";
3121
+ import { Routes as Routes23 } from "@fluxerjs/types";
3028
3122
  async function fetchMember(guild, userId) {
3029
3123
  try {
3030
3124
  const data = await guild.client.rest.get(
3031
- Routes22.guildMember(guild.id, userId)
3125
+ Routes23.guildMember(guild.id, userId)
3032
3126
  );
3033
3127
  return cacheMember(guild, data);
3034
3128
  } catch (err) {
@@ -3041,17 +3135,17 @@ async function fetchMember(guild, userId) {
3041
3135
  }
3042
3136
  async function fetchMe(guild) {
3043
3137
  const data = await guild.client.rest.get(
3044
- Routes22.guildMemberMe(guild.id),
3138
+ Routes23.guildMemberMe(guild.id),
3045
3139
  { auth: true }
3046
3140
  );
3047
3141
  return cacheMember(guild, data);
3048
3142
  }
3049
3143
 
3050
3144
  // src/structures/guild/moderation.ts
3051
- import { Routes as Routes24 } from "@fluxerjs/types";
3145
+ import { Routes as Routes25 } from "@fluxerjs/types";
3052
3146
 
3053
3147
  // src/structures/GuildBan.ts
3054
- import { Routes as Routes23 } from "@fluxerjs/types";
3148
+ import { Routes as Routes24 } from "@fluxerjs/types";
3055
3149
  var GuildBan = class extends Base {
3056
3150
  client;
3057
3151
  guildId;
@@ -3073,7 +3167,7 @@ var GuildBan = class extends Base {
3073
3167
  * Requires Ban Members permission.
3074
3168
  */
3075
3169
  async unban() {
3076
- await this.client.rest.delete(Routes23.guildBan(this.guildId, this.user.id), {
3170
+ await this.client.rest.delete(Routes24.guildBan(this.guildId, this.user.id), {
3077
3171
  auth: true
3078
3172
  });
3079
3173
  }
@@ -3082,40 +3176,40 @@ var GuildBan = class extends Base {
3082
3176
  // src/structures/guild/moderation.ts
3083
3177
  async function ban(guild, userId, options) {
3084
3178
  const body = options ? toGuildBanBody(options) : {};
3085
- await guild.client.rest.put(Routes24.guildBan(guild.id, userId), {
3179
+ await guild.client.rest.put(Routes25.guildBan(guild.id, userId), {
3086
3180
  body: Object.keys(body).length ? body : void 0,
3087
3181
  auth: true
3088
3182
  });
3089
3183
  }
3090
3184
  async function fetchBans(guild) {
3091
- const data = await guild.client.rest.get(Routes24.guildBans(guild.id));
3185
+ const data = await guild.client.rest.get(Routes25.guildBans(guild.id));
3092
3186
  return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
3093
3187
  }
3094
3188
  async function unban(guild, userId) {
3095
- await guild.client.rest.delete(Routes24.guildBan(guild.id, userId), { auth: true });
3189
+ await guild.client.rest.delete(Routes25.guildBan(guild.id, userId), { auth: true });
3096
3190
  }
3097
3191
  async function kick(guild, userId) {
3098
- await guild.client.rest.delete(Routes24.guildMember(guild.id, userId), { auth: true });
3192
+ await guild.client.rest.delete(Routes25.guildMember(guild.id, userId), { auth: true });
3099
3193
  }
3100
3194
 
3101
3195
  // src/structures/guild/roles.ts
3102
- import { Routes as Routes25 } from "@fluxerjs/types";
3196
+ import { Routes as Routes26 } from "@fluxerjs/types";
3103
3197
  import { parseRoleMention } from "@fluxerjs/util";
3104
3198
  async function createRole(guild, options = {}) {
3105
3199
  const body = toRoleRequestBody(options);
3106
- const data = await guild.client.rest.post(Routes25.guildRoles(guild.id), {
3200
+ const data = await guild.client.rest.post(Routes26.guildRoles(guild.id), {
3107
3201
  body: Object.keys(body).length ? body : void 0,
3108
3202
  auth: true
3109
3203
  });
3110
3204
  return cacheRole(guild, data);
3111
3205
  }
3112
3206
  async function fetchRoles(guild) {
3113
- const data = await guild.client.rest.get(Routes25.guildRoles(guild.id));
3207
+ const data = await guild.client.rest.get(Routes26.guildRoles(guild.id));
3114
3208
  return data.map((r) => cacheRole(guild, r));
3115
3209
  }
3116
3210
  async function fetchRole(guild, roleId2) {
3117
3211
  try {
3118
- const data = await guild.client.rest.get(Routes25.guildRole(guild.id, roleId2));
3212
+ const data = await guild.client.rest.get(Routes26.guildRole(guild.id, roleId2));
3119
3213
  return cacheRole(guild, data);
3120
3214
  } catch (err) {
3121
3215
  rethrowNotFound2(
@@ -3133,7 +3227,7 @@ async function resolveRoleId(guild, arg) {
3133
3227
  const needle = trimmed.toLowerCase();
3134
3228
  const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
3135
3229
  if (cached) return cached.id;
3136
- const roles = await guild.client.rest.get(Routes25.guildRoles(guild.id));
3230
+ const roles = await guild.client.rest.get(Routes26.guildRoles(guild.id));
3137
3231
  const role = roles.find((r) => r.name?.toLowerCase() === needle);
3138
3232
  if (!role) return null;
3139
3233
  cacheRole(guild, role);
@@ -3142,7 +3236,7 @@ async function resolveRoleId(guild, arg) {
3142
3236
  async function setRolePositions(guild, updates) {
3143
3237
  return replaceRoles(
3144
3238
  guild,
3145
- await guild.client.rest.patch(Routes25.guildRoles(guild.id), {
3239
+ await guild.client.rest.patch(Routes26.guildRoles(guild.id), {
3146
3240
  body: updates,
3147
3241
  auth: true
3148
3242
  })
@@ -3151,7 +3245,7 @@ async function setRolePositions(guild, updates) {
3151
3245
  async function setRoleHoistPositions(guild, updates) {
3152
3246
  return replaceRoles(
3153
3247
  guild,
3154
- await guild.client.rest.patch(Routes25.guildRolesHoistPositions(guild.id), {
3248
+ await guild.client.rest.patch(Routes26.guildRolesHoistPositions(guild.id), {
3155
3249
  body: updates.map((u) => ({
3156
3250
  id: u.id,
3157
3251
  ...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
@@ -3163,23 +3257,23 @@ async function setRoleHoistPositions(guild, updates) {
3163
3257
  async function resetRoleHoistPositions(guild) {
3164
3258
  return replaceRoles(
3165
3259
  guild,
3166
- await guild.client.rest.delete(Routes25.guildRolesHoistPositions(guild.id), {
3260
+ await guild.client.rest.delete(Routes26.guildRolesHoistPositions(guild.id), {
3167
3261
  auth: true
3168
3262
  })
3169
3263
  );
3170
3264
  }
3171
3265
 
3172
3266
  // src/structures/guild/stickers.ts
3173
- import { Routes as Routes26 } from "@fluxerjs/types";
3267
+ import { Routes as Routes27 } from "@fluxerjs/types";
3174
3268
  async function createSticker(guild, options) {
3175
- const data = await guild.client.rest.post(Routes26.guildStickers(guild.id), {
3269
+ const data = await guild.client.rest.post(Routes27.guildStickers(guild.id), {
3176
3270
  body: options,
3177
3271
  auth: true
3178
3272
  });
3179
3273
  return cacheSticker(guild, data);
3180
3274
  }
3181
3275
  async function cloneSticker(guild, sourceStickerId) {
3182
- const data = await guild.client.rest.post(Routes26.guildStickersClone(guild.id), {
3276
+ const data = await guild.client.rest.post(Routes27.guildStickersClone(guild.id), {
3183
3277
  body: { source_sticker_id: sourceStickerId },
3184
3278
  auth: true
3185
3279
  });
@@ -3187,17 +3281,17 @@ async function cloneSticker(guild, sourceStickerId) {
3187
3281
  }
3188
3282
  async function createStickersBulk(guild, stickers) {
3189
3283
  const data = await guild.client.rest.post(
3190
- Routes26.guildStickersBulk(guild.id),
3284
+ Routes27.guildStickersBulk(guild.id),
3191
3285
  { body: { stickers }, auth: true }
3192
3286
  );
3193
3287
  return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
3194
3288
  }
3195
3289
  async function fetchStickers(guild) {
3196
- const data = await guild.client.rest.get(Routes26.guildStickers(guild.id));
3290
+ const data = await guild.client.rest.get(Routes27.guildStickers(guild.id));
3197
3291
  return data.map((s) => cacheSticker(guild, s));
3198
3292
  }
3199
3293
  async function fetchSticker(guild, stickerId) {
3200
- const data = await guild.client.rest.get(Routes26.guildSticker(guild.id, stickerId));
3294
+ const data = await guild.client.rest.get(Routes27.guildSticker(guild.id, stickerId));
3201
3295
  return cacheSticker(guild, data);
3202
3296
  }
3203
3297
 
@@ -3207,6 +3301,8 @@ var Guild = class extends Base {
3207
3301
  client;
3208
3302
  /** Snowflake ID of this guild. */
3209
3303
  id;
3304
+ /** Whether the guild is currently available through the gateway. */
3305
+ available = true;
3210
3306
  /** Guild name. */
3211
3307
  name;
3212
3308
  /** Icon hash (use {@link iconURL} to get full CDN URL). */
@@ -3542,13 +3638,13 @@ var GuildManager = class extends Collection9 {
3542
3638
  const cached = this.get(guildId);
3543
3639
  if (cached) return cached;
3544
3640
  try {
3545
- const data = await this.client.rest.get(Routes27.guild(guildId));
3641
+ const data = await this.client.rest.get(Routes28.guild(guildId));
3546
3642
  const guild = new Guild(this.client, data);
3547
3643
  this.set(guild.id, guild);
3548
3644
  return guild;
3549
3645
  } catch (err) {
3550
- if (err instanceof RateLimitError3) throw err;
3551
- if (err instanceof FluxerAPIError4 && err.statusCode === 404) {
3646
+ if (err instanceof RateLimitError4) throw err;
3647
+ if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
3552
3648
  throw new FluxerError(`Guild ${guildId} not found`, {
3553
3649
  code: ErrorCodes.GuildNotFound,
3554
3650
  cause: err
@@ -3569,7 +3665,7 @@ var DEFAULT_CACHE_LIMITS = {
3569
3665
  };
3570
3666
 
3571
3667
  // src/structures/User.ts
3572
- import { Routes as Routes28 } from "@fluxerjs/types";
3668
+ import { Routes as Routes29 } from "@fluxerjs/types";
3573
3669
  var User = class extends Base {
3574
3670
  /** Parent client instance. */
3575
3671
  client;
@@ -3659,7 +3755,7 @@ var User = class extends Base {
3659
3755
  * @returns DM channel instance (cached if already open)
3660
3756
  */
3661
3757
  async createDM() {
3662
- const data = await this.client.rest.post(Routes28.userMeChannels(), {
3758
+ const data = await this.client.rest.post(Routes29.userMeChannels(), {
3663
3759
  body: { recipient_id: this.id },
3664
3760
  auth: true
3665
3761
  });
@@ -3669,7 +3765,7 @@ var User = class extends Base {
3669
3765
  }
3670
3766
  /**
3671
3767
  * Send a DM to this user.
3672
- * @param options - Message content or {@link MessageSendOptions}
3768
+ * @param options - {@link MessagePrepareInput}
3673
3769
  * @returns Sent message
3674
3770
  */
3675
3771
  async send(options) {
@@ -3680,7 +3776,7 @@ var User = class extends Base {
3680
3776
  // src/client/UserManager.ts
3681
3777
  import { Collection as Collection10 } from "@fluxerjs/collection";
3682
3778
  import {
3683
- Routes as Routes29
3779
+ Routes as Routes30
3684
3780
  } from "@fluxerjs/types";
3685
3781
  var soft = (p) => p.catch(() => null);
3686
3782
  var UserManager = class extends Collection10 {
@@ -3712,7 +3808,7 @@ var UserManager = class extends Collection10 {
3712
3808
  }
3713
3809
  /** Fetch a user by ID and update cache. */
3714
3810
  async fetch(userId) {
3715
- const data = await this.client.rest.get(Routes29.user(userId));
3811
+ const data = await this.client.rest.get(Routes30.user(userId));
3716
3812
  return this.client.getOrCreateUser(data);
3717
3813
  }
3718
3814
  /**
@@ -3726,10 +3822,10 @@ var UserManager = class extends Collection10 {
3726
3822
  async fetchWithProfile(userId, options) {
3727
3823
  const guildId = options?.guildId ?? void 0;
3728
3824
  const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
3729
- this.client.rest.get(Routes29.user(userId)),
3730
- soft(this.client.rest.get(Routes29.userProfile(userId))),
3731
- guildId ? soft(this.client.rest.get(Routes29.userProfile(userId, guildId))) : null,
3732
- guildId ? soft(this.client.rest.get(Routes29.guildMember(guildId, userId))) : null
3825
+ this.client.rest.get(Routes30.user(userId)),
3826
+ soft(this.client.rest.get(Routes30.userProfile(userId))),
3827
+ guildId ? soft(this.client.rest.get(Routes30.userProfile(userId, guildId))) : null,
3828
+ guildId ? soft(this.client.rest.get(Routes30.guildMember(guildId, userId))) : null
3733
3829
  ]);
3734
3830
  const user = this.client.getOrCreateUser(userData);
3735
3831
  let member = null;
@@ -3759,7 +3855,7 @@ var UserManager = class extends Collection10 {
3759
3855
 
3760
3856
  // src/client/PackManager.ts
3761
3857
  import {
3762
- Routes as Routes30
3858
+ Routes as Routes31
3763
3859
  } from "@fluxerjs/types";
3764
3860
  function toPackSummaryPayload(data) {
3765
3861
  return {
@@ -3815,7 +3911,7 @@ var PackManager = class {
3815
3911
  }
3816
3912
  /** Fetch the current user's pack dashboard (camelCase summaries). */
3817
3913
  async fetchDashboard() {
3818
- const data = await this.client.rest.get(Routes30.packs());
3914
+ const data = await this.client.rest.get(Routes31.packs());
3819
3915
  return {
3820
3916
  emoji: mapDashboardSection(data.emoji),
3821
3917
  sticker: mapDashboardSection(data.sticker)
@@ -3823,49 +3919,49 @@ var PackManager = class {
3823
3919
  }
3824
3920
  /** Create a pack. */
3825
3921
  async create(packType, body) {
3826
- const data = await this.client.rest.post(Routes30.packsByType(packType), {
3922
+ const data = await this.client.rest.post(Routes31.packsByType(packType), {
3827
3923
  body
3828
3924
  });
3829
3925
  return toPackSummaryPayload(data);
3830
3926
  }
3831
3927
  /** Edit a pack. */
3832
3928
  async edit(packId, body) {
3833
- const data = await this.client.rest.patch(Routes30.pack(packId), { body });
3929
+ const data = await this.client.rest.patch(Routes31.pack(packId), { body });
3834
3930
  return toPackSummaryPayload(data);
3835
3931
  }
3836
3932
  /** Delete a pack. */
3837
3933
  async delete(packId) {
3838
- await this.client.rest.delete(Routes30.pack(packId));
3934
+ await this.client.rest.delete(Routes31.pack(packId));
3839
3935
  }
3840
3936
  /** Install a pack for the current user. */
3841
3937
  async install(packId) {
3842
- await this.client.rest.post(Routes30.packInstall(packId));
3938
+ await this.client.rest.post(Routes31.packInstall(packId));
3843
3939
  }
3844
3940
  /** Uninstall a pack for the current user. */
3845
3941
  async uninstall(packId) {
3846
- await this.client.rest.delete(Routes30.packInstall(packId));
3942
+ await this.client.rest.delete(Routes31.packInstall(packId));
3847
3943
  }
3848
3944
  /** List invites for a pack. */
3849
3945
  async listInvites(packId) {
3850
- const data = await this.client.rest.get(Routes30.packInvites(packId));
3946
+ const data = await this.client.rest.get(Routes31.packInvites(packId));
3851
3947
  return data.map(toInvitePayload);
3852
3948
  }
3853
3949
  /** Create an invite for a pack. */
3854
3950
  async createInvite(packId, options = {}) {
3855
3951
  const body = toPackInviteBody(options);
3856
- const data = await this.client.rest.post(Routes30.packInvites(packId), {
3952
+ const data = await this.client.rest.post(Routes31.packInvites(packId), {
3857
3953
  body: Object.keys(body).length ? body : void 0
3858
3954
  });
3859
3955
  return toInvitePayload(data);
3860
3956
  }
3861
3957
  /** List emojis in a pack. */
3862
3958
  async listEmojis(packId) {
3863
- const data = await this.client.rest.get(Routes30.packEmojis(packId));
3959
+ const data = await this.client.rest.get(Routes31.packEmojis(packId));
3864
3960
  return data.map(toEmojiPayload);
3865
3961
  }
3866
3962
  /** Create an emoji in a pack. */
3867
3963
  async createEmoji(packId, options) {
3868
- const data = await this.client.rest.post(Routes30.packEmojis(packId), {
3964
+ const data = await this.client.rest.post(Routes31.packEmojis(packId), {
3869
3965
  body: toEmojiCreateBody(options)
3870
3966
  });
3871
3967
  return toEmojiPayload(data);
@@ -3873,7 +3969,7 @@ var PackManager = class {
3873
3969
  /** Bulk-create emojis in a pack. */
3874
3970
  async createEmojisBulk(packId, emojis) {
3875
3971
  const data = await this.client.rest.post(
3876
- Routes30.packEmojisBulk(packId),
3972
+ Routes31.packEmojisBulk(packId),
3877
3973
  { body: { emojis: emojis.map(toEmojiCreateBody) } }
3878
3974
  );
3879
3975
  return {
@@ -3883,23 +3979,23 @@ var PackManager = class {
3883
3979
  }
3884
3980
  /** Edit an emoji in a pack. */
3885
3981
  async editEmoji(packId, emojiId, options) {
3886
- const data = await this.client.rest.patch(Routes30.packEmoji(packId, emojiId), {
3982
+ const data = await this.client.rest.patch(Routes31.packEmoji(packId, emojiId), {
3887
3983
  body: toEmojiEditBody(options)
3888
3984
  });
3889
3985
  return toEmojiPayload(data);
3890
3986
  }
3891
3987
  /** Delete an emoji from a pack. */
3892
3988
  async deleteEmoji(packId, emojiId) {
3893
- await this.client.rest.delete(Routes30.packEmoji(packId, emojiId));
3989
+ await this.client.rest.delete(Routes31.packEmoji(packId, emojiId));
3894
3990
  }
3895
3991
  /** List stickers in a pack. */
3896
3992
  async listStickers(packId) {
3897
- const data = await this.client.rest.get(Routes30.packStickers(packId));
3993
+ const data = await this.client.rest.get(Routes31.packStickers(packId));
3898
3994
  return data.map(toStickerPayload);
3899
3995
  }
3900
3996
  /** Create a sticker in a pack. */
3901
3997
  async createSticker(packId, options) {
3902
- const data = await this.client.rest.post(Routes30.packStickers(packId), {
3998
+ const data = await this.client.rest.post(Routes31.packStickers(packId), {
3903
3999
  body: toStickerCreateBody(options)
3904
4000
  });
3905
4001
  return toStickerPayload(data);
@@ -3907,7 +4003,7 @@ var PackManager = class {
3907
4003
  /** Bulk-create stickers in a pack. */
3908
4004
  async createStickersBulk(packId, stickers) {
3909
4005
  const data = await this.client.rest.post(
3910
- Routes30.packStickersBulk(packId),
4006
+ Routes31.packStickersBulk(packId),
3911
4007
  { body: { stickers: stickers.map(toStickerCreateBody) } }
3912
4008
  );
3913
4009
  return {
@@ -3917,14 +4013,14 @@ var PackManager = class {
3917
4013
  }
3918
4014
  /** Edit a sticker in a pack. */
3919
4015
  async editSticker(packId, stickerId, options) {
3920
- const data = await this.client.rest.patch(Routes30.packSticker(packId, stickerId), {
4016
+ const data = await this.client.rest.patch(Routes31.packSticker(packId, stickerId), {
3921
4017
  body: toStickerEditBody(options)
3922
4018
  });
3923
4019
  return toStickerPayload(data);
3924
4020
  }
3925
4021
  /** Delete a sticker from a pack. */
3926
4022
  async deleteSticker(packId, stickerId) {
3927
- await this.client.rest.delete(Routes30.packSticker(packId, stickerId));
4023
+ await this.client.rest.delete(Routes31.packSticker(packId, stickerId));
3928
4024
  }
3929
4025
  };
3930
4026
 
@@ -3943,10 +4039,10 @@ function createEventMethods(client) {
3943
4039
 
3944
4040
  // src/client/clientEmoji.ts
3945
4041
  import { Collection as Collection11 } from "@fluxerjs/collection";
3946
- import { Routes as Routes31 } from "@fluxerjs/types";
4042
+ import { Routes as Routes32 } from "@fluxerjs/types";
3947
4043
  import { formatEmoji, getUnicodeFromShortcode, parseEmoji } from "@fluxerjs/util";
3948
4044
  async function assertEmojiInGuild(client, emojiId, guildId) {
3949
- const emojis = await client.rest.get(Routes31.guildEmojis(guildId));
4045
+ const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
3950
4046
  if (!emojis.some((e) => e.id === emojiId)) {
3951
4047
  throw new FluxerError("Custom emoji is from another server. Use an emoji from this server.", {
3952
4048
  code: ErrorCodes.EmojiNotInGuild
@@ -3972,7 +4068,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
3972
4068
  const unicodeFromShortcode = getUnicodeFromShortcode(parsed.name);
3973
4069
  if (unicodeFromShortcode) return unicodeFromShortcode;
3974
4070
  if (guildId) {
3975
- const emojis = await client.rest.get(Routes31.guildEmojis(guildId));
4071
+ const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
3976
4072
  const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
3977
4073
  if (found) return formatEmoji({ ...parsed, id: found.id, animated: found.animated });
3978
4074
  throw new FluxerError(
@@ -3989,28 +4085,28 @@ async function resolveClientEmoji(client, emoji, guildId) {
3989
4085
  return parsed.name;
3990
4086
  }
3991
4087
  async function fetchInstance(client) {
3992
- const raw = await client.rest.get(Routes31.instanceDiscovery(), { auth: false });
4088
+ const raw = await client.rest.get(Routes32.instanceDiscovery(), { auth: false });
3993
4089
  return parseInstanceDiscovery(raw);
3994
4090
  }
3995
4091
  function fetchGatewayInfo(client) {
3996
- return client.rest.get(Routes31.gatewayBot());
4092
+ return client.rest.get(Routes32.gatewayBot());
3997
4093
  }
3998
4094
  function fetchEmojiMetadata(client, emojiId) {
3999
- return client.rest.get(Routes31.emojiMetadata(emojiId), { auth: true });
4095
+ return client.rest.get(Routes32.emojiMetadata(emojiId), { auth: true });
4000
4096
  }
4001
4097
  function fetchStickerMetadata(client, stickerId) {
4002
- return client.rest.get(Routes31.stickerMetadata(stickerId), { auth: true });
4098
+ return client.rest.get(Routes32.stickerMetadata(stickerId), { auth: true });
4003
4099
  }
4004
4100
  function fetchApplication(client) {
4005
- return client.rest.get(Routes31.applicationsMe(), { auth: true });
4101
+ return client.rest.get(Routes32.applicationsMe(), { auth: true });
4006
4102
  }
4007
4103
  async function fetchOAuthApplications(client) {
4008
- const data = await client.rest.get(Routes31.oauth2ApplicationsMe(), { auth: true });
4104
+ const data = await client.rest.get(Routes32.oauth2ApplicationsMe(), { auth: true });
4009
4105
  return Array.isArray(data) ? data : data.applications ?? [];
4010
4106
  }
4011
4107
  function checkUsernameTag(client, username, discriminator) {
4012
4108
  const params = new URLSearchParams({ username, discriminator });
4013
- return client.rest.get(`${Routes31.checkUsernameTag()}?${params}`, { auth: true });
4109
+ return client.rest.get(`${Routes32.checkUsernameTag()}?${params}`, { auth: true });
4014
4110
  }
4015
4111
  function assertChannelIdBatch(name, channelIds) {
4016
4112
  if (channelIds.length < 1 || channelIds.length > 100) {
@@ -4021,14 +4117,14 @@ function assertChannelIdBatch(name, channelIds) {
4021
4117
  }
4022
4118
  function preloadMessages(client, channelIds) {
4023
4119
  assertChannelIdBatch("preloadMessages", channelIds);
4024
- return client.rest.post(Routes31.preloadMessages(), {
4120
+ return client.rest.post(Routes32.preloadMessages(), {
4025
4121
  body: { channels: channelIds },
4026
4122
  auth: true
4027
4123
  });
4028
4124
  }
4029
4125
  function preloadMessagesAlt(client, channelIds) {
4030
4126
  assertChannelIdBatch("preloadMessagesAlt", channelIds);
4031
- return client.rest.post(Routes31.preloadMessagesAlt(), {
4127
+ return client.rest.post(Routes32.preloadMessagesAlt(), {
4032
4128
  body: { channels: channelIds },
4033
4129
  auth: true
4034
4130
  });
@@ -4036,7 +4132,7 @@ function preloadMessagesAlt(client, channelIds) {
4036
4132
  async function bulkFetchMessages(client, requests, options = {}) {
4037
4133
  validateBulkMessageFetchRequests(requests);
4038
4134
  const wire = toBulkFetchWire(requests);
4039
- const data = await client.rest.post(Routes31.channelsMessagesBulk(), {
4135
+ const data = await client.rest.post(Routes32.channelsMessagesBulk(), {
4040
4136
  body: { requests: wire },
4041
4137
  auth: true
4042
4138
  });
@@ -4123,62 +4219,6 @@ function buildRegistry(...maps) {
4123
4219
  return registry;
4124
4220
  }
4125
4221
 
4126
- // src/structures/MessageReaction.ts
4127
- import { Routes as Routes32 } from "@fluxerjs/types";
4128
- import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
4129
- var MessageReaction = class extends Base {
4130
- client;
4131
- messageId;
4132
- channelId;
4133
- guildId;
4134
- emoji;
4135
- /** Raw gateway payload for low-level access. */
4136
- _data;
4137
- constructor(client, data) {
4138
- super();
4139
- this.client = client;
4140
- this._data = data;
4141
- this.messageId = data.message_id;
4142
- this.channelId = data.channel_id;
4143
- this.guildId = data.guild_id ?? null;
4144
- this.emoji = {
4145
- name: data.emoji.name,
4146
- ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
4147
- ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
4148
- };
4149
- }
4150
- /** Emoji as a string: unicode or "name:id" for custom. */
4151
- get emojiIdentifier() {
4152
- return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
4153
- }
4154
- /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
4155
- get guild() {
4156
- return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
4157
- }
4158
- /**
4159
- * Fetch the message this reaction belongs to.
4160
- * Use when you need to edit, delete, or otherwise interact with the message.
4161
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
4162
- */
4163
- async fetchMessage() {
4164
- try {
4165
- const data = await this.client.rest.get(
4166
- Routes32.channelMessage(this.channelId, this.messageId)
4167
- );
4168
- return new Message(this.client, data);
4169
- } catch (err) {
4170
- if (err instanceof RateLimitError4) throw err;
4171
- if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
4172
- throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
4173
- code: ErrorCodes.MessageNotFound,
4174
- cause: err
4175
- });
4176
- }
4177
- throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
4178
- }
4179
- }
4180
- };
4181
-
4182
4222
  // src/client/eventHandlers/helpers.ts
4183
4223
  function unknownUser(id) {
4184
4224
  return { id, username: "Unknown", discriminator: "0" };
@@ -4349,13 +4389,50 @@ function normalizeGuildPayload(raw) {
4349
4389
  }
4350
4390
 
4351
4391
  // src/client/eventHandlers/guilds.ts
4392
+ function markGuildUnavailable(client, id) {
4393
+ const guild = client.guilds.get(id);
4394
+ if (!guild || guild.available === false) return;
4395
+ guild.available = false;
4396
+ client.emit(Events.GuildUnavailable, guild);
4397
+ }
4398
+ function refreshRecoveredGuild(guild, data) {
4399
+ guild._patch(data);
4400
+ if (data.roles !== void 0) {
4401
+ guild.roles.clear();
4402
+ for (const role of data.roles) {
4403
+ guild.roles.set(role.id, new Role(guild.client, role, guild.id));
4404
+ }
4405
+ }
4406
+ if (data.channels !== void 0) {
4407
+ const recoveredChannelIds = new Set(data.channels.map((channel) => channel.id));
4408
+ for (const channel of guild.channels.values()) {
4409
+ guild.client.channels.delete(channel.id);
4410
+ if (!recoveredChannelIds.has(channel.id)) guild.client._clearMessageCache(channel.id);
4411
+ }
4412
+ guild.channels.clear();
4413
+ }
4414
+ }
4352
4415
  var guildHandlers = {
4353
4416
  GUILD_CREATE(client, d) {
4417
+ const raw = d;
4418
+ if (raw.unavailable === true) {
4419
+ if (typeof raw.id === "string") {
4420
+ try {
4421
+ markGuildUnavailable(client, raw.id);
4422
+ } finally {
4423
+ client._onGuildReceived(raw.id);
4424
+ }
4425
+ }
4426
+ return;
4427
+ }
4354
4428
  const guildData = normalizeGuildPayload(d);
4355
4429
  if (!guildData) return;
4356
- const guild = new Guild(client, guildData);
4357
- client.guilds.set(guild.id, guild);
4358
4430
  const g = d;
4431
+ const existing = client.guilds.get(guildData.id);
4432
+ const recovered = existing?.available === false;
4433
+ const guild = recovered && existing ? existing : new Guild(client, guildData);
4434
+ if (recovered) refreshRecoveredGuild(guild, g);
4435
+ client.guilds.set(guild.id, guild);
4359
4436
  for (const ch of g.channels ?? []) {
4360
4437
  const channel = Channel.from(client, ch);
4361
4438
  if (channel) {
@@ -4364,7 +4441,8 @@ var guildHandlers = {
4364
4441
  }
4365
4442
  }
4366
4443
  for (const m of g.members ?? []) cacheMember2(client, guild, m);
4367
- client.emit(Events.GuildCreate, guild);
4444
+ if (recovered) guild.available = true;
4445
+ client.emit(recovered ? Events.GuildAvailable : Events.GuildCreate, guild);
4368
4446
  if (g.voice_states?.length) {
4369
4447
  client.emit(Events.VoiceStatesSync, { guildId: guild.id, voiceStates: g.voice_states });
4370
4448
  }
@@ -4385,11 +4463,19 @@ var guildHandlers = {
4385
4463
  client.emit(Events.GuildUpdate, updated, updated);
4386
4464
  },
4387
4465
  GUILD_DELETE(client, d) {
4388
- const { id } = d;
4389
- const guild = client.guilds.get(id);
4390
- if (!guild) return;
4391
- client.guilds.delete(id);
4392
- client.emit(Events.GuildDelete, guild);
4466
+ const { id, unavailable } = d;
4467
+ try {
4468
+ if (unavailable === true) {
4469
+ markGuildUnavailable(client, id);
4470
+ return;
4471
+ }
4472
+ const guild = client.guilds.get(id);
4473
+ if (!guild) return;
4474
+ client.guilds.delete(id);
4475
+ client.emit(Events.GuildDelete, guild);
4476
+ } finally {
4477
+ client._onGuildReceived(id);
4478
+ }
4393
4479
  }
4394
4480
  };
4395
4481
 
@@ -4811,7 +4897,12 @@ function emitClientError(client, err) {
4811
4897
  function shouldDeferGatewayDispatchUntilReady(client, payload) {
4812
4898
  if (client.options.waitForGuilds !== true || client.readyAt !== null) return false;
4813
4899
  if (payload.op !== 0 || !payload.t) return false;
4814
- return payload.t !== "GUILD_CREATE";
4900
+ if (payload.t === "GUILD_CREATE") return false;
4901
+ if (payload.t === "GUILD_DELETE") {
4902
+ const data = payload.d;
4903
+ if (typeof data?.id === "string" && client._pendingGuildIds?.has(data.id)) return false;
4904
+ }
4905
+ return true;
4815
4906
  }
4816
4907
  function handleGatewayDispatch(client, payload, deferred) {
4817
4908
  if (payload.op !== 0 || !payload.t) return Promise.resolve();