@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.js CHANGED
@@ -49,6 +49,8 @@ var Events = {
49
49
  MessageReactionRemoveAll: "messageReactionRemoveAll",
50
50
  MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
51
51
  GuildCreate: "guildCreate",
52
+ GuildAvailable: "guildAvailable",
53
+ GuildUnavailable: "guildUnavailable",
52
54
  GuildUpdate: "guildUpdate",
53
55
  GuildDelete: "guildDelete",
54
56
  GuildBanAdd: "guildBanAdd",
@@ -95,8 +97,8 @@ var import_types46 = require("@fluxerjs/types");
95
97
 
96
98
  // src/client/ChannelManager.ts
97
99
  var import_collection5 = require("@fluxerjs/collection");
98
- var import_types16 = require("@fluxerjs/types");
99
- var import_rest3 = require("@fluxerjs/rest");
100
+ var import_types17 = require("@fluxerjs/types");
101
+ var import_rest4 = require("@fluxerjs/rest");
100
102
 
101
103
  // src/util/messageUtils/files.ts
102
104
  var FILE_FETCH_TIMEOUT_MS = 3e4;
@@ -278,17 +280,17 @@ async function prepareMessagePostPayload(options, defaults) {
278
280
  }
279
281
 
280
282
  // src/structures/channel/base.ts
281
- var import_types9 = require("@fluxerjs/types");
283
+ var import_types10 = require("@fluxerjs/types");
282
284
 
283
285
  // src/client/MessageManager.ts
284
- var import_types7 = require("@fluxerjs/types");
286
+ var import_types8 = require("@fluxerjs/types");
285
287
  var import_collection3 = require("@fluxerjs/collection");
286
- var import_rest = require("@fluxerjs/rest");
288
+ var import_rest2 = require("@fluxerjs/rest");
287
289
 
288
290
  // src/structures/message/Message.ts
289
291
  var import_collection2 = require("@fluxerjs/collection");
290
292
  var import_builders3 = require("@fluxerjs/builders");
291
- var import_types5 = require("@fluxerjs/types");
293
+ var import_types6 = require("@fluxerjs/types");
292
294
 
293
295
  // src/client/sdkOptions.ts
294
296
  function toMemberSearchBody(options) {
@@ -528,6 +530,70 @@ function toProfilePayload(data) {
528
530
  // src/util/ReactionCollector.ts
529
531
  var import_events = require("events");
530
532
  var import_collection = require("@fluxerjs/collection");
533
+
534
+ // src/structures/MessageReaction.ts
535
+ var import_types3 = require("@fluxerjs/types");
536
+ var import_rest = require("@fluxerjs/rest");
537
+
538
+ // src/structures/Base.ts
539
+ var Base = class {
540
+ };
541
+
542
+ // src/structures/MessageReaction.ts
543
+ var MessageReaction = class extends Base {
544
+ client;
545
+ messageId;
546
+ channelId;
547
+ guildId;
548
+ emoji;
549
+ /** Raw gateway payload for low-level access. */
550
+ _data;
551
+ constructor(client, data) {
552
+ super();
553
+ this.client = client;
554
+ this._data = data;
555
+ this.messageId = data.message_id;
556
+ this.channelId = data.channel_id;
557
+ this.guildId = data.guild_id ?? null;
558
+ this.emoji = {
559
+ name: data.emoji.name,
560
+ ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
561
+ ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
562
+ };
563
+ }
564
+ /** Emoji as a string: unicode or "name:id" for custom. */
565
+ get emojiIdentifier() {
566
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
567
+ }
568
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
569
+ get guild() {
570
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
571
+ }
572
+ /**
573
+ * Fetch the message this reaction belongs to.
574
+ * Use when you need to edit, delete, or otherwise interact with the message.
575
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
576
+ */
577
+ async fetchMessage() {
578
+ try {
579
+ const data = await this.client.rest.get(
580
+ import_types3.Routes.channelMessage(this.channelId, this.messageId)
581
+ );
582
+ return new Message(this.client, data);
583
+ } catch (err) {
584
+ if (err instanceof import_rest.RateLimitError) throw err;
585
+ if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
586
+ throw new import_util2.FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
587
+ code: import_util.ErrorCodes.MessageNotFound,
588
+ cause: err
589
+ });
590
+ }
591
+ throw err instanceof import_util2.FluxerError ? err : new import_util2.FluxerError(String(err), { cause: err });
592
+ }
593
+ }
594
+ };
595
+
596
+ // src/util/ReactionCollector.ts
531
597
  var ReactionCollector = class extends import_events.EventEmitter {
532
598
  client;
533
599
  messageId;
@@ -536,7 +602,8 @@ var ReactionCollector = class extends import_events.EventEmitter {
536
602
  collected = new import_collection.Collection();
537
603
  _timeout = null;
538
604
  _ended = false;
539
- _listener;
605
+ _onAdd;
606
+ _onAddMany;
540
607
  constructor(client, messageId, channelId, options = {}) {
541
608
  super();
542
609
  this.client = client;
@@ -547,27 +614,58 @@ var ReactionCollector = class extends import_events.EventEmitter {
547
614
  time: options.time ?? 0,
548
615
  max: options.max ?? 0
549
616
  };
550
- this._listener = (payload) => {
617
+ this._onAdd = (payload) => {
551
618
  if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
552
619
  return;
553
620
  }
554
- if (!this.options.filter(payload.reaction, payload.user)) return;
555
- const key = `${payload.userId}:${payload.reaction.emoji.id ?? payload.reaction.emoji.name}`;
556
- this.collected.set(key, { reaction: payload.reaction, user: payload.user });
557
- this.emit("collect", payload.reaction, payload.user);
558
- if (this.options.max > 0 && this.collected.size >= this.options.max) {
559
- this.stop("limit");
621
+ this._collect(payload.reaction, payload.user, payload.userId);
622
+ };
623
+ this._onAddMany = (payload) => {
624
+ if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
625
+ return;
626
+ }
627
+ for (const entry of payload.reactions) {
628
+ if (this._ended) return;
629
+ const reaction = new MessageReaction(this.client, {
630
+ message_id: payload.messageId,
631
+ channel_id: payload.channelId,
632
+ guild_id: payload.guildId ?? void 0,
633
+ user_id: entry.userId,
634
+ emoji: {
635
+ name: entry.emoji.name,
636
+ ...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
637
+ ...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
638
+ }
639
+ });
640
+ const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
641
+ id: entry.userId,
642
+ username: "Unknown",
643
+ discriminator: "0"
644
+ });
645
+ this._collect(reaction, user, entry.userId);
560
646
  }
561
647
  };
562
- this.client.on(Events.MessageReactionAdd, this._listener);
648
+ this.client.on(Events.MessageReactionAdd, this._onAdd);
649
+ this.client.on(Events.MessageReactionAddMany, this._onAddMany);
563
650
  if (this.options.time > 0) {
564
651
  this._timeout = setTimeout(() => this.stop("time"), this.options.time);
565
652
  }
566
653
  }
654
+ _collect(reaction, user, userId) {
655
+ if (this._ended) return;
656
+ if (!this.options.filter(reaction, user)) return;
657
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
658
+ this.collected.set(key, { reaction, user });
659
+ this.emit("collect", reaction, user);
660
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
661
+ this.stop("limit");
662
+ }
663
+ }
567
664
  stop(reason = "user") {
568
665
  if (this._ended) return;
569
666
  this._ended = true;
570
- this.client.off(Events.MessageReactionAdd, this._listener);
667
+ this.client.off(Events.MessageReactionAdd, this._onAdd);
668
+ this.client.off(Events.MessageReactionAddMany, this._onAddMany);
571
669
  if (this._timeout) {
572
670
  clearTimeout(this._timeout);
573
671
  this._timeout = null;
@@ -582,30 +680,26 @@ var ReactionCollector = class extends import_events.EventEmitter {
582
680
  }
583
681
  };
584
682
 
585
- // src/structures/Base.ts
586
- var Base = class {
587
- };
588
-
589
683
  // src/structures/message/reactions.ts
590
- var import_types3 = require("@fluxerjs/types");
684
+ var import_types4 = require("@fluxerjs/types");
591
685
  async function emojiPath(message, emoji) {
592
686
  return message.client.resolveEmoji(emoji, message.guildId);
593
687
  }
594
688
  async function reactToMessage(message, emoji) {
595
689
  const e = await emojiPath(message, emoji);
596
- await message.client.rest.put(import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e));
690
+ await message.client.rest.put(import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e));
597
691
  }
598
692
  async function removeMessageReaction(message, emoji, userId) {
599
693
  const e = await emojiPath(message, emoji);
600
- const route = userId ? import_types3.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e);
694
+ const route = userId ? import_types4.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e);
601
695
  await message.client.rest.delete(route);
602
696
  }
603
697
  async function removeAllMessageReactions(message) {
604
- await message.client.rest.delete(import_types3.Routes.channelMessageReactions(message.channelId, message.id));
698
+ await message.client.rest.delete(import_types4.Routes.channelMessageReactions(message.channelId, message.id));
605
699
  }
606
700
  async function removeMessageReactionEmoji(message, emoji) {
607
701
  const e = await emojiPath(message, emoji);
608
- await message.client.rest.delete(import_types3.Routes.channelMessageReaction(message.channelId, message.id, e));
702
+ await message.client.rest.delete(import_types4.Routes.channelMessageReaction(message.channelId, message.id, e));
609
703
  }
610
704
  async function fetchMessageReactionUsers(message, emoji, options) {
611
705
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -616,7 +710,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
616
710
  if (options?.limit != null) params.set("limit", String(options.limit));
617
711
  if (options?.after) params.set("after", options.after);
618
712
  const qs2 = params.toString();
619
- const route = import_types3.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
713
+ const route = import_types4.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
620
714
  const data = await message.client.rest.get(route);
621
715
  if (Array.isArray(data)) {
622
716
  return {
@@ -635,7 +729,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
635
729
 
636
730
  // src/structures/message/send.ts
637
731
  var import_builders2 = require("@fluxerjs/builders");
638
- var import_types4 = require("@fluxerjs/types");
732
+ var import_types5 = require("@fluxerjs/types");
639
733
  function toReplyTarget(ref) {
640
734
  return {
641
735
  channelId: ref.channel_id,
@@ -669,7 +763,7 @@ function asReplyTarget(value) {
669
763
  }
670
764
  async function sendPrepared(message, payload) {
671
765
  const data = await message.client.rest.post(
672
- import_types4.Routes.channelMessages(message.channelId),
766
+ import_types5.Routes.channelMessages(message.channelId),
673
767
  payload
674
768
  );
675
769
  message.client._addMessageToCache(message.channelId, data);
@@ -788,7 +882,7 @@ var Message = class _Message extends Base {
788
882
  this.pinned = data.pinned;
789
883
  this.attachments = new import_collection2.Collection();
790
884
  for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
791
- this.type = data.type ?? import_types5.MessageType.Default;
885
+ this.type = data.type ?? import_types6.MessageType.Default;
792
886
  this.flags = data.flags ?? 0;
793
887
  this.mentionEveryone = data.mention_everyone ?? false;
794
888
  this.tts = data.tts ?? false;
@@ -846,7 +940,7 @@ var Message = class _Message extends Base {
846
940
  if (options.attachments !== void 0) {
847
941
  body.attachments = toMessageAttachmentEditWire(options.attachments);
848
942
  }
849
- const data = await this.client.rest.patch(import_types5.Routes.channelMessage(this.channelId, this.id), {
943
+ const data = await this.client.rest.patch(import_types6.Routes.channelMessage(this.channelId, this.id), {
850
944
  body
851
945
  });
852
946
  const updated = new _Message(this.client, data);
@@ -863,25 +957,25 @@ var Message = class _Message extends Base {
863
957
  }
864
958
  /** Delete this message. */
865
959
  async delete() {
866
- await this.client.rest.delete(import_types5.Routes.channelMessage(this.channelId, this.id));
960
+ await this.client.rest.delete(import_types6.Routes.channelMessage(this.channelId, this.id));
867
961
  this.client._removeMessageFromCache(this.channelId, this.id);
868
962
  }
869
963
  /** Delete a specific attachment from this message. */
870
964
  async deleteAttachment(attachmentId) {
871
965
  await this.client.rest.delete(
872
- import_types5.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
966
+ import_types6.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
873
967
  { auth: true }
874
968
  );
875
969
  this.attachments.delete(attachmentId);
876
970
  }
877
971
  /** Pin this message in the channel. */
878
972
  async pin() {
879
- await this.client.rest.put(import_types5.Routes.channelPinMessage(this.channelId, this.id));
973
+ await this.client.rest.put(import_types6.Routes.channelPinMessage(this.channelId, this.id));
880
974
  this.pinned = true;
881
975
  }
882
976
  /** Unpin this message from the channel. */
883
977
  async unpin() {
884
- await this.client.rest.delete(import_types5.Routes.channelPinMessage(this.channelId, this.id));
978
+ await this.client.rest.delete(import_types6.Routes.channelPinMessage(this.channelId, this.id));
885
979
  this.pinned = false;
886
980
  }
887
981
  /** React to this message with an emoji. */
@@ -962,12 +1056,12 @@ var MessageManager = class {
962
1056
  async fetchOne(messageId) {
963
1057
  try {
964
1058
  const data = await this.client.rest.get(
965
- import_types7.Routes.channelMessage(this.channelId, messageId)
1059
+ import_types8.Routes.channelMessage(this.channelId, messageId)
966
1060
  );
967
1061
  return this.wrap(data);
968
1062
  } catch (err) {
969
- if (err instanceof import_rest.RateLimitError) throw err;
970
- if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
1063
+ if (err instanceof import_rest2.RateLimitError) throw err;
1064
+ if (err instanceof import_rest2.FluxerAPIError && err.statusCode === 404) {
971
1065
  throw new import_util2.FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
972
1066
  code: import_util.ErrorCodes.MessageNotFound,
973
1067
  cause: err
@@ -988,7 +1082,7 @@ var MessageManager = class {
988
1082
  const value = options[key];
989
1083
  if (value != null && value !== "") qs2.set(key, String(value));
990
1084
  }
991
- const base = import_types7.Routes.channelMessages(this.channelId);
1085
+ const base = import_types8.Routes.channelMessages(this.channelId);
992
1086
  const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
993
1087
  const collection = new import_collection3.Collection();
994
1088
  for (const msg of data) collection.set(msg.id, this.wrap(msg));
@@ -997,7 +1091,7 @@ var MessageManager = class {
997
1091
  };
998
1092
 
999
1093
  // src/structures/channel/attachments.ts
1000
- var import_types8 = require("@fluxerjs/types");
1094
+ var import_types9 = require("@fluxerjs/types");
1001
1095
  function asBytes(data) {
1002
1096
  const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
1003
1097
  const out = new Uint8Array(src.byteLength);
@@ -1018,7 +1112,7 @@ async function putBlob(url, body, contentType) {
1018
1112
  }
1019
1113
  async function uploadAttachmentsForSend(client, channelId, files) {
1020
1114
  const plan = await client.rest.post(
1021
- import_types8.Routes.channelAttachments(channelId),
1115
+ import_types9.Routes.channelAttachments(channelId),
1022
1116
  {
1023
1117
  body: {
1024
1118
  attachments: files.map((f) => ({
@@ -1064,7 +1158,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
1064
1158
  });
1065
1159
  }
1066
1160
  if (multipart.length) {
1067
- await client.rest.post(import_types8.Routes.channelAttachmentsComplete(channelId), {
1161
+ await client.rest.post(import_types9.Routes.channelAttachmentsComplete(channelId), {
1068
1162
  body: { uploads: multipart },
1069
1163
  auth: true
1070
1164
  });
@@ -1123,11 +1217,11 @@ var Channel = class extends Base {
1123
1217
  }
1124
1218
  /** Check if this is a DM, group DM, or personal notes channel. */
1125
1219
  isDM() {
1126
- return this.type === import_types9.ChannelType.DM || this.type === import_types9.ChannelType.GroupDM || this.type === import_types9.ChannelType.DMPersonalNotes;
1220
+ return this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes;
1127
1221
  }
1128
1222
  /** Check if this is a personal notes channel. */
1129
1223
  isPersonalNotes() {
1130
- return this.type === import_types9.ChannelType.DMPersonalNotes;
1224
+ return this.type === import_types10.ChannelType.DMPersonalNotes;
1131
1225
  }
1132
1226
  /** Check if this is a voice channel. */
1133
1227
  isVoice() {
@@ -1158,7 +1252,7 @@ var Channel = class extends Base {
1158
1252
  }
1159
1253
  if (ids.length === 0) return [];
1160
1254
  if (ids.length === 1) {
1161
- await this.client.rest.delete(import_types9.Routes.channelMessage(this.id, ids[0]), { auth: true });
1255
+ await this.client.rest.delete(import_types10.Routes.channelMessage(this.id, ids[0]), { auth: true });
1162
1256
  this.client._removeMessageFromCache(this.id, ids[0]);
1163
1257
  return ids;
1164
1258
  }
@@ -1167,7 +1261,7 @@ var Channel = class extends Base {
1167
1261
  code: import_util.ErrorCodes.InvalidBulkDelete
1168
1262
  });
1169
1263
  }
1170
- await this.client.rest.post(import_types9.Routes.channelBulkDelete(this.id), {
1264
+ await this.client.rest.post(import_types10.Routes.channelBulkDelete(this.id), {
1171
1265
  body: { message_ids: ids },
1172
1266
  auth: true
1173
1267
  });
@@ -1177,23 +1271,23 @@ var Channel = class extends Base {
1177
1271
  /** Delete all messages sent by the bot in this channel (user account feature). */
1178
1272
  async bulkDeleteMyMessages(options) {
1179
1273
  const body = options ? toSudoBody(options) : void 0;
1180
- await this.client.rest.post(import_types9.Routes.channelBulkDeleteMine(this.id), {
1274
+ await this.client.rest.post(import_types10.Routes.channelBulkDeleteMine(this.id), {
1181
1275
  body: body && Object.keys(body).length ? body : void 0,
1182
1276
  auth: true
1183
1277
  });
1184
1278
  }
1185
1279
  /** Mark all pinned messages as read in this channel. */
1186
1280
  async acknowledgePins() {
1187
- await this.client.rest.post(import_types9.Routes.channelPinsAck(this.id), { auth: true });
1281
+ await this.client.rest.post(import_types10.Routes.channelPinsAck(this.id), { auth: true });
1188
1282
  }
1189
1283
  /** Clear the read state for this channel. */
1190
1284
  async clearReadState() {
1191
- await this.client.rest.delete(import_types9.Routes.channelMessagesAck(this.id), { auth: true });
1285
+ await this.client.rest.delete(import_types10.Routes.channelMessagesAck(this.id), { auth: true });
1192
1286
  }
1193
1287
  /** Request upload URLs for attachments before sending a message. */
1194
1288
  async requestAttachmentUploads(attachments) {
1195
1289
  const data = await this.client.rest.post(
1196
- import_types9.Routes.channelAttachments(this.id),
1290
+ import_types10.Routes.channelAttachments(this.id),
1197
1291
  {
1198
1292
  body: toAttachmentUploadPlanBody(attachments),
1199
1293
  auth: true
@@ -1204,7 +1298,7 @@ var Channel = class extends Base {
1204
1298
  /** Complete the attachment upload flow after uploading to the CDN. */
1205
1299
  async completeAttachmentUploads(uploads) {
1206
1300
  const data = await this.client.rest.post(
1207
- import_types9.Routes.channelAttachmentsComplete(this.id),
1301
+ import_types10.Routes.channelAttachmentsComplete(this.id),
1208
1302
  {
1209
1303
  body: toAttachmentUploadCompleteBody(uploads),
1210
1304
  auth: true
@@ -1220,11 +1314,11 @@ var Channel = class extends Base {
1220
1314
  }
1221
1315
  /** Trigger the typing indicator in this channel. */
1222
1316
  async sendTyping() {
1223
- await this.client.rest.post(import_types9.Routes.channelTyping(this.id), { auth: true });
1317
+ await this.client.rest.post(import_types10.Routes.channelTyping(this.id), { auth: true });
1224
1318
  }
1225
1319
  /** Fetch available RTC regions for voice channels. */
1226
1320
  async fetchRtcRegions() {
1227
- const data = await this.client.rest.get(import_types9.Routes.channelRtcRegions(this.id), {
1321
+ const data = await this.client.rest.get(import_types10.Routes.channelRtcRegions(this.id), {
1228
1322
  auth: true
1229
1323
  });
1230
1324
  return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
@@ -1232,7 +1326,7 @@ var Channel = class extends Base {
1232
1326
  /** Fetch slowmode state for this channel. */
1233
1327
  async fetchSlowmode() {
1234
1328
  const data = await this.client.rest.get(
1235
- import_types9.Routes.channelSlowmode(this.id),
1329
+ import_types10.Routes.channelSlowmode(this.id),
1236
1330
  { auth: true }
1237
1331
  );
1238
1332
  return {
@@ -1248,14 +1342,14 @@ var Channel = class extends Base {
1248
1342
  };
1249
1343
 
1250
1344
  // src/structures/channel/guild.ts
1251
- var import_types13 = require("@fluxerjs/types");
1345
+ var import_types14 = require("@fluxerjs/types");
1252
1346
  var import_util3 = require("@fluxerjs/util");
1253
1347
 
1254
1348
  // src/structures/Invite.ts
1255
- var import_types10 = require("@fluxerjs/types");
1349
+ var import_types11 = require("@fluxerjs/types");
1256
1350
 
1257
1351
  // src/util/Constants.ts
1258
- var import_rest2 = require("@fluxerjs/rest");
1352
+ var import_rest3 = require("@fluxerjs/rest");
1259
1353
  var CDN_URL = "https://fluxerusercontent.com";
1260
1354
  var STATIC_CDN_URL = "https://fluxerstatic.com";
1261
1355
 
@@ -1439,12 +1533,12 @@ var Invite = class _Invite extends Base {
1439
1533
  this.client = client;
1440
1534
  this.code = data.code;
1441
1535
  this.type = data.type;
1442
- this.guild = (0, import_types10.isGuildInvite)(data) ? data.guild : null;
1443
- this.channel = (0, import_types10.isGuildInvite)(data) || (0, import_types10.isGroupDmInvite)(data) ? data.channel : null;
1444
- this.pack = (0, import_types10.isPackInvite)(data) ? data.pack : null;
1536
+ this.guild = (0, import_types11.isGuildInvite)(data) ? data.guild : null;
1537
+ this.channel = (0, import_types11.isGuildInvite)(data) || (0, import_types11.isGroupDmInvite)(data) ? data.channel : null;
1538
+ this.pack = (0, import_types11.isPackInvite)(data) ? data.pack : null;
1445
1539
  this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
1446
- this.memberCount = (0, import_types10.isPackInvite)(data) ? null : data.member_count ?? null;
1447
- this.presenceCount = (0, import_types10.isGuildInvite)(data) ? data.presence_count ?? null : null;
1540
+ this.memberCount = (0, import_types11.isPackInvite)(data) ? null : data.member_count ?? null;
1541
+ this.presenceCount = (0, import_types11.isGuildInvite)(data) ? data.presence_count ?? null : null;
1448
1542
  this.expiresAt = data.expires_at ?? null;
1449
1543
  this.temporary = data.temporary ?? null;
1450
1544
  this.createdAt = data.created_at ?? null;
@@ -1453,13 +1547,13 @@ var Invite = class _Invite extends Base {
1453
1547
  this.maxAge = data.max_age ?? null;
1454
1548
  }
1455
1549
  isGuild() {
1456
- return this.type === import_types10.InviteType.Guild;
1550
+ return this.type === import_types11.InviteType.Guild;
1457
1551
  }
1458
1552
  isGroupDM() {
1459
- return this.type === import_types10.InviteType.GroupDM;
1553
+ return this.type === import_types11.InviteType.GroupDM;
1460
1554
  }
1461
1555
  isPack() {
1462
- return this.type === import_types10.InviteType.EmojiPack || this.type === import_types10.InviteType.StickerPack;
1556
+ return this.type === import_types11.InviteType.EmojiPack || this.type === import_types11.InviteType.StickerPack;
1463
1557
  }
1464
1558
  /** Full invite URL (uses this client's instance invite base). */
1465
1559
  get url() {
@@ -1471,18 +1565,18 @@ var Invite = class _Invite extends Base {
1471
1565
  }
1472
1566
  /** Fetch invite metadata by code or URL (does not join). */
1473
1567
  static async fetch(client, codeOrUrl) {
1474
- const data = await client.rest.get(import_types10.Routes.invite(parseInviteCode(codeOrUrl)));
1568
+ const data = await client.rest.get(import_types11.Routes.invite(parseInviteCode(codeOrUrl)));
1475
1569
  return new _Invite(client, data);
1476
1570
  }
1477
1571
  /** Delete this invite. Requires Manage Guild or Create Instant Invite. */
1478
1572
  async delete() {
1479
- await this.client.rest.delete(import_types10.Routes.invite(this.code), { auth: true });
1573
+ await this.client.rest.delete(import_types11.Routes.invite(this.code), { auth: true });
1480
1574
  }
1481
1575
  };
1482
1576
 
1483
1577
  // src/structures/Webhook.ts
1484
1578
  var import_builders4 = require("@fluxerjs/builders");
1485
- var import_types11 = require("@fluxerjs/types");
1579
+ var import_types12 = require("@fluxerjs/types");
1486
1580
 
1487
1581
  // src/util/cdn.ts
1488
1582
  function mediaBase(options) {
@@ -1574,10 +1668,10 @@ var Webhook = class _Webhook extends Base {
1574
1668
  /** Delete this webhook (token auth when available, otherwise bot auth). */
1575
1669
  async delete() {
1576
1670
  if (this.token) {
1577
- await this.client.rest.delete(import_types11.Routes.webhookExecute(this.id, this.token), { auth: false });
1671
+ await this.client.rest.delete(import_types12.Routes.webhookExecute(this.id, this.token), { auth: false });
1578
1672
  return;
1579
1673
  }
1580
- await this.client.rest.delete(import_types11.Routes.webhook(this.id), { auth: true });
1674
+ await this.client.rest.delete(import_types12.Routes.webhook(this.id), { auth: true });
1581
1675
  }
1582
1676
  /**
1583
1677
  * Edit name/avatar. With bot auth (no token), `channelId` may also be set.
@@ -1589,10 +1683,10 @@ var Webhook = class _Webhook extends Base {
1589
1683
  if (!this.token && options.channelId !== void 0) {
1590
1684
  body.channel_id = options.channelId;
1591
1685
  }
1592
- const data = this.token ? await this.client.rest.patch(import_types11.Routes.webhookExecute(this.id, this.token), {
1686
+ const data = this.token ? await this.client.rest.patch(import_types12.Routes.webhookExecute(this.id, this.token), {
1593
1687
  body,
1594
1688
  auth: false
1595
- }) : await this.client.rest.patch(import_types11.Routes.webhook(this.id), { body, auth: true });
1689
+ }) : await this.client.rest.patch(import_types12.Routes.webhook(this.id), { body, auth: true });
1596
1690
  this.name = data.name ?? this.name;
1597
1691
  this.avatar = data.avatar ?? null;
1598
1692
  if (!this.token) this.channelId = data.channel_id ?? this.channelId;
@@ -1613,7 +1707,7 @@ var Webhook = class _Webhook extends Base {
1613
1707
  if (overrides.avatarUrl !== void 0) {
1614
1708
  body.avatar_url = overrides.avatarUrl;
1615
1709
  }
1616
- const route = `${import_types11.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1710
+ const route = `${import_types12.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1617
1711
  const data = await this.client.rest.post(route, {
1618
1712
  body,
1619
1713
  ...files?.length ? { files } : {},
@@ -1654,7 +1748,7 @@ var Webhook = class _Webhook extends Base {
1654
1748
  }
1655
1749
  /** Fetch a webhook by ID (bot auth; no token). */
1656
1750
  static async fetch(client, webhookId) {
1657
- const data = await client.rest.get(import_types11.Routes.webhook(webhookId));
1751
+ const data = await client.rest.get(import_types12.Routes.webhook(webhookId));
1658
1752
  return new _Webhook(client, data);
1659
1753
  }
1660
1754
  /** Build a webhook from a stored id + token (e.g. webhook URL). */
@@ -1679,12 +1773,12 @@ var Webhook = class _Webhook extends Base {
1679
1773
  return this.token;
1680
1774
  }
1681
1775
  messageRoute(messageId) {
1682
- return import_types11.Routes.webhookMessage(this.id, this.requireToken(), messageId);
1776
+ return import_types12.Routes.webhookMessage(this.id, this.requireToken(), messageId);
1683
1777
  }
1684
1778
  };
1685
1779
 
1686
1780
  // src/structures/channel/textCapable.ts
1687
- var import_types12 = require("@fluxerjs/types");
1781
+ var import_types13 = require("@fluxerjs/types");
1688
1782
 
1689
1783
  // src/util/MessageCollector.ts
1690
1784
  var import_events2 = require("events");
@@ -1745,7 +1839,7 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
1745
1839
  if (options?.before) params.set("before", options.before);
1746
1840
  const qs2 = params.toString();
1747
1841
  const data = await client.rest.get(
1748
- import_types12.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1842
+ import_types13.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1749
1843
  );
1750
1844
  const items = data.items ?? [];
1751
1845
  return {
@@ -1761,7 +1855,7 @@ function TextCapable(Base2) {
1761
1855
  const payload = await prepareMessagePostPayload(options, {
1762
1856
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
1763
1857
  });
1764
- const data = await this.client.rest.post(import_types12.Routes.channelMessages(this.id), payload);
1858
+ const data = await this.client.rest.post(import_types13.Routes.channelMessages(this.id), payload);
1765
1859
  this.client._addMessageToCache(this.id, data);
1766
1860
  return new Message(this.client, data);
1767
1861
  }
@@ -1818,7 +1912,7 @@ var GuildChannel = class extends Channel {
1818
1912
  }
1819
1913
  /** Create a webhook for this channel. Requires Manage Webhooks. */
1820
1914
  async createWebhook(options) {
1821
- const data = await this.client.rest.post(import_types13.Routes.channelWebhooks(this.id), {
1915
+ const data = await this.client.rest.post(import_types14.Routes.channelWebhooks(this.id), {
1822
1916
  body: options,
1823
1917
  auth: true
1824
1918
  });
@@ -1826,13 +1920,13 @@ var GuildChannel = class extends Channel {
1826
1920
  }
1827
1921
  /** Fetch all webhooks in this channel. Requires Manage Webhooks. */
1828
1922
  async fetchWebhooks() {
1829
- const data = await this.client.rest.get(import_types13.Routes.channelWebhooks(this.id));
1923
+ const data = await this.client.rest.get(import_types14.Routes.channelWebhooks(this.id));
1830
1924
  return data.map((w) => new Webhook(this.client, w));
1831
1925
  }
1832
1926
  /** Create an invite for this channel. Requires Create Instant Invite. */
1833
1927
  async createInvite(options) {
1834
1928
  const body = options ? toChannelInviteBody(options) : {};
1835
- const data = await this.client.rest.post(import_types13.Routes.channelInvites(this.id), {
1929
+ const data = await this.client.rest.post(import_types14.Routes.channelInvites(this.id), {
1836
1930
  body: Object.keys(body).length ? body : void 0,
1837
1931
  auth: true
1838
1932
  });
@@ -1840,12 +1934,12 @@ var GuildChannel = class extends Channel {
1840
1934
  }
1841
1935
  /** Fetch all invites for this channel. Requires Manage Channels. */
1842
1936
  async fetchInvites() {
1843
- const data = await this.client.rest.get(import_types13.Routes.channelInvites(this.id));
1937
+ const data = await this.client.rest.get(import_types14.Routes.channelInvites(this.id));
1844
1938
  return data.map((i) => new Invite(this.client, i));
1845
1939
  }
1846
1940
  /** Edit or create a permission overwrite. Requires Manage Roles. */
1847
1941
  async editPermission(overwriteId, options) {
1848
- await this.client.rest.put(import_types13.Routes.channelPermission(this.id, overwriteId), {
1942
+ await this.client.rest.put(import_types14.Routes.channelPermission(this.id, overwriteId), {
1849
1943
  body: options,
1850
1944
  auth: true
1851
1945
  });
@@ -1861,7 +1955,7 @@ var GuildChannel = class extends Channel {
1861
1955
  }
1862
1956
  /** Delete a permission overwrite. Requires Manage Roles. */
1863
1957
  async deletePermission(overwriteId) {
1864
- await this.client.rest.delete(import_types13.Routes.channelPermission(this.id, overwriteId), { auth: true });
1958
+ await this.client.rest.delete(import_types14.Routes.channelPermission(this.id, overwriteId), { auth: true });
1865
1959
  const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
1866
1960
  if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
1867
1961
  }
@@ -1874,7 +1968,7 @@ var GuildChannel = class extends Channel {
1874
1968
  }
1875
1969
  /** Edit this channel's settings. Requires Manage Channels. */
1876
1970
  async edit(options) {
1877
- const data = await this.client.rest.patch(import_types13.Routes.channel(this.id), {
1971
+ const data = await this.client.rest.patch(import_types14.Routes.channel(this.id), {
1878
1972
  body: toChannelEditBody(options),
1879
1973
  auth: true
1880
1974
  });
@@ -1894,7 +1988,7 @@ var GuildChannel = class extends Channel {
1894
1988
  const qs2 = params.toString();
1895
1989
  const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
1896
1990
  const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
1897
- await this.client.rest.delete(import_types13.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1991
+ await this.client.rest.delete(import_types14.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1898
1992
  body,
1899
1993
  auth: true
1900
1994
  });
@@ -1956,7 +2050,7 @@ var LinkChannel = class extends GuildChannel {
1956
2050
  };
1957
2051
 
1958
2052
  // src/structures/channel/dm.ts
1959
- var import_types14 = require("@fluxerjs/types");
2053
+ var import_types15 = require("@fluxerjs/types");
1960
2054
  var DMChannel = class extends TextCapable(Channel) {
1961
2055
  /** ID of the last message sent in this channel. */
1962
2056
  lastMessageId;
@@ -1976,34 +2070,34 @@ var DMChannel = class extends TextCapable(Channel) {
1976
2070
  }
1977
2071
  /** Purge all messages from personal notes. Only works on personal notes channels. */
1978
2072
  async purgeMessages() {
1979
- if (this.type !== import_types14.ChannelType.DMPersonalNotes) {
2073
+ if (this.type !== import_types15.ChannelType.DMPersonalNotes) {
1980
2074
  throw new import_util2.FluxerError("purgeMessages is only available on personal notes channels", {
1981
2075
  code: import_util.ErrorCodes.InvalidChannelType
1982
2076
  });
1983
2077
  }
1984
2078
  const data = await this.client.rest.post(
1985
- import_types14.Routes.channelMessagesPurge(this.id),
2079
+ import_types15.Routes.channelMessagesPurge(this.id),
1986
2080
  { auth: true }
1987
2081
  );
1988
2082
  return data.deleted_count;
1989
2083
  }
1990
2084
  /** Pin this DM channel to the top of the DM list. */
1991
2085
  async pinInList() {
1992
- await this.client.rest.put(import_types14.Routes.userMeChannelPin(this.id), { auth: true });
2086
+ await this.client.rest.put(import_types15.Routes.userMeChannelPin(this.id), { auth: true });
1993
2087
  }
1994
2088
  /** Unpin this DM channel from the DM list. */
1995
2089
  async unpinFromList() {
1996
- await this.client.rest.delete(import_types14.Routes.userMeChannelPin(this.id), { auth: true });
2090
+ await this.client.rest.delete(import_types15.Routes.userMeChannelPin(this.id), { auth: true });
1997
2091
  }
1998
2092
  /** Add a user to this group DM. */
1999
2093
  async addRecipient(userId) {
2000
- await this.client.rest.put(import_types14.Routes.channelRecipient(this.id, userId), { auth: true });
2094
+ await this.client.rest.put(import_types15.Routes.channelRecipient(this.id, userId), { auth: true });
2001
2095
  const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
2002
2096
  if (user) this.recipients.push(user);
2003
2097
  }
2004
2098
  /** Remove a user from this group DM. */
2005
2099
  async removeRecipient(userId, options) {
2006
- const url = import_types14.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2100
+ const url = import_types15.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2007
2101
  await this.client.rest.delete(url, { auth: true });
2008
2102
  const idx = this.recipients.findIndex((u) => u.id === userId);
2009
2103
  if (idx >= 0) this.recipients.splice(idx, 1);
@@ -2011,17 +2105,17 @@ var DMChannel = class extends TextCapable(Channel) {
2011
2105
  };
2012
2106
 
2013
2107
  // src/structures/channel/factory.ts
2014
- var import_types15 = require("@fluxerjs/types");
2108
+ var import_types16 = require("@fluxerjs/types");
2015
2109
  var GUILD_FACTORIES = {
2016
- [import_types15.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
2017
- [import_types15.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
2018
- [import_types15.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
2019
- [import_types15.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d)
2110
+ [import_types16.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
2111
+ [import_types16.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
2112
+ [import_types16.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
2113
+ [import_types16.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d)
2020
2114
  };
2021
2115
  var DM_TYPES = /* @__PURE__ */ new Set([
2022
- import_types15.ChannelType.DM,
2023
- import_types15.ChannelType.GroupDM,
2024
- import_types15.ChannelType.DMPersonalNotes
2116
+ import_types16.ChannelType.DM,
2117
+ import_types16.ChannelType.GroupDM,
2118
+ import_types16.ChannelType.DMPersonalNotes
2025
2119
  ]);
2026
2120
  function createDM(client, data) {
2027
2121
  return new DMChannel(client, data);
@@ -2041,8 +2135,8 @@ Channel.createDM = createDM;
2041
2135
 
2042
2136
  // src/client/ChannelManager.ts
2043
2137
  function rethrowNotFound(err, message, code) {
2044
- if (err instanceof import_rest3.RateLimitError) throw err;
2045
- if (err instanceof import_rest3.FluxerAPIError && err.statusCode === 404) {
2138
+ if (err instanceof import_rest4.RateLimitError) throw err;
2139
+ if (err instanceof import_rest4.FluxerAPIError && err.statusCode === 404) {
2046
2140
  throw new import_util2.FluxerError(message, { code, cause: err });
2047
2141
  }
2048
2142
  throw err instanceof import_util2.FluxerError ? err : new import_util2.FluxerError(String(err), { cause: err });
@@ -2074,7 +2168,7 @@ var ChannelManager = class extends import_collection5.Collection {
2074
2168
  const cached = this.get(channelId);
2075
2169
  if (cached) return cached;
2076
2170
  try {
2077
- const data = await this.client.rest.get(import_types16.Routes.channel(channelId));
2171
+ const data = await this.client.rest.get(import_types17.Routes.channel(channelId));
2078
2172
  const channel = Channel.fromOrCreate(this.client, data);
2079
2173
  if (!channel) {
2080
2174
  throw new import_util2.FluxerError("Channel data invalid or unsupported type", {
@@ -2107,7 +2201,7 @@ var ChannelManager = class extends import_collection5.Collection {
2107
2201
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
2108
2202
  });
2109
2203
  const data = await this.client.rest.post(
2110
- import_types16.Routes.channelMessages(channelId),
2204
+ import_types17.Routes.channelMessages(channelId),
2111
2205
  postPayload
2112
2206
  );
2113
2207
  this.client._addMessageToCache(channelId, data);
@@ -2117,29 +2211,29 @@ var ChannelManager = class extends import_collection5.Collection {
2117
2211
 
2118
2212
  // src/client/GuildManager.ts
2119
2213
  var import_collection9 = require("@fluxerjs/collection");
2120
- var import_types36 = require("@fluxerjs/types");
2121
- var import_rest5 = require("@fluxerjs/rest");
2214
+ var import_types37 = require("@fluxerjs/types");
2215
+ var import_rest6 = require("@fluxerjs/rest");
2122
2216
 
2123
2217
  // src/structures/guild/Guild.ts
2124
2218
  var import_collection8 = require("@fluxerjs/collection");
2125
- var import_types35 = require("@fluxerjs/types");
2219
+ var import_types36 = require("@fluxerjs/types");
2126
2220
 
2127
2221
  // src/client/GuildMemberManager.ts
2128
2222
  var import_collection7 = require("@fluxerjs/collection");
2129
- var import_types20 = require("@fluxerjs/types");
2223
+ var import_types21 = require("@fluxerjs/types");
2130
2224
 
2131
2225
  // src/structures/GuildMember.ts
2132
- var import_types19 = require("@fluxerjs/types");
2226
+ var import_types20 = require("@fluxerjs/types");
2133
2227
  var import_util5 = require("@fluxerjs/util");
2134
2228
 
2135
2229
  // src/util/permissions.ts
2136
- var import_types17 = require("@fluxerjs/types");
2230
+ var import_types18 = require("@fluxerjs/types");
2137
2231
  var import_util4 = require("@fluxerjs/util");
2138
2232
  function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
2139
2233
  if (isOwner) return import_util4.ALL_PERMISSIONS_BIGINT;
2140
2234
  let perms = basePermissions;
2141
2235
  for (const overwrite of overwrites ?? []) {
2142
- const applies = overwrite.type === import_types17.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types17.OverwriteType.Member && overwrite.id === memberId;
2236
+ const applies = overwrite.type === import_types18.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types18.OverwriteType.Member && overwrite.id === memberId;
2143
2237
  if (!applies) continue;
2144
2238
  const allow = BigInt(overwrite.allow || "0");
2145
2239
  const deny = BigInt(overwrite.deny || "0");
@@ -2150,7 +2244,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
2150
2244
 
2151
2245
  // src/structures/GuildMemberRoleManager.ts
2152
2246
  var import_collection6 = require("@fluxerjs/collection");
2153
- var import_types18 = require("@fluxerjs/types");
2247
+ var import_types19 = require("@fluxerjs/types");
2154
2248
  function roleId(roleOrId) {
2155
2249
  return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
2156
2250
  }
@@ -2179,7 +2273,7 @@ var GuildMemberRoleManager = class {
2179
2273
  const id = roleId(roleOrId);
2180
2274
  if (this.ids.includes(id)) return;
2181
2275
  await this.member.client.rest.put(
2182
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2276
+ import_types19.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2183
2277
  );
2184
2278
  this.ids.push(id);
2185
2279
  }
@@ -2188,13 +2282,13 @@ var GuildMemberRoleManager = class {
2188
2282
  const idx = this.ids.indexOf(id);
2189
2283
  if (idx === -1) return;
2190
2284
  await this.member.client.rest.delete(
2191
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2285
+ import_types19.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2192
2286
  );
2193
2287
  this.ids.splice(idx, 1);
2194
2288
  }
2195
2289
  async set(roleIds) {
2196
2290
  const data = await this.member.client.rest.patch(
2197
- import_types18.Routes.guildMember(this.member.guild.id, this.member.id),
2291
+ import_types19.Routes.guildMember(this.member.guild.id, this.member.id),
2198
2292
  { body: { roles: roleIds }, auth: true }
2199
2293
  );
2200
2294
  this.ids = data.roles ? [...data.roles] : [];
@@ -2321,7 +2415,7 @@ var GuildMember = class _GuildMember extends Base {
2321
2415
  /** PATCH member (`/members/@me` when editing the bot). */
2322
2416
  async edit(options) {
2323
2417
  const isMe = this.client.user?.id === this.id;
2324
- const route = isMe ? import_types19.Routes.guildMemberMe(this.guild.id) : import_types19.Routes.guildMember(this.guild.id, this.id);
2418
+ const route = isMe ? import_types20.Routes.guildMemberMe(this.guild.id) : import_types20.Routes.guildMember(this.guild.id, this.id);
2325
2419
  const data = await this.client.rest.patch(route, {
2326
2420
  body: toMemberEditBody(options),
2327
2421
  auth: true
@@ -2450,7 +2544,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2450
2544
  if (options?.limit != null) params.set("limit", String(options.limit));
2451
2545
  if (options?.after) params.set("after", options.after);
2452
2546
  const qs2 = params.toString();
2453
- const url = import_types20.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2547
+ const url = import_types21.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2454
2548
  const data = await this.guild.client.rest.get(url, { auth: true });
2455
2549
  const members = [];
2456
2550
  for (const m of data) {
@@ -2473,7 +2567,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2473
2567
  */
2474
2568
  async search(options = {}) {
2475
2569
  const data = await this.guild.client.rest.post(
2476
- import_types20.Routes.guildMembersSearch(this.guild.id),
2570
+ import_types21.Routes.guildMembersSearch(this.guild.id),
2477
2571
  { body: toMemberSearchBody(options), auth: true }
2478
2572
  );
2479
2573
  const offset = options.offset ?? 0;
@@ -2499,7 +2593,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2499
2593
  };
2500
2594
 
2501
2595
  // src/structures/Role.ts
2502
- var import_types21 = require("@fluxerjs/types");
2596
+ var import_types22 = require("@fluxerjs/types");
2503
2597
  var import_util7 = require("@fluxerjs/util");
2504
2598
 
2505
2599
  // src/structures/roleOptions.ts
@@ -2612,7 +2706,7 @@ var Role = class _Role extends Base {
2612
2706
  */
2613
2707
  async edit(options) {
2614
2708
  const body = toRoleRequestBody(options);
2615
- const data = await this.client.rest.patch(import_types21.Routes.guildRole(this.guildId, this.id), {
2709
+ const data = await this.client.rest.patch(import_types22.Routes.guildRole(this.guildId, this.id), {
2616
2710
  body: Object.keys(body).length ? body : void 0,
2617
2711
  auth: true
2618
2712
  });
@@ -2623,18 +2717,18 @@ var Role = class _Role extends Base {
2623
2717
  * DELETE role. Requires Manage Roles.
2624
2718
  */
2625
2719
  async delete() {
2626
- await this.client.rest.delete(import_types21.Routes.guildRole(this.guildId, this.id), { auth: true });
2720
+ await this.client.rest.delete(import_types22.Routes.guildRole(this.guildId, this.id), { auth: true });
2627
2721
  this.client.guilds.get(this.guildId)?.roles.delete(this.id);
2628
2722
  }
2629
2723
  };
2630
2724
 
2631
2725
  // src/structures/guild/admin.ts
2632
- var import_types22 = require("@fluxerjs/types");
2726
+ var import_types23 = require("@fluxerjs/types");
2633
2727
 
2634
2728
  // src/structures/guild/http.ts
2635
- var import_rest4 = require("@fluxerjs/rest");
2729
+ var import_rest5 = require("@fluxerjs/rest");
2636
2730
  function httpStatus(err) {
2637
- if (err instanceof import_rest4.FluxerAPIError) return err.statusCode;
2731
+ if (err instanceof import_rest5.FluxerAPIError) return err.statusCode;
2638
2732
  if (typeof err === "object" && err !== null && "statusCode" in err) {
2639
2733
  const code = err.statusCode;
2640
2734
  return typeof code === "number" ? code : void 0;
@@ -2734,7 +2828,7 @@ function toVanityPayload(data) {
2734
2828
  return { code: data.code ?? null, uses: data.uses };
2735
2829
  }
2736
2830
  async function fetchAuditLogs(guild, options) {
2737
- const url = import_types22.Routes.guildAuditLogs(guild.id) + qs({
2831
+ const url = import_types23.Routes.guildAuditLogs(guild.id) + qs({
2738
2832
  limit: options?.limit,
2739
2833
  before: options?.before,
2740
2834
  after: options?.after,
@@ -2755,7 +2849,7 @@ async function fetchAuditLogs(guild, options) {
2755
2849
  };
2756
2850
  }
2757
2851
  async function editGuild(guild, options) {
2758
- const data = await guild.client.rest.patch(import_types22.Routes.guild(guild.id), {
2852
+ const data = await guild.client.rest.patch(import_types23.Routes.guild(guild.id), {
2759
2853
  body: toGuildEditBody(options),
2760
2854
  auth: true
2761
2855
  });
@@ -2763,13 +2857,13 @@ async function editGuild(guild, options) {
2763
2857
  return guild;
2764
2858
  }
2765
2859
  async function fetchVanityURL(guild) {
2766
- const data = await guild.client.rest.get(import_types22.Routes.guildVanityUrl(guild.id), {
2860
+ const data = await guild.client.rest.get(import_types23.Routes.guildVanityUrl(guild.id), {
2767
2861
  auth: true
2768
2862
  });
2769
2863
  return toVanityPayload(data);
2770
2864
  }
2771
2865
  async function editVanityURL(guild, code) {
2772
- const data = await guild.client.rest.patch(import_types22.Routes.guildVanityUrl(guild.id), {
2866
+ const data = await guild.client.rest.patch(import_types23.Routes.guildVanityUrl(guild.id), {
2773
2867
  body: { code },
2774
2868
  auth: true
2775
2869
  });
@@ -2777,14 +2871,14 @@ async function editVanityURL(guild, code) {
2777
2871
  return toVanityPayload(data);
2778
2872
  }
2779
2873
  async function fetchDiscoveryStatus(guild) {
2780
- const data = await guild.client.rest.get(import_types22.Routes.guildDiscovery(guild.id), {
2874
+ const data = await guild.client.rest.get(import_types23.Routes.guildDiscovery(guild.id), {
2781
2875
  auth: true
2782
2876
  });
2783
2877
  return toDiscoveryStatusPayload(data);
2784
2878
  }
2785
2879
  async function applyForDiscovery(guild, options) {
2786
2880
  const data = await guild.client.rest.post(
2787
- import_types22.Routes.guildDiscovery(guild.id),
2881
+ import_types23.Routes.guildDiscovery(guild.id),
2788
2882
  {
2789
2883
  body: toDiscoveryBody(options),
2790
2884
  auth: true
@@ -2794,7 +2888,7 @@ async function applyForDiscovery(guild, options) {
2794
2888
  }
2795
2889
  async function editDiscoveryApplication(guild, options) {
2796
2890
  const data = await guild.client.rest.patch(
2797
- import_types22.Routes.guildDiscovery(guild.id),
2891
+ import_types23.Routes.guildDiscovery(guild.id),
2798
2892
  {
2799
2893
  body: toDiscoveryBody(options),
2800
2894
  auth: true
@@ -2803,28 +2897,28 @@ async function editDiscoveryApplication(guild, options) {
2803
2897
  return toDiscoveryApplicationPayload(data);
2804
2898
  }
2805
2899
  async function withdrawDiscoveryApplication(guild) {
2806
- await guild.client.rest.delete(import_types22.Routes.guildDiscovery(guild.id), { auth: true });
2900
+ await guild.client.rest.delete(import_types23.Routes.guildDiscovery(guild.id), { auth: true });
2807
2901
  }
2808
2902
  async function deleteGuild(guild, options) {
2809
2903
  const body = options ? toSudoBody(options) : {};
2810
- await guild.client.rest.post(import_types22.Routes.guildDelete(guild.id), {
2904
+ await guild.client.rest.post(import_types23.Routes.guildDelete(guild.id), {
2811
2905
  body,
2812
2906
  auth: true
2813
2907
  });
2814
2908
  guild.client.guilds.delete(guild.id);
2815
2909
  }
2816
2910
  async function transferOwnership(guild, newOwnerId, password) {
2817
- await guild.client.rest.post(import_types22.Routes.guildTransferOwnership(guild.id), {
2911
+ await guild.client.rest.post(import_types23.Routes.guildTransferOwnership(guild.id), {
2818
2912
  body: { new_owner_id: newOwnerId, ...password != null && { password } },
2819
2913
  auth: true
2820
2914
  });
2821
2915
  }
2822
2916
 
2823
2917
  // src/structures/guild/channels.ts
2824
- var import_types26 = require("@fluxerjs/types");
2918
+ var import_types27 = require("@fluxerjs/types");
2825
2919
 
2826
2920
  // src/structures/GuildEmoji.ts
2827
- var import_types24 = require("@fluxerjs/types");
2921
+ var import_types25 = require("@fluxerjs/types");
2828
2922
  var GuildEmoji = class extends Base {
2829
2923
  client;
2830
2924
  id;
@@ -2852,7 +2946,7 @@ var GuildEmoji = class extends Base {
2852
2946
  }
2853
2947
  /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
2854
2948
  async delete() {
2855
- await this.client.rest.delete(import_types24.Routes.guildEmoji(this.guildId, this.id), {
2949
+ await this.client.rest.delete(import_types25.Routes.guildEmoji(this.guildId, this.id), {
2856
2950
  auth: true
2857
2951
  });
2858
2952
  const guild = this.client.guilds.get(this.guildId);
@@ -2863,7 +2957,7 @@ var GuildEmoji = class extends Base {
2863
2957
  * Requires Manage Emojis and Stickers permission.
2864
2958
  */
2865
2959
  async edit(options) {
2866
- const data = await this.client.rest.patch(import_types24.Routes.guildEmoji(this.guildId, this.id), {
2960
+ const data = await this.client.rest.patch(import_types25.Routes.guildEmoji(this.guildId, this.id), {
2867
2961
  body: options,
2868
2962
  auth: true
2869
2963
  });
@@ -2873,7 +2967,7 @@ var GuildEmoji = class extends Base {
2873
2967
  };
2874
2968
 
2875
2969
  // src/structures/GuildSticker.ts
2876
- var import_types25 = require("@fluxerjs/types");
2970
+ var import_types26 = require("@fluxerjs/types");
2877
2971
  var GuildSticker = class extends Base {
2878
2972
  client;
2879
2973
  id;
@@ -2904,7 +2998,7 @@ var GuildSticker = class extends Base {
2904
2998
  }
2905
2999
  /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
2906
3000
  async delete() {
2907
- await this.client.rest.delete(import_types25.Routes.guildSticker(this.guildId, this.id), {
3001
+ await this.client.rest.delete(import_types26.Routes.guildSticker(this.guildId, this.id), {
2908
3002
  auth: true
2909
3003
  });
2910
3004
  }
@@ -2913,7 +3007,7 @@ var GuildSticker = class extends Base {
2913
3007
  * Requires Manage Emojis and Stickers permission.
2914
3008
  */
2915
3009
  async edit(options) {
2916
- const data = await this.client.rest.patch(import_types25.Routes.guildSticker(this.guildId, this.id), {
3010
+ const data = await this.client.rest.patch(import_types26.Routes.guildSticker(this.guildId, this.id), {
2917
3011
  body: options,
2918
3012
  auth: true
2919
3013
  });
@@ -2968,14 +3062,14 @@ function cacheSticker(guild, data) {
2968
3062
 
2969
3063
  // src/structures/guild/channels.ts
2970
3064
  async function createChannel(guild, data) {
2971
- const created = await guild.client.rest.post(import_types26.Routes.guildChannels(guild.id), {
3065
+ const created = await guild.client.rest.post(import_types27.Routes.guildChannels(guild.id), {
2972
3066
  body: data,
2973
3067
  auth: true
2974
3068
  });
2975
3069
  return cacheChannel(guild, created);
2976
3070
  }
2977
3071
  async function fetchChannels(guild) {
2978
- const data = await guild.client.rest.get(import_types26.Routes.guildChannels(guild.id));
3072
+ const data = await guild.client.rest.get(import_types27.Routes.guildChannels(guild.id));
2979
3073
  const channels = [];
2980
3074
  for (const ch of data) {
2981
3075
  const channel = cacheChannel(guild, ch);
@@ -2984,17 +3078,17 @@ async function fetchChannels(guild) {
2984
3078
  return channels;
2985
3079
  }
2986
3080
  async function setChannelPositions(guild, updates) {
2987
- await guild.client.rest.patch(import_types26.Routes.guildChannels(guild.id), {
3081
+ await guild.client.rest.patch(import_types27.Routes.guildChannels(guild.id), {
2988
3082
  body: toChannelPositionBody(updates),
2989
3083
  auth: true
2990
3084
  });
2991
3085
  }
2992
3086
  async function fetchWebhooks(guild) {
2993
- const data = await guild.client.rest.get(import_types26.Routes.guildWebhooks(guild.id));
3087
+ const data = await guild.client.rest.get(import_types27.Routes.guildWebhooks(guild.id));
2994
3088
  return data.map((w) => new Webhook(guild.client, w));
2995
3089
  }
2996
3090
  async function fetchInvites(guild) {
2997
- const data = await guild.client.rest.get(import_types26.Routes.guildInvites(guild.id));
3091
+ const data = await guild.client.rest.get(import_types27.Routes.guildInvites(guild.id));
2998
3092
  return data.map((invite) => new Invite(guild.client, invite));
2999
3093
  }
3000
3094
  async function fetchInvite(guild, codeOrUrl) {
@@ -3002,14 +3096,14 @@ async function fetchInvite(guild, codeOrUrl) {
3002
3096
  }
3003
3097
 
3004
3098
  // src/structures/guild/emojis.ts
3005
- var import_types28 = require("@fluxerjs/types");
3099
+ var import_types29 = require("@fluxerjs/types");
3006
3100
  async function fetchEmojis(guild) {
3007
- const data = await guild.client.rest.get(import_types28.Routes.guildEmojis(guild.id));
3101
+ const data = await guild.client.rest.get(import_types29.Routes.guildEmojis(guild.id));
3008
3102
  return data.map((e) => cacheEmoji(guild, e));
3009
3103
  }
3010
3104
  async function fetchEmoji(guild, emojiId) {
3011
3105
  try {
3012
- const data = await guild.client.rest.get(import_types28.Routes.guildEmoji(guild.id, emojiId));
3106
+ const data = await guild.client.rest.get(import_types29.Routes.guildEmoji(guild.id, emojiId));
3013
3107
  return cacheEmoji(guild, data);
3014
3108
  } catch (err) {
3015
3109
  rethrowNotFound2(
@@ -3020,14 +3114,14 @@ async function fetchEmoji(guild, emojiId) {
3020
3114
  }
3021
3115
  }
3022
3116
  async function createEmoji(guild, options) {
3023
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojis(guild.id), {
3117
+ const data = await guild.client.rest.post(import_types29.Routes.guildEmojis(guild.id), {
3024
3118
  body: options,
3025
3119
  auth: true
3026
3120
  });
3027
3121
  return cacheEmoji(guild, data);
3028
3122
  }
3029
3123
  async function cloneEmoji(guild, sourceEmojiId) {
3030
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojisClone(guild.id), {
3124
+ const data = await guild.client.rest.post(import_types29.Routes.guildEmojisClone(guild.id), {
3031
3125
  body: { source_emoji_id: sourceEmojiId },
3032
3126
  auth: true
3033
3127
  });
@@ -3035,18 +3129,18 @@ async function cloneEmoji(guild, sourceEmojiId) {
3035
3129
  }
3036
3130
  async function createEmojisBulk(guild, emojis) {
3037
3131
  const data = await guild.client.rest.post(
3038
- import_types28.Routes.guildEmojisBulk(guild.id),
3132
+ import_types29.Routes.guildEmojisBulk(guild.id),
3039
3133
  { body: { emojis }, auth: true }
3040
3134
  );
3041
3135
  return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
3042
3136
  }
3043
3137
 
3044
3138
  // src/structures/guild/members.ts
3045
- var import_types29 = require("@fluxerjs/types");
3139
+ var import_types30 = require("@fluxerjs/types");
3046
3140
  async function fetchMember(guild, userId) {
3047
3141
  try {
3048
3142
  const data = await guild.client.rest.get(
3049
- import_types29.Routes.guildMember(guild.id, userId)
3143
+ import_types30.Routes.guildMember(guild.id, userId)
3050
3144
  );
3051
3145
  return cacheMember(guild, data);
3052
3146
  } catch (err) {
@@ -3059,17 +3153,17 @@ async function fetchMember(guild, userId) {
3059
3153
  }
3060
3154
  async function fetchMe(guild) {
3061
3155
  const data = await guild.client.rest.get(
3062
- import_types29.Routes.guildMemberMe(guild.id),
3156
+ import_types30.Routes.guildMemberMe(guild.id),
3063
3157
  { auth: true }
3064
3158
  );
3065
3159
  return cacheMember(guild, data);
3066
3160
  }
3067
3161
 
3068
3162
  // src/structures/guild/moderation.ts
3069
- var import_types31 = require("@fluxerjs/types");
3163
+ var import_types32 = require("@fluxerjs/types");
3070
3164
 
3071
3165
  // src/structures/GuildBan.ts
3072
- var import_types30 = require("@fluxerjs/types");
3166
+ var import_types31 = require("@fluxerjs/types");
3073
3167
  var GuildBan = class extends Base {
3074
3168
  client;
3075
3169
  guildId;
@@ -3091,7 +3185,7 @@ var GuildBan = class extends Base {
3091
3185
  * Requires Ban Members permission.
3092
3186
  */
3093
3187
  async unban() {
3094
- await this.client.rest.delete(import_types30.Routes.guildBan(this.guildId, this.user.id), {
3188
+ await this.client.rest.delete(import_types31.Routes.guildBan(this.guildId, this.user.id), {
3095
3189
  auth: true
3096
3190
  });
3097
3191
  }
@@ -3100,40 +3194,40 @@ var GuildBan = class extends Base {
3100
3194
  // src/structures/guild/moderation.ts
3101
3195
  async function ban(guild, userId, options) {
3102
3196
  const body = options ? toGuildBanBody(options) : {};
3103
- await guild.client.rest.put(import_types31.Routes.guildBan(guild.id, userId), {
3197
+ await guild.client.rest.put(import_types32.Routes.guildBan(guild.id, userId), {
3104
3198
  body: Object.keys(body).length ? body : void 0,
3105
3199
  auth: true
3106
3200
  });
3107
3201
  }
3108
3202
  async function fetchBans(guild) {
3109
- const data = await guild.client.rest.get(import_types31.Routes.guildBans(guild.id));
3203
+ const data = await guild.client.rest.get(import_types32.Routes.guildBans(guild.id));
3110
3204
  return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
3111
3205
  }
3112
3206
  async function unban(guild, userId) {
3113
- await guild.client.rest.delete(import_types31.Routes.guildBan(guild.id, userId), { auth: true });
3207
+ await guild.client.rest.delete(import_types32.Routes.guildBan(guild.id, userId), { auth: true });
3114
3208
  }
3115
3209
  async function kick(guild, userId) {
3116
- await guild.client.rest.delete(import_types31.Routes.guildMember(guild.id, userId), { auth: true });
3210
+ await guild.client.rest.delete(import_types32.Routes.guildMember(guild.id, userId), { auth: true });
3117
3211
  }
3118
3212
 
3119
3213
  // src/structures/guild/roles.ts
3120
- var import_types33 = require("@fluxerjs/types");
3214
+ var import_types34 = require("@fluxerjs/types");
3121
3215
  var import_util8 = require("@fluxerjs/util");
3122
3216
  async function createRole(guild, options = {}) {
3123
3217
  const body = toRoleRequestBody(options);
3124
- const data = await guild.client.rest.post(import_types33.Routes.guildRoles(guild.id), {
3218
+ const data = await guild.client.rest.post(import_types34.Routes.guildRoles(guild.id), {
3125
3219
  body: Object.keys(body).length ? body : void 0,
3126
3220
  auth: true
3127
3221
  });
3128
3222
  return cacheRole(guild, data);
3129
3223
  }
3130
3224
  async function fetchRoles(guild) {
3131
- const data = await guild.client.rest.get(import_types33.Routes.guildRoles(guild.id));
3225
+ const data = await guild.client.rest.get(import_types34.Routes.guildRoles(guild.id));
3132
3226
  return data.map((r) => cacheRole(guild, r));
3133
3227
  }
3134
3228
  async function fetchRole(guild, roleId2) {
3135
3229
  try {
3136
- const data = await guild.client.rest.get(import_types33.Routes.guildRole(guild.id, roleId2));
3230
+ const data = await guild.client.rest.get(import_types34.Routes.guildRole(guild.id, roleId2));
3137
3231
  return cacheRole(guild, data);
3138
3232
  } catch (err) {
3139
3233
  rethrowNotFound2(
@@ -3151,7 +3245,7 @@ async function resolveRoleId(guild, arg) {
3151
3245
  const needle = trimmed.toLowerCase();
3152
3246
  const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
3153
3247
  if (cached) return cached.id;
3154
- const roles = await guild.client.rest.get(import_types33.Routes.guildRoles(guild.id));
3248
+ const roles = await guild.client.rest.get(import_types34.Routes.guildRoles(guild.id));
3155
3249
  const role = roles.find((r) => r.name?.toLowerCase() === needle);
3156
3250
  if (!role) return null;
3157
3251
  cacheRole(guild, role);
@@ -3160,7 +3254,7 @@ async function resolveRoleId(guild, arg) {
3160
3254
  async function setRolePositions(guild, updates) {
3161
3255
  return replaceRoles(
3162
3256
  guild,
3163
- await guild.client.rest.patch(import_types33.Routes.guildRoles(guild.id), {
3257
+ await guild.client.rest.patch(import_types34.Routes.guildRoles(guild.id), {
3164
3258
  body: updates,
3165
3259
  auth: true
3166
3260
  })
@@ -3169,7 +3263,7 @@ async function setRolePositions(guild, updates) {
3169
3263
  async function setRoleHoistPositions(guild, updates) {
3170
3264
  return replaceRoles(
3171
3265
  guild,
3172
- await guild.client.rest.patch(import_types33.Routes.guildRolesHoistPositions(guild.id), {
3266
+ await guild.client.rest.patch(import_types34.Routes.guildRolesHoistPositions(guild.id), {
3173
3267
  body: updates.map((u) => ({
3174
3268
  id: u.id,
3175
3269
  ...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
@@ -3181,23 +3275,23 @@ async function setRoleHoistPositions(guild, updates) {
3181
3275
  async function resetRoleHoistPositions(guild) {
3182
3276
  return replaceRoles(
3183
3277
  guild,
3184
- await guild.client.rest.delete(import_types33.Routes.guildRolesHoistPositions(guild.id), {
3278
+ await guild.client.rest.delete(import_types34.Routes.guildRolesHoistPositions(guild.id), {
3185
3279
  auth: true
3186
3280
  })
3187
3281
  );
3188
3282
  }
3189
3283
 
3190
3284
  // src/structures/guild/stickers.ts
3191
- var import_types34 = require("@fluxerjs/types");
3285
+ var import_types35 = require("@fluxerjs/types");
3192
3286
  async function createSticker(guild, options) {
3193
- const data = await guild.client.rest.post(import_types34.Routes.guildStickers(guild.id), {
3287
+ const data = await guild.client.rest.post(import_types35.Routes.guildStickers(guild.id), {
3194
3288
  body: options,
3195
3289
  auth: true
3196
3290
  });
3197
3291
  return cacheSticker(guild, data);
3198
3292
  }
3199
3293
  async function cloneSticker(guild, sourceStickerId) {
3200
- const data = await guild.client.rest.post(import_types34.Routes.guildStickersClone(guild.id), {
3294
+ const data = await guild.client.rest.post(import_types35.Routes.guildStickersClone(guild.id), {
3201
3295
  body: { source_sticker_id: sourceStickerId },
3202
3296
  auth: true
3203
3297
  });
@@ -3205,17 +3299,17 @@ async function cloneSticker(guild, sourceStickerId) {
3205
3299
  }
3206
3300
  async function createStickersBulk(guild, stickers) {
3207
3301
  const data = await guild.client.rest.post(
3208
- import_types34.Routes.guildStickersBulk(guild.id),
3302
+ import_types35.Routes.guildStickersBulk(guild.id),
3209
3303
  { body: { stickers }, auth: true }
3210
3304
  );
3211
3305
  return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
3212
3306
  }
3213
3307
  async function fetchStickers(guild) {
3214
- const data = await guild.client.rest.get(import_types34.Routes.guildStickers(guild.id));
3308
+ const data = await guild.client.rest.get(import_types35.Routes.guildStickers(guild.id));
3215
3309
  return data.map((s) => cacheSticker(guild, s));
3216
3310
  }
3217
3311
  async function fetchSticker(guild, stickerId) {
3218
- const data = await guild.client.rest.get(import_types34.Routes.guildSticker(guild.id, stickerId));
3312
+ const data = await guild.client.rest.get(import_types35.Routes.guildSticker(guild.id, stickerId));
3219
3313
  return cacheSticker(guild, data);
3220
3314
  }
3221
3315
 
@@ -3225,6 +3319,8 @@ var Guild = class extends Base {
3225
3319
  client;
3226
3320
  /** Snowflake ID of this guild. */
3227
3321
  id;
3322
+ /** Whether the guild is currently available through the gateway. */
3323
+ available = true;
3228
3324
  /** Guild name. */
3229
3325
  name;
3230
3326
  /** Icon hash (use {@link iconURL} to get full CDN URL). */
@@ -3298,7 +3394,7 @@ var Guild = class extends Base {
3298
3394
  this.afkTimeout = data.afk_timeout ?? 0;
3299
3395
  this.systemChannelId = data.system_channel_id ?? null;
3300
3396
  this.rulesChannelId = data.rules_channel_id ?? null;
3301
- this.nsfwLevel = data.nsfw_level ?? import_types35.GuildNSFWLevel.Safe;
3397
+ this.nsfwLevel = data.nsfw_level ?? import_types36.GuildNSFWLevel.Safe;
3302
3398
  this.mfaLevel = data.mfa_level ?? 0;
3303
3399
  this.bannerWidth = data.banner_width ?? null;
3304
3400
  this.bannerHeight = data.banner_height ?? null;
@@ -3331,7 +3427,7 @@ var Guild = class extends Base {
3331
3427
  if (data.afk_timeout !== void 0) this.afkTimeout = data.afk_timeout ?? 0;
3332
3428
  if (data.system_channel_id !== void 0) this.systemChannelId = data.system_channel_id ?? null;
3333
3429
  if (data.rules_channel_id !== void 0) this.rulesChannelId = data.rules_channel_id ?? null;
3334
- if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types35.GuildNSFWLevel.Safe;
3430
+ if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types36.GuildNSFWLevel.Safe;
3335
3431
  if (data.mfa_level !== void 0) this.mfaLevel = data.mfa_level ?? 0;
3336
3432
  if (data.banner_width !== void 0) this.bannerWidth = data.banner_width ?? null;
3337
3433
  if (data.banner_height !== void 0) this.bannerHeight = data.banner_height ?? null;
@@ -3560,13 +3656,13 @@ var GuildManager = class extends import_collection9.Collection {
3560
3656
  const cached = this.get(guildId);
3561
3657
  if (cached) return cached;
3562
3658
  try {
3563
- const data = await this.client.rest.get(import_types36.Routes.guild(guildId));
3659
+ const data = await this.client.rest.get(import_types37.Routes.guild(guildId));
3564
3660
  const guild = new Guild(this.client, data);
3565
3661
  this.set(guild.id, guild);
3566
3662
  return guild;
3567
3663
  } catch (err) {
3568
- if (err instanceof import_rest5.RateLimitError) throw err;
3569
- if (err instanceof import_rest5.FluxerAPIError && err.statusCode === 404) {
3664
+ if (err instanceof import_rest6.RateLimitError) throw err;
3665
+ if (err instanceof import_rest6.FluxerAPIError && err.statusCode === 404) {
3570
3666
  throw new import_util2.FluxerError(`Guild ${guildId} not found`, {
3571
3667
  code: import_util.ErrorCodes.GuildNotFound,
3572
3668
  cause: err
@@ -3587,7 +3683,7 @@ var DEFAULT_CACHE_LIMITS = {
3587
3683
  };
3588
3684
 
3589
3685
  // src/structures/User.ts
3590
- var import_types37 = require("@fluxerjs/types");
3686
+ var import_types38 = require("@fluxerjs/types");
3591
3687
  var User = class extends Base {
3592
3688
  /** Parent client instance. */
3593
3689
  client;
@@ -3677,7 +3773,7 @@ var User = class extends Base {
3677
3773
  * @returns DM channel instance (cached if already open)
3678
3774
  */
3679
3775
  async createDM() {
3680
- const data = await this.client.rest.post(import_types37.Routes.userMeChannels(), {
3776
+ const data = await this.client.rest.post(import_types38.Routes.userMeChannels(), {
3681
3777
  body: { recipient_id: this.id },
3682
3778
  auth: true
3683
3779
  });
@@ -3687,7 +3783,7 @@ var User = class extends Base {
3687
3783
  }
3688
3784
  /**
3689
3785
  * Send a DM to this user.
3690
- * @param options - Message content or {@link MessageSendOptions}
3786
+ * @param options - {@link MessagePrepareInput}
3691
3787
  * @returns Sent message
3692
3788
  */
3693
3789
  async send(options) {
@@ -3697,7 +3793,7 @@ var User = class extends Base {
3697
3793
 
3698
3794
  // src/client/UserManager.ts
3699
3795
  var import_collection10 = require("@fluxerjs/collection");
3700
- var import_types38 = require("@fluxerjs/types");
3796
+ var import_types39 = require("@fluxerjs/types");
3701
3797
  var soft = (p) => p.catch(() => null);
3702
3798
  var UserManager = class extends import_collection10.Collection {
3703
3799
  constructor(client) {
@@ -3728,7 +3824,7 @@ var UserManager = class extends import_collection10.Collection {
3728
3824
  }
3729
3825
  /** Fetch a user by ID and update cache. */
3730
3826
  async fetch(userId) {
3731
- const data = await this.client.rest.get(import_types38.Routes.user(userId));
3827
+ const data = await this.client.rest.get(import_types39.Routes.user(userId));
3732
3828
  return this.client.getOrCreateUser(data);
3733
3829
  }
3734
3830
  /**
@@ -3742,10 +3838,10 @@ var UserManager = class extends import_collection10.Collection {
3742
3838
  async fetchWithProfile(userId, options) {
3743
3839
  const guildId = options?.guildId ?? void 0;
3744
3840
  const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
3745
- this.client.rest.get(import_types38.Routes.user(userId)),
3746
- soft(this.client.rest.get(import_types38.Routes.userProfile(userId))),
3747
- guildId ? soft(this.client.rest.get(import_types38.Routes.userProfile(userId, guildId))) : null,
3748
- guildId ? soft(this.client.rest.get(import_types38.Routes.guildMember(guildId, userId))) : null
3841
+ this.client.rest.get(import_types39.Routes.user(userId)),
3842
+ soft(this.client.rest.get(import_types39.Routes.userProfile(userId))),
3843
+ guildId ? soft(this.client.rest.get(import_types39.Routes.userProfile(userId, guildId))) : null,
3844
+ guildId ? soft(this.client.rest.get(import_types39.Routes.guildMember(guildId, userId))) : null
3749
3845
  ]);
3750
3846
  const user = this.client.getOrCreateUser(userData);
3751
3847
  let member = null;
@@ -3774,7 +3870,7 @@ var UserManager = class extends import_collection10.Collection {
3774
3870
  };
3775
3871
 
3776
3872
  // src/client/PackManager.ts
3777
- var import_types39 = require("@fluxerjs/types");
3873
+ var import_types40 = require("@fluxerjs/types");
3778
3874
  function toPackSummaryPayload(data) {
3779
3875
  return {
3780
3876
  id: data.id,
@@ -3829,7 +3925,7 @@ var PackManager = class {
3829
3925
  }
3830
3926
  /** Fetch the current user's pack dashboard (camelCase summaries). */
3831
3927
  async fetchDashboard() {
3832
- const data = await this.client.rest.get(import_types39.Routes.packs());
3928
+ const data = await this.client.rest.get(import_types40.Routes.packs());
3833
3929
  return {
3834
3930
  emoji: mapDashboardSection(data.emoji),
3835
3931
  sticker: mapDashboardSection(data.sticker)
@@ -3837,49 +3933,49 @@ var PackManager = class {
3837
3933
  }
3838
3934
  /** Create a pack. */
3839
3935
  async create(packType, body) {
3840
- const data = await this.client.rest.post(import_types39.Routes.packsByType(packType), {
3936
+ const data = await this.client.rest.post(import_types40.Routes.packsByType(packType), {
3841
3937
  body
3842
3938
  });
3843
3939
  return toPackSummaryPayload(data);
3844
3940
  }
3845
3941
  /** Edit a pack. */
3846
3942
  async edit(packId, body) {
3847
- const data = await this.client.rest.patch(import_types39.Routes.pack(packId), { body });
3943
+ const data = await this.client.rest.patch(import_types40.Routes.pack(packId), { body });
3848
3944
  return toPackSummaryPayload(data);
3849
3945
  }
3850
3946
  /** Delete a pack. */
3851
3947
  async delete(packId) {
3852
- await this.client.rest.delete(import_types39.Routes.pack(packId));
3948
+ await this.client.rest.delete(import_types40.Routes.pack(packId));
3853
3949
  }
3854
3950
  /** Install a pack for the current user. */
3855
3951
  async install(packId) {
3856
- await this.client.rest.post(import_types39.Routes.packInstall(packId));
3952
+ await this.client.rest.post(import_types40.Routes.packInstall(packId));
3857
3953
  }
3858
3954
  /** Uninstall a pack for the current user. */
3859
3955
  async uninstall(packId) {
3860
- await this.client.rest.delete(import_types39.Routes.packInstall(packId));
3956
+ await this.client.rest.delete(import_types40.Routes.packInstall(packId));
3861
3957
  }
3862
3958
  /** List invites for a pack. */
3863
3959
  async listInvites(packId) {
3864
- const data = await this.client.rest.get(import_types39.Routes.packInvites(packId));
3960
+ const data = await this.client.rest.get(import_types40.Routes.packInvites(packId));
3865
3961
  return data.map(toInvitePayload);
3866
3962
  }
3867
3963
  /** Create an invite for a pack. */
3868
3964
  async createInvite(packId, options = {}) {
3869
3965
  const body = toPackInviteBody(options);
3870
- const data = await this.client.rest.post(import_types39.Routes.packInvites(packId), {
3966
+ const data = await this.client.rest.post(import_types40.Routes.packInvites(packId), {
3871
3967
  body: Object.keys(body).length ? body : void 0
3872
3968
  });
3873
3969
  return toInvitePayload(data);
3874
3970
  }
3875
3971
  /** List emojis in a pack. */
3876
3972
  async listEmojis(packId) {
3877
- const data = await this.client.rest.get(import_types39.Routes.packEmojis(packId));
3973
+ const data = await this.client.rest.get(import_types40.Routes.packEmojis(packId));
3878
3974
  return data.map(toEmojiPayload);
3879
3975
  }
3880
3976
  /** Create an emoji in a pack. */
3881
3977
  async createEmoji(packId, options) {
3882
- const data = await this.client.rest.post(import_types39.Routes.packEmojis(packId), {
3978
+ const data = await this.client.rest.post(import_types40.Routes.packEmojis(packId), {
3883
3979
  body: toEmojiCreateBody(options)
3884
3980
  });
3885
3981
  return toEmojiPayload(data);
@@ -3887,7 +3983,7 @@ var PackManager = class {
3887
3983
  /** Bulk-create emojis in a pack. */
3888
3984
  async createEmojisBulk(packId, emojis) {
3889
3985
  const data = await this.client.rest.post(
3890
- import_types39.Routes.packEmojisBulk(packId),
3986
+ import_types40.Routes.packEmojisBulk(packId),
3891
3987
  { body: { emojis: emojis.map(toEmojiCreateBody) } }
3892
3988
  );
3893
3989
  return {
@@ -3897,23 +3993,23 @@ var PackManager = class {
3897
3993
  }
3898
3994
  /** Edit an emoji in a pack. */
3899
3995
  async editEmoji(packId, emojiId, options) {
3900
- const data = await this.client.rest.patch(import_types39.Routes.packEmoji(packId, emojiId), {
3996
+ const data = await this.client.rest.patch(import_types40.Routes.packEmoji(packId, emojiId), {
3901
3997
  body: toEmojiEditBody(options)
3902
3998
  });
3903
3999
  return toEmojiPayload(data);
3904
4000
  }
3905
4001
  /** Delete an emoji from a pack. */
3906
4002
  async deleteEmoji(packId, emojiId) {
3907
- await this.client.rest.delete(import_types39.Routes.packEmoji(packId, emojiId));
4003
+ await this.client.rest.delete(import_types40.Routes.packEmoji(packId, emojiId));
3908
4004
  }
3909
4005
  /** List stickers in a pack. */
3910
4006
  async listStickers(packId) {
3911
- const data = await this.client.rest.get(import_types39.Routes.packStickers(packId));
4007
+ const data = await this.client.rest.get(import_types40.Routes.packStickers(packId));
3912
4008
  return data.map(toStickerPayload);
3913
4009
  }
3914
4010
  /** Create a sticker in a pack. */
3915
4011
  async createSticker(packId, options) {
3916
- const data = await this.client.rest.post(import_types39.Routes.packStickers(packId), {
4012
+ const data = await this.client.rest.post(import_types40.Routes.packStickers(packId), {
3917
4013
  body: toStickerCreateBody(options)
3918
4014
  });
3919
4015
  return toStickerPayload(data);
@@ -3921,7 +4017,7 @@ var PackManager = class {
3921
4017
  /** Bulk-create stickers in a pack. */
3922
4018
  async createStickersBulk(packId, stickers) {
3923
4019
  const data = await this.client.rest.post(
3924
- import_types39.Routes.packStickersBulk(packId),
4020
+ import_types40.Routes.packStickersBulk(packId),
3925
4021
  { body: { stickers: stickers.map(toStickerCreateBody) } }
3926
4022
  );
3927
4023
  return {
@@ -3931,14 +4027,14 @@ var PackManager = class {
3931
4027
  }
3932
4028
  /** Edit a sticker in a pack. */
3933
4029
  async editSticker(packId, stickerId, options) {
3934
- const data = await this.client.rest.patch(import_types39.Routes.packSticker(packId, stickerId), {
4030
+ const data = await this.client.rest.patch(import_types40.Routes.packSticker(packId, stickerId), {
3935
4031
  body: toStickerEditBody(options)
3936
4032
  });
3937
4033
  return toStickerPayload(data);
3938
4034
  }
3939
4035
  /** Delete a sticker from a pack. */
3940
4036
  async deleteSticker(packId, stickerId) {
3941
- await this.client.rest.delete(import_types39.Routes.packSticker(packId, stickerId));
4037
+ await this.client.rest.delete(import_types40.Routes.packSticker(packId, stickerId));
3942
4038
  }
3943
4039
  };
3944
4040
 
@@ -3957,10 +4053,10 @@ function createEventMethods(client) {
3957
4053
 
3958
4054
  // src/client/clientEmoji.ts
3959
4055
  var import_collection11 = require("@fluxerjs/collection");
3960
- var import_types40 = require("@fluxerjs/types");
4056
+ var import_types41 = require("@fluxerjs/types");
3961
4057
  var import_util9 = require("@fluxerjs/util");
3962
4058
  async function assertEmojiInGuild(client, emojiId, guildId) {
3963
- const emojis = await client.rest.get(import_types40.Routes.guildEmojis(guildId));
4059
+ const emojis = await client.rest.get(import_types41.Routes.guildEmojis(guildId));
3964
4060
  if (!emojis.some((e) => e.id === emojiId)) {
3965
4061
  throw new import_util2.FluxerError("Custom emoji is from another server. Use an emoji from this server.", {
3966
4062
  code: import_util.ErrorCodes.EmojiNotInGuild
@@ -3986,7 +4082,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
3986
4082
  const unicodeFromShortcode = (0, import_util9.getUnicodeFromShortcode)(parsed.name);
3987
4083
  if (unicodeFromShortcode) return unicodeFromShortcode;
3988
4084
  if (guildId) {
3989
- const emojis = await client.rest.get(import_types40.Routes.guildEmojis(guildId));
4085
+ const emojis = await client.rest.get(import_types41.Routes.guildEmojis(guildId));
3990
4086
  const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
3991
4087
  if (found) return (0, import_util9.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
3992
4088
  throw new import_util2.FluxerError(
@@ -4003,28 +4099,28 @@ async function resolveClientEmoji(client, emoji, guildId) {
4003
4099
  return parsed.name;
4004
4100
  }
4005
4101
  async function fetchInstance(client) {
4006
- const raw = await client.rest.get(import_types40.Routes.instanceDiscovery(), { auth: false });
4102
+ const raw = await client.rest.get(import_types41.Routes.instanceDiscovery(), { auth: false });
4007
4103
  return parseInstanceDiscovery(raw);
4008
4104
  }
4009
4105
  function fetchGatewayInfo(client) {
4010
- return client.rest.get(import_types40.Routes.gatewayBot());
4106
+ return client.rest.get(import_types41.Routes.gatewayBot());
4011
4107
  }
4012
4108
  function fetchEmojiMetadata(client, emojiId) {
4013
- return client.rest.get(import_types40.Routes.emojiMetadata(emojiId), { auth: true });
4109
+ return client.rest.get(import_types41.Routes.emojiMetadata(emojiId), { auth: true });
4014
4110
  }
4015
4111
  function fetchStickerMetadata(client, stickerId) {
4016
- return client.rest.get(import_types40.Routes.stickerMetadata(stickerId), { auth: true });
4112
+ return client.rest.get(import_types41.Routes.stickerMetadata(stickerId), { auth: true });
4017
4113
  }
4018
4114
  function fetchApplication(client) {
4019
- return client.rest.get(import_types40.Routes.applicationsMe(), { auth: true });
4115
+ return client.rest.get(import_types41.Routes.applicationsMe(), { auth: true });
4020
4116
  }
4021
4117
  async function fetchOAuthApplications(client) {
4022
- const data = await client.rest.get(import_types40.Routes.oauth2ApplicationsMe(), { auth: true });
4118
+ const data = await client.rest.get(import_types41.Routes.oauth2ApplicationsMe(), { auth: true });
4023
4119
  return Array.isArray(data) ? data : data.applications ?? [];
4024
4120
  }
4025
4121
  function checkUsernameTag(client, username, discriminator) {
4026
4122
  const params = new URLSearchParams({ username, discriminator });
4027
- return client.rest.get(`${import_types40.Routes.checkUsernameTag()}?${params}`, { auth: true });
4123
+ return client.rest.get(`${import_types41.Routes.checkUsernameTag()}?${params}`, { auth: true });
4028
4124
  }
4029
4125
  function assertChannelIdBatch(name, channelIds) {
4030
4126
  if (channelIds.length < 1 || channelIds.length > 100) {
@@ -4035,14 +4131,14 @@ function assertChannelIdBatch(name, channelIds) {
4035
4131
  }
4036
4132
  function preloadMessages(client, channelIds) {
4037
4133
  assertChannelIdBatch("preloadMessages", channelIds);
4038
- return client.rest.post(import_types40.Routes.preloadMessages(), {
4134
+ return client.rest.post(import_types41.Routes.preloadMessages(), {
4039
4135
  body: { channels: channelIds },
4040
4136
  auth: true
4041
4137
  });
4042
4138
  }
4043
4139
  function preloadMessagesAlt(client, channelIds) {
4044
4140
  assertChannelIdBatch("preloadMessagesAlt", channelIds);
4045
- return client.rest.post(import_types40.Routes.preloadMessagesAlt(), {
4141
+ return client.rest.post(import_types41.Routes.preloadMessagesAlt(), {
4046
4142
  body: { channels: channelIds },
4047
4143
  auth: true
4048
4144
  });
@@ -4050,7 +4146,7 @@ function preloadMessagesAlt(client, channelIds) {
4050
4146
  async function bulkFetchMessages(client, requests, options = {}) {
4051
4147
  validateBulkMessageFetchRequests(requests);
4052
4148
  const wire = toBulkFetchWire(requests);
4053
- const data = await client.rest.post(import_types40.Routes.channelsMessagesBulk(), {
4149
+ const data = await client.rest.post(import_types41.Routes.channelsMessagesBulk(), {
4054
4150
  body: { requests: wire },
4055
4151
  auth: true
4056
4152
  });
@@ -4137,62 +4233,6 @@ function buildRegistry(...maps) {
4137
4233
  return registry;
4138
4234
  }
4139
4235
 
4140
- // src/structures/MessageReaction.ts
4141
- var import_types41 = require("@fluxerjs/types");
4142
- var import_rest6 = require("@fluxerjs/rest");
4143
- var MessageReaction = class extends Base {
4144
- client;
4145
- messageId;
4146
- channelId;
4147
- guildId;
4148
- emoji;
4149
- /** Raw gateway payload for low-level access. */
4150
- _data;
4151
- constructor(client, data) {
4152
- super();
4153
- this.client = client;
4154
- this._data = data;
4155
- this.messageId = data.message_id;
4156
- this.channelId = data.channel_id;
4157
- this.guildId = data.guild_id ?? null;
4158
- this.emoji = {
4159
- name: data.emoji.name,
4160
- ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
4161
- ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
4162
- };
4163
- }
4164
- /** Emoji as a string: unicode or "name:id" for custom. */
4165
- get emojiIdentifier() {
4166
- return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
4167
- }
4168
- /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
4169
- get guild() {
4170
- return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
4171
- }
4172
- /**
4173
- * Fetch the message this reaction belongs to.
4174
- * Use when you need to edit, delete, or otherwise interact with the message.
4175
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
4176
- */
4177
- async fetchMessage() {
4178
- try {
4179
- const data = await this.client.rest.get(
4180
- import_types41.Routes.channelMessage(this.channelId, this.messageId)
4181
- );
4182
- return new Message(this.client, data);
4183
- } catch (err) {
4184
- if (err instanceof import_rest6.RateLimitError) throw err;
4185
- if (err instanceof import_rest6.FluxerAPIError && err.statusCode === 404) {
4186
- throw new import_util2.FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
4187
- code: import_util.ErrorCodes.MessageNotFound,
4188
- cause: err
4189
- });
4190
- }
4191
- throw err instanceof import_util2.FluxerError ? err : new import_util2.FluxerError(String(err), { cause: err });
4192
- }
4193
- }
4194
- };
4195
-
4196
4236
  // src/client/eventHandlers/helpers.ts
4197
4237
  function unknownUser(id) {
4198
4238
  return { id, username: "Unknown", discriminator: "0" };
@@ -4363,13 +4403,50 @@ function normalizeGuildPayload(raw) {
4363
4403
  }
4364
4404
 
4365
4405
  // src/client/eventHandlers/guilds.ts
4406
+ function markGuildUnavailable(client, id) {
4407
+ const guild = client.guilds.get(id);
4408
+ if (!guild || guild.available === false) return;
4409
+ guild.available = false;
4410
+ client.emit(Events.GuildUnavailable, guild);
4411
+ }
4412
+ function refreshRecoveredGuild(guild, data) {
4413
+ guild._patch(data);
4414
+ if (data.roles !== void 0) {
4415
+ guild.roles.clear();
4416
+ for (const role of data.roles) {
4417
+ guild.roles.set(role.id, new Role(guild.client, role, guild.id));
4418
+ }
4419
+ }
4420
+ if (data.channels !== void 0) {
4421
+ const recoveredChannelIds = new Set(data.channels.map((channel) => channel.id));
4422
+ for (const channel of guild.channels.values()) {
4423
+ guild.client.channels.delete(channel.id);
4424
+ if (!recoveredChannelIds.has(channel.id)) guild.client._clearMessageCache(channel.id);
4425
+ }
4426
+ guild.channels.clear();
4427
+ }
4428
+ }
4366
4429
  var guildHandlers = {
4367
4430
  GUILD_CREATE(client, d) {
4431
+ const raw = d;
4432
+ if (raw.unavailable === true) {
4433
+ if (typeof raw.id === "string") {
4434
+ try {
4435
+ markGuildUnavailable(client, raw.id);
4436
+ } finally {
4437
+ client._onGuildReceived(raw.id);
4438
+ }
4439
+ }
4440
+ return;
4441
+ }
4368
4442
  const guildData = normalizeGuildPayload(d);
4369
4443
  if (!guildData) return;
4370
- const guild = new Guild(client, guildData);
4371
- client.guilds.set(guild.id, guild);
4372
4444
  const g = d;
4445
+ const existing = client.guilds.get(guildData.id);
4446
+ const recovered = existing?.available === false;
4447
+ const guild = recovered && existing ? existing : new Guild(client, guildData);
4448
+ if (recovered) refreshRecoveredGuild(guild, g);
4449
+ client.guilds.set(guild.id, guild);
4373
4450
  for (const ch of g.channels ?? []) {
4374
4451
  const channel = Channel.from(client, ch);
4375
4452
  if (channel) {
@@ -4378,7 +4455,8 @@ var guildHandlers = {
4378
4455
  }
4379
4456
  }
4380
4457
  for (const m of g.members ?? []) cacheMember2(client, guild, m);
4381
- client.emit(Events.GuildCreate, guild);
4458
+ if (recovered) guild.available = true;
4459
+ client.emit(recovered ? Events.GuildAvailable : Events.GuildCreate, guild);
4382
4460
  if (g.voice_states?.length) {
4383
4461
  client.emit(Events.VoiceStatesSync, { guildId: guild.id, voiceStates: g.voice_states });
4384
4462
  }
@@ -4399,11 +4477,19 @@ var guildHandlers = {
4399
4477
  client.emit(Events.GuildUpdate, updated, updated);
4400
4478
  },
4401
4479
  GUILD_DELETE(client, d) {
4402
- const { id } = d;
4403
- const guild = client.guilds.get(id);
4404
- if (!guild) return;
4405
- client.guilds.delete(id);
4406
- client.emit(Events.GuildDelete, guild);
4480
+ const { id, unavailable } = d;
4481
+ try {
4482
+ if (unavailable === true) {
4483
+ markGuildUnavailable(client, id);
4484
+ return;
4485
+ }
4486
+ const guild = client.guilds.get(id);
4487
+ if (!guild) return;
4488
+ client.guilds.delete(id);
4489
+ client.emit(Events.GuildDelete, guild);
4490
+ } finally {
4491
+ client._onGuildReceived(id);
4492
+ }
4407
4493
  }
4408
4494
  };
4409
4495
 
@@ -4822,7 +4908,12 @@ function emitClientError(client, err) {
4822
4908
  function shouldDeferGatewayDispatchUntilReady(client, payload) {
4823
4909
  if (client.options.waitForGuilds !== true || client.readyAt !== null) return false;
4824
4910
  if (payload.op !== 0 || !payload.t) return false;
4825
- return payload.t !== "GUILD_CREATE";
4911
+ if (payload.t === "GUILD_CREATE") return false;
4912
+ if (payload.t === "GUILD_DELETE") {
4913
+ const data = payload.d;
4914
+ if (typeof data?.id === "string" && client._pendingGuildIds?.has(data.id)) return false;
4915
+ }
4916
+ return true;
4826
4917
  }
4827
4918
  function handleGatewayDispatch(client, payload, deferred) {
4828
4919
  if (payload.op !== 0 || !payload.t) return Promise.resolve();