@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/client.js CHANGED
@@ -32,8 +32,8 @@ var import_types46 = require("@fluxerjs/types");
32
32
 
33
33
  // src/client/ChannelManager.ts
34
34
  var import_collection5 = require("@fluxerjs/collection");
35
- var import_types16 = require("@fluxerjs/types");
36
- var import_rest3 = require("@fluxerjs/rest");
35
+ var import_types17 = require("@fluxerjs/types");
36
+ var import_rest4 = require("@fluxerjs/rest");
37
37
 
38
38
  // src/errors/FluxerError.ts
39
39
  var import_util = require("@fluxerjs/util");
@@ -221,17 +221,17 @@ async function prepareMessagePostPayload(options, defaults) {
221
221
  }
222
222
 
223
223
  // src/structures/channel/base.ts
224
- var import_types9 = require("@fluxerjs/types");
224
+ var import_types10 = require("@fluxerjs/types");
225
225
 
226
226
  // src/client/MessageManager.ts
227
- var import_types7 = require("@fluxerjs/types");
227
+ var import_types8 = require("@fluxerjs/types");
228
228
  var import_collection3 = require("@fluxerjs/collection");
229
- var import_rest = require("@fluxerjs/rest");
229
+ var import_rest2 = require("@fluxerjs/rest");
230
230
 
231
231
  // src/structures/message/Message.ts
232
232
  var import_collection2 = require("@fluxerjs/collection");
233
233
  var import_builders3 = require("@fluxerjs/builders");
234
- var import_types5 = require("@fluxerjs/types");
234
+ var import_types6 = require("@fluxerjs/types");
235
235
 
236
236
  // src/client/sdkOptions.ts
237
237
  function toMemberSearchBody(options) {
@@ -472,6 +472,68 @@ function toProfilePayload(data) {
472
472
  var import_events = require("events");
473
473
  var import_collection = require("@fluxerjs/collection");
474
474
 
475
+ // src/structures/MessageReaction.ts
476
+ var import_types3 = require("@fluxerjs/types");
477
+ var import_rest = require("@fluxerjs/rest");
478
+
479
+ // src/structures/Base.ts
480
+ var Base = class {
481
+ };
482
+
483
+ // src/structures/MessageReaction.ts
484
+ var MessageReaction = class extends Base {
485
+ client;
486
+ messageId;
487
+ channelId;
488
+ guildId;
489
+ emoji;
490
+ /** Raw gateway payload for low-level access. */
491
+ _data;
492
+ constructor(client, data) {
493
+ super();
494
+ this.client = client;
495
+ this._data = data;
496
+ this.messageId = data.message_id;
497
+ this.channelId = data.channel_id;
498
+ this.guildId = data.guild_id ?? null;
499
+ this.emoji = {
500
+ name: data.emoji.name,
501
+ ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
502
+ ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
503
+ };
504
+ }
505
+ /** Emoji as a string: unicode or "name:id" for custom. */
506
+ get emojiIdentifier() {
507
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
508
+ }
509
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
510
+ get guild() {
511
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
512
+ }
513
+ /**
514
+ * Fetch the message this reaction belongs to.
515
+ * Use when you need to edit, delete, or otherwise interact with the message.
516
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
517
+ */
518
+ async fetchMessage() {
519
+ try {
520
+ const data = await this.client.rest.get(
521
+ import_types3.Routes.channelMessage(this.channelId, this.messageId)
522
+ );
523
+ return new Message(this.client, data);
524
+ } catch (err) {
525
+ if (err instanceof import_rest.RateLimitError) throw err;
526
+ if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
527
+ throw new import_util.FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
528
+ code: import_util2.ErrorCodes.MessageNotFound,
529
+ cause: err
530
+ });
531
+ }
532
+ throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
533
+ }
534
+ }
535
+ };
536
+
475
537
  // src/util/Events.ts
476
538
  var Events = {
477
539
  Ready: "ready",
@@ -485,6 +547,8 @@ var Events = {
485
547
  MessageReactionRemoveAll: "messageReactionRemoveAll",
486
548
  MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
487
549
  GuildCreate: "guildCreate",
550
+ GuildAvailable: "guildAvailable",
551
+ GuildUnavailable: "guildUnavailable",
488
552
  GuildUpdate: "guildUpdate",
489
553
  GuildDelete: "guildDelete",
490
554
  GuildBanAdd: "guildBanAdd",
@@ -533,7 +597,8 @@ var ReactionCollector = class extends import_events.EventEmitter {
533
597
  collected = new import_collection.Collection();
534
598
  _timeout = null;
535
599
  _ended = false;
536
- _listener;
600
+ _onAdd;
601
+ _onAddMany;
537
602
  constructor(client, messageId, channelId, options = {}) {
538
603
  super();
539
604
  this.client = client;
@@ -544,27 +609,58 @@ var ReactionCollector = class extends import_events.EventEmitter {
544
609
  time: options.time ?? 0,
545
610
  max: options.max ?? 0
546
611
  };
547
- this._listener = (payload) => {
612
+ this._onAdd = (payload) => {
548
613
  if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
549
614
  return;
550
615
  }
551
- if (!this.options.filter(payload.reaction, payload.user)) return;
552
- const key = `${payload.userId}:${payload.reaction.emoji.id ?? payload.reaction.emoji.name}`;
553
- this.collected.set(key, { reaction: payload.reaction, user: payload.user });
554
- this.emit("collect", payload.reaction, payload.user);
555
- if (this.options.max > 0 && this.collected.size >= this.options.max) {
556
- this.stop("limit");
616
+ this._collect(payload.reaction, payload.user, payload.userId);
617
+ };
618
+ this._onAddMany = (payload) => {
619
+ if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
620
+ return;
621
+ }
622
+ for (const entry of payload.reactions) {
623
+ if (this._ended) return;
624
+ const reaction = new MessageReaction(this.client, {
625
+ message_id: payload.messageId,
626
+ channel_id: payload.channelId,
627
+ guild_id: payload.guildId ?? void 0,
628
+ user_id: entry.userId,
629
+ emoji: {
630
+ name: entry.emoji.name,
631
+ ...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
632
+ ...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
633
+ }
634
+ });
635
+ const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
636
+ id: entry.userId,
637
+ username: "Unknown",
638
+ discriminator: "0"
639
+ });
640
+ this._collect(reaction, user, entry.userId);
557
641
  }
558
642
  };
559
- this.client.on(Events.MessageReactionAdd, this._listener);
643
+ this.client.on(Events.MessageReactionAdd, this._onAdd);
644
+ this.client.on(Events.MessageReactionAddMany, this._onAddMany);
560
645
  if (this.options.time > 0) {
561
646
  this._timeout = setTimeout(() => this.stop("time"), this.options.time);
562
647
  }
563
648
  }
649
+ _collect(reaction, user, userId) {
650
+ if (this._ended) return;
651
+ if (!this.options.filter(reaction, user)) return;
652
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
653
+ this.collected.set(key, { reaction, user });
654
+ this.emit("collect", reaction, user);
655
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
656
+ this.stop("limit");
657
+ }
658
+ }
564
659
  stop(reason = "user") {
565
660
  if (this._ended) return;
566
661
  this._ended = true;
567
- this.client.off(Events.MessageReactionAdd, this._listener);
662
+ this.client.off(Events.MessageReactionAdd, this._onAdd);
663
+ this.client.off(Events.MessageReactionAddMany, this._onAddMany);
568
664
  if (this._timeout) {
569
665
  clearTimeout(this._timeout);
570
666
  this._timeout = null;
@@ -579,30 +675,26 @@ var ReactionCollector = class extends import_events.EventEmitter {
579
675
  }
580
676
  };
581
677
 
582
- // src/structures/Base.ts
583
- var Base = class {
584
- };
585
-
586
678
  // src/structures/message/reactions.ts
587
- var import_types3 = require("@fluxerjs/types");
679
+ var import_types4 = require("@fluxerjs/types");
588
680
  async function emojiPath(message, emoji) {
589
681
  return message.client.resolveEmoji(emoji, message.guildId);
590
682
  }
591
683
  async function reactToMessage(message, emoji) {
592
684
  const e = await emojiPath(message, emoji);
593
- await message.client.rest.put(import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e));
685
+ await message.client.rest.put(import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e));
594
686
  }
595
687
  async function removeMessageReaction(message, emoji, userId) {
596
688
  const e = await emojiPath(message, emoji);
597
- const route = userId ? import_types3.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e);
689
+ const route = userId ? import_types4.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e);
598
690
  await message.client.rest.delete(route);
599
691
  }
600
692
  async function removeAllMessageReactions(message) {
601
- await message.client.rest.delete(import_types3.Routes.channelMessageReactions(message.channelId, message.id));
693
+ await message.client.rest.delete(import_types4.Routes.channelMessageReactions(message.channelId, message.id));
602
694
  }
603
695
  async function removeMessageReactionEmoji(message, emoji) {
604
696
  const e = await emojiPath(message, emoji);
605
- await message.client.rest.delete(import_types3.Routes.channelMessageReaction(message.channelId, message.id, e));
697
+ await message.client.rest.delete(import_types4.Routes.channelMessageReaction(message.channelId, message.id, e));
606
698
  }
607
699
  async function fetchMessageReactionUsers(message, emoji, options) {
608
700
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -613,7 +705,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
613
705
  if (options?.limit != null) params.set("limit", String(options.limit));
614
706
  if (options?.after) params.set("after", options.after);
615
707
  const qs2 = params.toString();
616
- const route = import_types3.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
708
+ const route = import_types4.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
617
709
  const data = await message.client.rest.get(route);
618
710
  if (Array.isArray(data)) {
619
711
  return {
@@ -632,7 +724,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
632
724
 
633
725
  // src/structures/message/send.ts
634
726
  var import_builders2 = require("@fluxerjs/builders");
635
- var import_types4 = require("@fluxerjs/types");
727
+ var import_types5 = require("@fluxerjs/types");
636
728
  function toReplyTarget(ref) {
637
729
  return {
638
730
  channelId: ref.channel_id,
@@ -666,7 +758,7 @@ function asReplyTarget(value) {
666
758
  }
667
759
  async function sendPrepared(message, payload) {
668
760
  const data = await message.client.rest.post(
669
- import_types4.Routes.channelMessages(message.channelId),
761
+ import_types5.Routes.channelMessages(message.channelId),
670
762
  payload
671
763
  );
672
764
  message.client._addMessageToCache(message.channelId, data);
@@ -785,7 +877,7 @@ var Message = class _Message extends Base {
785
877
  this.pinned = data.pinned;
786
878
  this.attachments = new import_collection2.Collection();
787
879
  for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
788
- this.type = data.type ?? import_types5.MessageType.Default;
880
+ this.type = data.type ?? import_types6.MessageType.Default;
789
881
  this.flags = data.flags ?? 0;
790
882
  this.mentionEveryone = data.mention_everyone ?? false;
791
883
  this.tts = data.tts ?? false;
@@ -843,7 +935,7 @@ var Message = class _Message extends Base {
843
935
  if (options.attachments !== void 0) {
844
936
  body.attachments = toMessageAttachmentEditWire(options.attachments);
845
937
  }
846
- const data = await this.client.rest.patch(import_types5.Routes.channelMessage(this.channelId, this.id), {
938
+ const data = await this.client.rest.patch(import_types6.Routes.channelMessage(this.channelId, this.id), {
847
939
  body
848
940
  });
849
941
  const updated = new _Message(this.client, data);
@@ -860,25 +952,25 @@ var Message = class _Message extends Base {
860
952
  }
861
953
  /** Delete this message. */
862
954
  async delete() {
863
- await this.client.rest.delete(import_types5.Routes.channelMessage(this.channelId, this.id));
955
+ await this.client.rest.delete(import_types6.Routes.channelMessage(this.channelId, this.id));
864
956
  this.client._removeMessageFromCache(this.channelId, this.id);
865
957
  }
866
958
  /** Delete a specific attachment from this message. */
867
959
  async deleteAttachment(attachmentId) {
868
960
  await this.client.rest.delete(
869
- import_types5.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
961
+ import_types6.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
870
962
  { auth: true }
871
963
  );
872
964
  this.attachments.delete(attachmentId);
873
965
  }
874
966
  /** Pin this message in the channel. */
875
967
  async pin() {
876
- await this.client.rest.put(import_types5.Routes.channelPinMessage(this.channelId, this.id));
968
+ await this.client.rest.put(import_types6.Routes.channelPinMessage(this.channelId, this.id));
877
969
  this.pinned = true;
878
970
  }
879
971
  /** Unpin this message from the channel. */
880
972
  async unpin() {
881
- await this.client.rest.delete(import_types5.Routes.channelPinMessage(this.channelId, this.id));
973
+ await this.client.rest.delete(import_types6.Routes.channelPinMessage(this.channelId, this.id));
882
974
  this.pinned = false;
883
975
  }
884
976
  /** React to this message with an emoji. */
@@ -959,12 +1051,12 @@ var MessageManager = class {
959
1051
  async fetchOne(messageId) {
960
1052
  try {
961
1053
  const data = await this.client.rest.get(
962
- import_types7.Routes.channelMessage(this.channelId, messageId)
1054
+ import_types8.Routes.channelMessage(this.channelId, messageId)
963
1055
  );
964
1056
  return this.wrap(data);
965
1057
  } catch (err) {
966
- if (err instanceof import_rest.RateLimitError) throw err;
967
- if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
1058
+ if (err instanceof import_rest2.RateLimitError) throw err;
1059
+ if (err instanceof import_rest2.FluxerAPIError && err.statusCode === 404) {
968
1060
  throw new import_util.FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
969
1061
  code: import_util2.ErrorCodes.MessageNotFound,
970
1062
  cause: err
@@ -985,7 +1077,7 @@ var MessageManager = class {
985
1077
  const value = options[key];
986
1078
  if (value != null && value !== "") qs2.set(key, String(value));
987
1079
  }
988
- const base = import_types7.Routes.channelMessages(this.channelId);
1080
+ const base = import_types8.Routes.channelMessages(this.channelId);
989
1081
  const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
990
1082
  const collection = new import_collection3.Collection();
991
1083
  for (const msg of data) collection.set(msg.id, this.wrap(msg));
@@ -994,7 +1086,7 @@ var MessageManager = class {
994
1086
  };
995
1087
 
996
1088
  // src/structures/channel/attachments.ts
997
- var import_types8 = require("@fluxerjs/types");
1089
+ var import_types9 = require("@fluxerjs/types");
998
1090
  function asBytes(data) {
999
1091
  const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
1000
1092
  const out = new Uint8Array(src.byteLength);
@@ -1015,7 +1107,7 @@ async function putBlob(url, body, contentType) {
1015
1107
  }
1016
1108
  async function uploadAttachmentsForSend(client, channelId, files) {
1017
1109
  const plan = await client.rest.post(
1018
- import_types8.Routes.channelAttachments(channelId),
1110
+ import_types9.Routes.channelAttachments(channelId),
1019
1111
  {
1020
1112
  body: {
1021
1113
  attachments: files.map((f) => ({
@@ -1061,7 +1153,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
1061
1153
  });
1062
1154
  }
1063
1155
  if (multipart.length) {
1064
- await client.rest.post(import_types8.Routes.channelAttachmentsComplete(channelId), {
1156
+ await client.rest.post(import_types9.Routes.channelAttachmentsComplete(channelId), {
1065
1157
  body: { uploads: multipart },
1066
1158
  auth: true
1067
1159
  });
@@ -1120,11 +1212,11 @@ var Channel = class extends Base {
1120
1212
  }
1121
1213
  /** Check if this is a DM, group DM, or personal notes channel. */
1122
1214
  isDM() {
1123
- return this.type === import_types9.ChannelType.DM || this.type === import_types9.ChannelType.GroupDM || this.type === import_types9.ChannelType.DMPersonalNotes;
1215
+ return this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes;
1124
1216
  }
1125
1217
  /** Check if this is a personal notes channel. */
1126
1218
  isPersonalNotes() {
1127
- return this.type === import_types9.ChannelType.DMPersonalNotes;
1219
+ return this.type === import_types10.ChannelType.DMPersonalNotes;
1128
1220
  }
1129
1221
  /** Check if this is a voice channel. */
1130
1222
  isVoice() {
@@ -1155,7 +1247,7 @@ var Channel = class extends Base {
1155
1247
  }
1156
1248
  if (ids.length === 0) return [];
1157
1249
  if (ids.length === 1) {
1158
- await this.client.rest.delete(import_types9.Routes.channelMessage(this.id, ids[0]), { auth: true });
1250
+ await this.client.rest.delete(import_types10.Routes.channelMessage(this.id, ids[0]), { auth: true });
1159
1251
  this.client._removeMessageFromCache(this.id, ids[0]);
1160
1252
  return ids;
1161
1253
  }
@@ -1164,7 +1256,7 @@ var Channel = class extends Base {
1164
1256
  code: import_util2.ErrorCodes.InvalidBulkDelete
1165
1257
  });
1166
1258
  }
1167
- await this.client.rest.post(import_types9.Routes.channelBulkDelete(this.id), {
1259
+ await this.client.rest.post(import_types10.Routes.channelBulkDelete(this.id), {
1168
1260
  body: { message_ids: ids },
1169
1261
  auth: true
1170
1262
  });
@@ -1174,23 +1266,23 @@ var Channel = class extends Base {
1174
1266
  /** Delete all messages sent by the bot in this channel (user account feature). */
1175
1267
  async bulkDeleteMyMessages(options) {
1176
1268
  const body = options ? toSudoBody(options) : void 0;
1177
- await this.client.rest.post(import_types9.Routes.channelBulkDeleteMine(this.id), {
1269
+ await this.client.rest.post(import_types10.Routes.channelBulkDeleteMine(this.id), {
1178
1270
  body: body && Object.keys(body).length ? body : void 0,
1179
1271
  auth: true
1180
1272
  });
1181
1273
  }
1182
1274
  /** Mark all pinned messages as read in this channel. */
1183
1275
  async acknowledgePins() {
1184
- await this.client.rest.post(import_types9.Routes.channelPinsAck(this.id), { auth: true });
1276
+ await this.client.rest.post(import_types10.Routes.channelPinsAck(this.id), { auth: true });
1185
1277
  }
1186
1278
  /** Clear the read state for this channel. */
1187
1279
  async clearReadState() {
1188
- await this.client.rest.delete(import_types9.Routes.channelMessagesAck(this.id), { auth: true });
1280
+ await this.client.rest.delete(import_types10.Routes.channelMessagesAck(this.id), { auth: true });
1189
1281
  }
1190
1282
  /** Request upload URLs for attachments before sending a message. */
1191
1283
  async requestAttachmentUploads(attachments) {
1192
1284
  const data = await this.client.rest.post(
1193
- import_types9.Routes.channelAttachments(this.id),
1285
+ import_types10.Routes.channelAttachments(this.id),
1194
1286
  {
1195
1287
  body: toAttachmentUploadPlanBody(attachments),
1196
1288
  auth: true
@@ -1201,7 +1293,7 @@ var Channel = class extends Base {
1201
1293
  /** Complete the attachment upload flow after uploading to the CDN. */
1202
1294
  async completeAttachmentUploads(uploads) {
1203
1295
  const data = await this.client.rest.post(
1204
- import_types9.Routes.channelAttachmentsComplete(this.id),
1296
+ import_types10.Routes.channelAttachmentsComplete(this.id),
1205
1297
  {
1206
1298
  body: toAttachmentUploadCompleteBody(uploads),
1207
1299
  auth: true
@@ -1217,11 +1309,11 @@ var Channel = class extends Base {
1217
1309
  }
1218
1310
  /** Trigger the typing indicator in this channel. */
1219
1311
  async sendTyping() {
1220
- await this.client.rest.post(import_types9.Routes.channelTyping(this.id), { auth: true });
1312
+ await this.client.rest.post(import_types10.Routes.channelTyping(this.id), { auth: true });
1221
1313
  }
1222
1314
  /** Fetch available RTC regions for voice channels. */
1223
1315
  async fetchRtcRegions() {
1224
- const data = await this.client.rest.get(import_types9.Routes.channelRtcRegions(this.id), {
1316
+ const data = await this.client.rest.get(import_types10.Routes.channelRtcRegions(this.id), {
1225
1317
  auth: true
1226
1318
  });
1227
1319
  return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
@@ -1229,7 +1321,7 @@ var Channel = class extends Base {
1229
1321
  /** Fetch slowmode state for this channel. */
1230
1322
  async fetchSlowmode() {
1231
1323
  const data = await this.client.rest.get(
1232
- import_types9.Routes.channelSlowmode(this.id),
1324
+ import_types10.Routes.channelSlowmode(this.id),
1233
1325
  { auth: true }
1234
1326
  );
1235
1327
  return {
@@ -1245,14 +1337,14 @@ var Channel = class extends Base {
1245
1337
  };
1246
1338
 
1247
1339
  // src/structures/channel/guild.ts
1248
- var import_types13 = require("@fluxerjs/types");
1340
+ var import_types14 = require("@fluxerjs/types");
1249
1341
  var import_util3 = require("@fluxerjs/util");
1250
1342
 
1251
1343
  // src/structures/Invite.ts
1252
- var import_types10 = require("@fluxerjs/types");
1344
+ var import_types11 = require("@fluxerjs/types");
1253
1345
 
1254
1346
  // src/util/Constants.ts
1255
- var import_rest2 = require("@fluxerjs/rest");
1347
+ var import_rest3 = require("@fluxerjs/rest");
1256
1348
  var CDN_URL = "https://fluxerusercontent.com";
1257
1349
  var STATIC_CDN_URL = "https://fluxerstatic.com";
1258
1350
 
@@ -1436,12 +1528,12 @@ var Invite = class _Invite extends Base {
1436
1528
  this.client = client;
1437
1529
  this.code = data.code;
1438
1530
  this.type = data.type;
1439
- this.guild = (0, import_types10.isGuildInvite)(data) ? data.guild : null;
1440
- this.channel = (0, import_types10.isGuildInvite)(data) || (0, import_types10.isGroupDmInvite)(data) ? data.channel : null;
1441
- this.pack = (0, import_types10.isPackInvite)(data) ? data.pack : null;
1531
+ this.guild = (0, import_types11.isGuildInvite)(data) ? data.guild : null;
1532
+ this.channel = (0, import_types11.isGuildInvite)(data) || (0, import_types11.isGroupDmInvite)(data) ? data.channel : null;
1533
+ this.pack = (0, import_types11.isPackInvite)(data) ? data.pack : null;
1442
1534
  this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
1443
- this.memberCount = (0, import_types10.isPackInvite)(data) ? null : data.member_count ?? null;
1444
- this.presenceCount = (0, import_types10.isGuildInvite)(data) ? data.presence_count ?? null : null;
1535
+ this.memberCount = (0, import_types11.isPackInvite)(data) ? null : data.member_count ?? null;
1536
+ this.presenceCount = (0, import_types11.isGuildInvite)(data) ? data.presence_count ?? null : null;
1445
1537
  this.expiresAt = data.expires_at ?? null;
1446
1538
  this.temporary = data.temporary ?? null;
1447
1539
  this.createdAt = data.created_at ?? null;
@@ -1450,13 +1542,13 @@ var Invite = class _Invite extends Base {
1450
1542
  this.maxAge = data.max_age ?? null;
1451
1543
  }
1452
1544
  isGuild() {
1453
- return this.type === import_types10.InviteType.Guild;
1545
+ return this.type === import_types11.InviteType.Guild;
1454
1546
  }
1455
1547
  isGroupDM() {
1456
- return this.type === import_types10.InviteType.GroupDM;
1548
+ return this.type === import_types11.InviteType.GroupDM;
1457
1549
  }
1458
1550
  isPack() {
1459
- return this.type === import_types10.InviteType.EmojiPack || this.type === import_types10.InviteType.StickerPack;
1551
+ return this.type === import_types11.InviteType.EmojiPack || this.type === import_types11.InviteType.StickerPack;
1460
1552
  }
1461
1553
  /** Full invite URL (uses this client's instance invite base). */
1462
1554
  get url() {
@@ -1468,18 +1560,18 @@ var Invite = class _Invite extends Base {
1468
1560
  }
1469
1561
  /** Fetch invite metadata by code or URL (does not join). */
1470
1562
  static async fetch(client, codeOrUrl) {
1471
- const data = await client.rest.get(import_types10.Routes.invite(parseInviteCode(codeOrUrl)));
1563
+ const data = await client.rest.get(import_types11.Routes.invite(parseInviteCode(codeOrUrl)));
1472
1564
  return new _Invite(client, data);
1473
1565
  }
1474
1566
  /** Delete this invite. Requires Manage Guild or Create Instant Invite. */
1475
1567
  async delete() {
1476
- await this.client.rest.delete(import_types10.Routes.invite(this.code), { auth: true });
1568
+ await this.client.rest.delete(import_types11.Routes.invite(this.code), { auth: true });
1477
1569
  }
1478
1570
  };
1479
1571
 
1480
1572
  // src/structures/Webhook.ts
1481
1573
  var import_builders4 = require("@fluxerjs/builders");
1482
- var import_types11 = require("@fluxerjs/types");
1574
+ var import_types12 = require("@fluxerjs/types");
1483
1575
 
1484
1576
  // src/util/cdn.ts
1485
1577
  function mediaBase(options) {
@@ -1571,10 +1663,10 @@ var Webhook = class _Webhook extends Base {
1571
1663
  /** Delete this webhook (token auth when available, otherwise bot auth). */
1572
1664
  async delete() {
1573
1665
  if (this.token) {
1574
- await this.client.rest.delete(import_types11.Routes.webhookExecute(this.id, this.token), { auth: false });
1666
+ await this.client.rest.delete(import_types12.Routes.webhookExecute(this.id, this.token), { auth: false });
1575
1667
  return;
1576
1668
  }
1577
- await this.client.rest.delete(import_types11.Routes.webhook(this.id), { auth: true });
1669
+ await this.client.rest.delete(import_types12.Routes.webhook(this.id), { auth: true });
1578
1670
  }
1579
1671
  /**
1580
1672
  * Edit name/avatar. With bot auth (no token), `channelId` may also be set.
@@ -1586,10 +1678,10 @@ var Webhook = class _Webhook extends Base {
1586
1678
  if (!this.token && options.channelId !== void 0) {
1587
1679
  body.channel_id = options.channelId;
1588
1680
  }
1589
- const data = this.token ? await this.client.rest.patch(import_types11.Routes.webhookExecute(this.id, this.token), {
1681
+ const data = this.token ? await this.client.rest.patch(import_types12.Routes.webhookExecute(this.id, this.token), {
1590
1682
  body,
1591
1683
  auth: false
1592
- }) : await this.client.rest.patch(import_types11.Routes.webhook(this.id), { body, auth: true });
1684
+ }) : await this.client.rest.patch(import_types12.Routes.webhook(this.id), { body, auth: true });
1593
1685
  this.name = data.name ?? this.name;
1594
1686
  this.avatar = data.avatar ?? null;
1595
1687
  if (!this.token) this.channelId = data.channel_id ?? this.channelId;
@@ -1610,7 +1702,7 @@ var Webhook = class _Webhook extends Base {
1610
1702
  if (overrides.avatarUrl !== void 0) {
1611
1703
  body.avatar_url = overrides.avatarUrl;
1612
1704
  }
1613
- const route = `${import_types11.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1705
+ const route = `${import_types12.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1614
1706
  const data = await this.client.rest.post(route, {
1615
1707
  body,
1616
1708
  ...files?.length ? { files } : {},
@@ -1651,7 +1743,7 @@ var Webhook = class _Webhook extends Base {
1651
1743
  }
1652
1744
  /** Fetch a webhook by ID (bot auth; no token). */
1653
1745
  static async fetch(client, webhookId) {
1654
- const data = await client.rest.get(import_types11.Routes.webhook(webhookId));
1746
+ const data = await client.rest.get(import_types12.Routes.webhook(webhookId));
1655
1747
  return new _Webhook(client, data);
1656
1748
  }
1657
1749
  /** Build a webhook from a stored id + token (e.g. webhook URL). */
@@ -1676,12 +1768,12 @@ var Webhook = class _Webhook extends Base {
1676
1768
  return this.token;
1677
1769
  }
1678
1770
  messageRoute(messageId) {
1679
- return import_types11.Routes.webhookMessage(this.id, this.requireToken(), messageId);
1771
+ return import_types12.Routes.webhookMessage(this.id, this.requireToken(), messageId);
1680
1772
  }
1681
1773
  };
1682
1774
 
1683
1775
  // src/structures/channel/textCapable.ts
1684
- var import_types12 = require("@fluxerjs/types");
1776
+ var import_types13 = require("@fluxerjs/types");
1685
1777
 
1686
1778
  // src/util/MessageCollector.ts
1687
1779
  var import_events2 = require("events");
@@ -1742,7 +1834,7 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
1742
1834
  if (options?.before) params.set("before", options.before);
1743
1835
  const qs2 = params.toString();
1744
1836
  const data = await client.rest.get(
1745
- import_types12.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1837
+ import_types13.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1746
1838
  );
1747
1839
  const items = data.items ?? [];
1748
1840
  return {
@@ -1758,7 +1850,7 @@ function TextCapable(Base2) {
1758
1850
  const payload = await prepareMessagePostPayload(options, {
1759
1851
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
1760
1852
  });
1761
- const data = await this.client.rest.post(import_types12.Routes.channelMessages(this.id), payload);
1853
+ const data = await this.client.rest.post(import_types13.Routes.channelMessages(this.id), payload);
1762
1854
  this.client._addMessageToCache(this.id, data);
1763
1855
  return new Message(this.client, data);
1764
1856
  }
@@ -1815,7 +1907,7 @@ var GuildChannel = class extends Channel {
1815
1907
  }
1816
1908
  /** Create a webhook for this channel. Requires Manage Webhooks. */
1817
1909
  async createWebhook(options) {
1818
- const data = await this.client.rest.post(import_types13.Routes.channelWebhooks(this.id), {
1910
+ const data = await this.client.rest.post(import_types14.Routes.channelWebhooks(this.id), {
1819
1911
  body: options,
1820
1912
  auth: true
1821
1913
  });
@@ -1823,13 +1915,13 @@ var GuildChannel = class extends Channel {
1823
1915
  }
1824
1916
  /** Fetch all webhooks in this channel. Requires Manage Webhooks. */
1825
1917
  async fetchWebhooks() {
1826
- const data = await this.client.rest.get(import_types13.Routes.channelWebhooks(this.id));
1918
+ const data = await this.client.rest.get(import_types14.Routes.channelWebhooks(this.id));
1827
1919
  return data.map((w) => new Webhook(this.client, w));
1828
1920
  }
1829
1921
  /** Create an invite for this channel. Requires Create Instant Invite. */
1830
1922
  async createInvite(options) {
1831
1923
  const body = options ? toChannelInviteBody(options) : {};
1832
- const data = await this.client.rest.post(import_types13.Routes.channelInvites(this.id), {
1924
+ const data = await this.client.rest.post(import_types14.Routes.channelInvites(this.id), {
1833
1925
  body: Object.keys(body).length ? body : void 0,
1834
1926
  auth: true
1835
1927
  });
@@ -1837,12 +1929,12 @@ var GuildChannel = class extends Channel {
1837
1929
  }
1838
1930
  /** Fetch all invites for this channel. Requires Manage Channels. */
1839
1931
  async fetchInvites() {
1840
- const data = await this.client.rest.get(import_types13.Routes.channelInvites(this.id));
1932
+ const data = await this.client.rest.get(import_types14.Routes.channelInvites(this.id));
1841
1933
  return data.map((i) => new Invite(this.client, i));
1842
1934
  }
1843
1935
  /** Edit or create a permission overwrite. Requires Manage Roles. */
1844
1936
  async editPermission(overwriteId, options) {
1845
- await this.client.rest.put(import_types13.Routes.channelPermission(this.id, overwriteId), {
1937
+ await this.client.rest.put(import_types14.Routes.channelPermission(this.id, overwriteId), {
1846
1938
  body: options,
1847
1939
  auth: true
1848
1940
  });
@@ -1858,7 +1950,7 @@ var GuildChannel = class extends Channel {
1858
1950
  }
1859
1951
  /** Delete a permission overwrite. Requires Manage Roles. */
1860
1952
  async deletePermission(overwriteId) {
1861
- await this.client.rest.delete(import_types13.Routes.channelPermission(this.id, overwriteId), { auth: true });
1953
+ await this.client.rest.delete(import_types14.Routes.channelPermission(this.id, overwriteId), { auth: true });
1862
1954
  const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
1863
1955
  if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
1864
1956
  }
@@ -1871,7 +1963,7 @@ var GuildChannel = class extends Channel {
1871
1963
  }
1872
1964
  /** Edit this channel's settings. Requires Manage Channels. */
1873
1965
  async edit(options) {
1874
- const data = await this.client.rest.patch(import_types13.Routes.channel(this.id), {
1966
+ const data = await this.client.rest.patch(import_types14.Routes.channel(this.id), {
1875
1967
  body: toChannelEditBody(options),
1876
1968
  auth: true
1877
1969
  });
@@ -1891,7 +1983,7 @@ var GuildChannel = class extends Channel {
1891
1983
  const qs2 = params.toString();
1892
1984
  const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
1893
1985
  const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
1894
- await this.client.rest.delete(import_types13.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1986
+ await this.client.rest.delete(import_types14.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1895
1987
  body,
1896
1988
  auth: true
1897
1989
  });
@@ -1953,7 +2045,7 @@ var LinkChannel = class extends GuildChannel {
1953
2045
  };
1954
2046
 
1955
2047
  // src/structures/channel/dm.ts
1956
- var import_types14 = require("@fluxerjs/types");
2048
+ var import_types15 = require("@fluxerjs/types");
1957
2049
  var DMChannel = class extends TextCapable(Channel) {
1958
2050
  /** ID of the last message sent in this channel. */
1959
2051
  lastMessageId;
@@ -1973,34 +2065,34 @@ var DMChannel = class extends TextCapable(Channel) {
1973
2065
  }
1974
2066
  /** Purge all messages from personal notes. Only works on personal notes channels. */
1975
2067
  async purgeMessages() {
1976
- if (this.type !== import_types14.ChannelType.DMPersonalNotes) {
2068
+ if (this.type !== import_types15.ChannelType.DMPersonalNotes) {
1977
2069
  throw new import_util.FluxerError("purgeMessages is only available on personal notes channels", {
1978
2070
  code: import_util2.ErrorCodes.InvalidChannelType
1979
2071
  });
1980
2072
  }
1981
2073
  const data = await this.client.rest.post(
1982
- import_types14.Routes.channelMessagesPurge(this.id),
2074
+ import_types15.Routes.channelMessagesPurge(this.id),
1983
2075
  { auth: true }
1984
2076
  );
1985
2077
  return data.deleted_count;
1986
2078
  }
1987
2079
  /** Pin this DM channel to the top of the DM list. */
1988
2080
  async pinInList() {
1989
- await this.client.rest.put(import_types14.Routes.userMeChannelPin(this.id), { auth: true });
2081
+ await this.client.rest.put(import_types15.Routes.userMeChannelPin(this.id), { auth: true });
1990
2082
  }
1991
2083
  /** Unpin this DM channel from the DM list. */
1992
2084
  async unpinFromList() {
1993
- await this.client.rest.delete(import_types14.Routes.userMeChannelPin(this.id), { auth: true });
2085
+ await this.client.rest.delete(import_types15.Routes.userMeChannelPin(this.id), { auth: true });
1994
2086
  }
1995
2087
  /** Add a user to this group DM. */
1996
2088
  async addRecipient(userId) {
1997
- await this.client.rest.put(import_types14.Routes.channelRecipient(this.id, userId), { auth: true });
2089
+ await this.client.rest.put(import_types15.Routes.channelRecipient(this.id, userId), { auth: true });
1998
2090
  const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
1999
2091
  if (user) this.recipients.push(user);
2000
2092
  }
2001
2093
  /** Remove a user from this group DM. */
2002
2094
  async removeRecipient(userId, options) {
2003
- const url = import_types14.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2095
+ const url = import_types15.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2004
2096
  await this.client.rest.delete(url, { auth: true });
2005
2097
  const idx = this.recipients.findIndex((u) => u.id === userId);
2006
2098
  if (idx >= 0) this.recipients.splice(idx, 1);
@@ -2008,17 +2100,17 @@ var DMChannel = class extends TextCapable(Channel) {
2008
2100
  };
2009
2101
 
2010
2102
  // src/structures/channel/factory.ts
2011
- var import_types15 = require("@fluxerjs/types");
2103
+ var import_types16 = require("@fluxerjs/types");
2012
2104
  var GUILD_FACTORIES = {
2013
- [import_types15.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
2014
- [import_types15.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
2015
- [import_types15.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
2016
- [import_types15.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d)
2105
+ [import_types16.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
2106
+ [import_types16.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
2107
+ [import_types16.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
2108
+ [import_types16.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d)
2017
2109
  };
2018
2110
  var DM_TYPES = /* @__PURE__ */ new Set([
2019
- import_types15.ChannelType.DM,
2020
- import_types15.ChannelType.GroupDM,
2021
- import_types15.ChannelType.DMPersonalNotes
2111
+ import_types16.ChannelType.DM,
2112
+ import_types16.ChannelType.GroupDM,
2113
+ import_types16.ChannelType.DMPersonalNotes
2022
2114
  ]);
2023
2115
  function createDM(client, data) {
2024
2116
  return new DMChannel(client, data);
@@ -2038,8 +2130,8 @@ Channel.createDM = createDM;
2038
2130
 
2039
2131
  // src/client/ChannelManager.ts
2040
2132
  function rethrowNotFound(err, message, code) {
2041
- if (err instanceof import_rest3.RateLimitError) throw err;
2042
- if (err instanceof import_rest3.FluxerAPIError && err.statusCode === 404) {
2133
+ if (err instanceof import_rest4.RateLimitError) throw err;
2134
+ if (err instanceof import_rest4.FluxerAPIError && err.statusCode === 404) {
2043
2135
  throw new import_util.FluxerError(message, { code, cause: err });
2044
2136
  }
2045
2137
  throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
@@ -2071,7 +2163,7 @@ var ChannelManager = class extends import_collection5.Collection {
2071
2163
  const cached = this.get(channelId);
2072
2164
  if (cached) return cached;
2073
2165
  try {
2074
- const data = await this.client.rest.get(import_types16.Routes.channel(channelId));
2166
+ const data = await this.client.rest.get(import_types17.Routes.channel(channelId));
2075
2167
  const channel = Channel.fromOrCreate(this.client, data);
2076
2168
  if (!channel) {
2077
2169
  throw new import_util.FluxerError("Channel data invalid or unsupported type", {
@@ -2104,7 +2196,7 @@ var ChannelManager = class extends import_collection5.Collection {
2104
2196
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
2105
2197
  });
2106
2198
  const data = await this.client.rest.post(
2107
- import_types16.Routes.channelMessages(channelId),
2199
+ import_types17.Routes.channelMessages(channelId),
2108
2200
  postPayload
2109
2201
  );
2110
2202
  this.client._addMessageToCache(channelId, data);
@@ -2114,29 +2206,29 @@ var ChannelManager = class extends import_collection5.Collection {
2114
2206
 
2115
2207
  // src/client/GuildManager.ts
2116
2208
  var import_collection9 = require("@fluxerjs/collection");
2117
- var import_types36 = require("@fluxerjs/types");
2118
- var import_rest5 = require("@fluxerjs/rest");
2209
+ var import_types37 = require("@fluxerjs/types");
2210
+ var import_rest6 = require("@fluxerjs/rest");
2119
2211
 
2120
2212
  // src/structures/guild/Guild.ts
2121
2213
  var import_collection8 = require("@fluxerjs/collection");
2122
- var import_types35 = require("@fluxerjs/types");
2214
+ var import_types36 = require("@fluxerjs/types");
2123
2215
 
2124
2216
  // src/client/GuildMemberManager.ts
2125
2217
  var import_collection7 = require("@fluxerjs/collection");
2126
- var import_types20 = require("@fluxerjs/types");
2218
+ var import_types21 = require("@fluxerjs/types");
2127
2219
 
2128
2220
  // src/structures/GuildMember.ts
2129
- var import_types19 = require("@fluxerjs/types");
2221
+ var import_types20 = require("@fluxerjs/types");
2130
2222
  var import_util5 = require("@fluxerjs/util");
2131
2223
 
2132
2224
  // src/util/permissions.ts
2133
- var import_types17 = require("@fluxerjs/types");
2225
+ var import_types18 = require("@fluxerjs/types");
2134
2226
  var import_util4 = require("@fluxerjs/util");
2135
2227
  function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
2136
2228
  if (isOwner) return import_util4.ALL_PERMISSIONS_BIGINT;
2137
2229
  let perms = basePermissions;
2138
2230
  for (const overwrite of overwrites ?? []) {
2139
- const applies = overwrite.type === import_types17.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types17.OverwriteType.Member && overwrite.id === memberId;
2231
+ const applies = overwrite.type === import_types18.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types18.OverwriteType.Member && overwrite.id === memberId;
2140
2232
  if (!applies) continue;
2141
2233
  const allow = BigInt(overwrite.allow || "0");
2142
2234
  const deny = BigInt(overwrite.deny || "0");
@@ -2147,7 +2239,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
2147
2239
 
2148
2240
  // src/structures/GuildMemberRoleManager.ts
2149
2241
  var import_collection6 = require("@fluxerjs/collection");
2150
- var import_types18 = require("@fluxerjs/types");
2242
+ var import_types19 = require("@fluxerjs/types");
2151
2243
  function roleId(roleOrId) {
2152
2244
  return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
2153
2245
  }
@@ -2176,7 +2268,7 @@ var GuildMemberRoleManager = class {
2176
2268
  const id = roleId(roleOrId);
2177
2269
  if (this.ids.includes(id)) return;
2178
2270
  await this.member.client.rest.put(
2179
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2271
+ import_types19.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2180
2272
  );
2181
2273
  this.ids.push(id);
2182
2274
  }
@@ -2185,13 +2277,13 @@ var GuildMemberRoleManager = class {
2185
2277
  const idx = this.ids.indexOf(id);
2186
2278
  if (idx === -1) return;
2187
2279
  await this.member.client.rest.delete(
2188
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2280
+ import_types19.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2189
2281
  );
2190
2282
  this.ids.splice(idx, 1);
2191
2283
  }
2192
2284
  async set(roleIds) {
2193
2285
  const data = await this.member.client.rest.patch(
2194
- import_types18.Routes.guildMember(this.member.guild.id, this.member.id),
2286
+ import_types19.Routes.guildMember(this.member.guild.id, this.member.id),
2195
2287
  { body: { roles: roleIds }, auth: true }
2196
2288
  );
2197
2289
  this.ids = data.roles ? [...data.roles] : [];
@@ -2318,7 +2410,7 @@ var GuildMember = class _GuildMember extends Base {
2318
2410
  /** PATCH member (`/members/@me` when editing the bot). */
2319
2411
  async edit(options) {
2320
2412
  const isMe = this.client.user?.id === this.id;
2321
- const route = isMe ? import_types19.Routes.guildMemberMe(this.guild.id) : import_types19.Routes.guildMember(this.guild.id, this.id);
2413
+ const route = isMe ? import_types20.Routes.guildMemberMe(this.guild.id) : import_types20.Routes.guildMember(this.guild.id, this.id);
2322
2414
  const data = await this.client.rest.patch(route, {
2323
2415
  body: toMemberEditBody(options),
2324
2416
  auth: true
@@ -2447,7 +2539,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2447
2539
  if (options?.limit != null) params.set("limit", String(options.limit));
2448
2540
  if (options?.after) params.set("after", options.after);
2449
2541
  const qs2 = params.toString();
2450
- const url = import_types20.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2542
+ const url = import_types21.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2451
2543
  const data = await this.guild.client.rest.get(url, { auth: true });
2452
2544
  const members = [];
2453
2545
  for (const m of data) {
@@ -2470,7 +2562,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2470
2562
  */
2471
2563
  async search(options = {}) {
2472
2564
  const data = await this.guild.client.rest.post(
2473
- import_types20.Routes.guildMembersSearch(this.guild.id),
2565
+ import_types21.Routes.guildMembersSearch(this.guild.id),
2474
2566
  { body: toMemberSearchBody(options), auth: true }
2475
2567
  );
2476
2568
  const offset = options.offset ?? 0;
@@ -2496,7 +2588,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2496
2588
  };
2497
2589
 
2498
2590
  // src/structures/Role.ts
2499
- var import_types21 = require("@fluxerjs/types");
2591
+ var import_types22 = require("@fluxerjs/types");
2500
2592
  var import_util7 = require("@fluxerjs/util");
2501
2593
 
2502
2594
  // src/structures/roleOptions.ts
@@ -2609,7 +2701,7 @@ var Role = class _Role extends Base {
2609
2701
  */
2610
2702
  async edit(options) {
2611
2703
  const body = toRoleRequestBody(options);
2612
- const data = await this.client.rest.patch(import_types21.Routes.guildRole(this.guildId, this.id), {
2704
+ const data = await this.client.rest.patch(import_types22.Routes.guildRole(this.guildId, this.id), {
2613
2705
  body: Object.keys(body).length ? body : void 0,
2614
2706
  auth: true
2615
2707
  });
@@ -2620,18 +2712,18 @@ var Role = class _Role extends Base {
2620
2712
  * DELETE role. Requires Manage Roles.
2621
2713
  */
2622
2714
  async delete() {
2623
- await this.client.rest.delete(import_types21.Routes.guildRole(this.guildId, this.id), { auth: true });
2715
+ await this.client.rest.delete(import_types22.Routes.guildRole(this.guildId, this.id), { auth: true });
2624
2716
  this.client.guilds.get(this.guildId)?.roles.delete(this.id);
2625
2717
  }
2626
2718
  };
2627
2719
 
2628
2720
  // src/structures/guild/admin.ts
2629
- var import_types22 = require("@fluxerjs/types");
2721
+ var import_types23 = require("@fluxerjs/types");
2630
2722
 
2631
2723
  // src/structures/guild/http.ts
2632
- var import_rest4 = require("@fluxerjs/rest");
2724
+ var import_rest5 = require("@fluxerjs/rest");
2633
2725
  function httpStatus(err) {
2634
- if (err instanceof import_rest4.FluxerAPIError) return err.statusCode;
2726
+ if (err instanceof import_rest5.FluxerAPIError) return err.statusCode;
2635
2727
  if (typeof err === "object" && err !== null && "statusCode" in err) {
2636
2728
  const code = err.statusCode;
2637
2729
  return typeof code === "number" ? code : void 0;
@@ -2731,7 +2823,7 @@ function toVanityPayload(data) {
2731
2823
  return { code: data.code ?? null, uses: data.uses };
2732
2824
  }
2733
2825
  async function fetchAuditLogs(guild, options) {
2734
- const url = import_types22.Routes.guildAuditLogs(guild.id) + qs({
2826
+ const url = import_types23.Routes.guildAuditLogs(guild.id) + qs({
2735
2827
  limit: options?.limit,
2736
2828
  before: options?.before,
2737
2829
  after: options?.after,
@@ -2752,7 +2844,7 @@ async function fetchAuditLogs(guild, options) {
2752
2844
  };
2753
2845
  }
2754
2846
  async function editGuild(guild, options) {
2755
- const data = await guild.client.rest.patch(import_types22.Routes.guild(guild.id), {
2847
+ const data = await guild.client.rest.patch(import_types23.Routes.guild(guild.id), {
2756
2848
  body: toGuildEditBody(options),
2757
2849
  auth: true
2758
2850
  });
@@ -2760,13 +2852,13 @@ async function editGuild(guild, options) {
2760
2852
  return guild;
2761
2853
  }
2762
2854
  async function fetchVanityURL(guild) {
2763
- const data = await guild.client.rest.get(import_types22.Routes.guildVanityUrl(guild.id), {
2855
+ const data = await guild.client.rest.get(import_types23.Routes.guildVanityUrl(guild.id), {
2764
2856
  auth: true
2765
2857
  });
2766
2858
  return toVanityPayload(data);
2767
2859
  }
2768
2860
  async function editVanityURL(guild, code) {
2769
- const data = await guild.client.rest.patch(import_types22.Routes.guildVanityUrl(guild.id), {
2861
+ const data = await guild.client.rest.patch(import_types23.Routes.guildVanityUrl(guild.id), {
2770
2862
  body: { code },
2771
2863
  auth: true
2772
2864
  });
@@ -2774,14 +2866,14 @@ async function editVanityURL(guild, code) {
2774
2866
  return toVanityPayload(data);
2775
2867
  }
2776
2868
  async function fetchDiscoveryStatus(guild) {
2777
- const data = await guild.client.rest.get(import_types22.Routes.guildDiscovery(guild.id), {
2869
+ const data = await guild.client.rest.get(import_types23.Routes.guildDiscovery(guild.id), {
2778
2870
  auth: true
2779
2871
  });
2780
2872
  return toDiscoveryStatusPayload(data);
2781
2873
  }
2782
2874
  async function applyForDiscovery(guild, options) {
2783
2875
  const data = await guild.client.rest.post(
2784
- import_types22.Routes.guildDiscovery(guild.id),
2876
+ import_types23.Routes.guildDiscovery(guild.id),
2785
2877
  {
2786
2878
  body: toDiscoveryBody(options),
2787
2879
  auth: true
@@ -2791,7 +2883,7 @@ async function applyForDiscovery(guild, options) {
2791
2883
  }
2792
2884
  async function editDiscoveryApplication(guild, options) {
2793
2885
  const data = await guild.client.rest.patch(
2794
- import_types22.Routes.guildDiscovery(guild.id),
2886
+ import_types23.Routes.guildDiscovery(guild.id),
2795
2887
  {
2796
2888
  body: toDiscoveryBody(options),
2797
2889
  auth: true
@@ -2800,28 +2892,28 @@ async function editDiscoveryApplication(guild, options) {
2800
2892
  return toDiscoveryApplicationPayload(data);
2801
2893
  }
2802
2894
  async function withdrawDiscoveryApplication(guild) {
2803
- await guild.client.rest.delete(import_types22.Routes.guildDiscovery(guild.id), { auth: true });
2895
+ await guild.client.rest.delete(import_types23.Routes.guildDiscovery(guild.id), { auth: true });
2804
2896
  }
2805
2897
  async function deleteGuild(guild, options) {
2806
2898
  const body = options ? toSudoBody(options) : {};
2807
- await guild.client.rest.post(import_types22.Routes.guildDelete(guild.id), {
2899
+ await guild.client.rest.post(import_types23.Routes.guildDelete(guild.id), {
2808
2900
  body,
2809
2901
  auth: true
2810
2902
  });
2811
2903
  guild.client.guilds.delete(guild.id);
2812
2904
  }
2813
2905
  async function transferOwnership(guild, newOwnerId, password) {
2814
- await guild.client.rest.post(import_types22.Routes.guildTransferOwnership(guild.id), {
2906
+ await guild.client.rest.post(import_types23.Routes.guildTransferOwnership(guild.id), {
2815
2907
  body: { new_owner_id: newOwnerId, ...password != null && { password } },
2816
2908
  auth: true
2817
2909
  });
2818
2910
  }
2819
2911
 
2820
2912
  // src/structures/guild/channels.ts
2821
- var import_types26 = require("@fluxerjs/types");
2913
+ var import_types27 = require("@fluxerjs/types");
2822
2914
 
2823
2915
  // src/structures/GuildEmoji.ts
2824
- var import_types24 = require("@fluxerjs/types");
2916
+ var import_types25 = require("@fluxerjs/types");
2825
2917
  var GuildEmoji = class extends Base {
2826
2918
  client;
2827
2919
  id;
@@ -2849,7 +2941,7 @@ var GuildEmoji = class extends Base {
2849
2941
  }
2850
2942
  /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
2851
2943
  async delete() {
2852
- await this.client.rest.delete(import_types24.Routes.guildEmoji(this.guildId, this.id), {
2944
+ await this.client.rest.delete(import_types25.Routes.guildEmoji(this.guildId, this.id), {
2853
2945
  auth: true
2854
2946
  });
2855
2947
  const guild = this.client.guilds.get(this.guildId);
@@ -2860,7 +2952,7 @@ var GuildEmoji = class extends Base {
2860
2952
  * Requires Manage Emojis and Stickers permission.
2861
2953
  */
2862
2954
  async edit(options) {
2863
- const data = await this.client.rest.patch(import_types24.Routes.guildEmoji(this.guildId, this.id), {
2955
+ const data = await this.client.rest.patch(import_types25.Routes.guildEmoji(this.guildId, this.id), {
2864
2956
  body: options,
2865
2957
  auth: true
2866
2958
  });
@@ -2870,7 +2962,7 @@ var GuildEmoji = class extends Base {
2870
2962
  };
2871
2963
 
2872
2964
  // src/structures/GuildSticker.ts
2873
- var import_types25 = require("@fluxerjs/types");
2965
+ var import_types26 = require("@fluxerjs/types");
2874
2966
  var GuildSticker = class extends Base {
2875
2967
  client;
2876
2968
  id;
@@ -2901,7 +2993,7 @@ var GuildSticker = class extends Base {
2901
2993
  }
2902
2994
  /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
2903
2995
  async delete() {
2904
- await this.client.rest.delete(import_types25.Routes.guildSticker(this.guildId, this.id), {
2996
+ await this.client.rest.delete(import_types26.Routes.guildSticker(this.guildId, this.id), {
2905
2997
  auth: true
2906
2998
  });
2907
2999
  }
@@ -2910,7 +3002,7 @@ var GuildSticker = class extends Base {
2910
3002
  * Requires Manage Emojis and Stickers permission.
2911
3003
  */
2912
3004
  async edit(options) {
2913
- const data = await this.client.rest.patch(import_types25.Routes.guildSticker(this.guildId, this.id), {
3005
+ const data = await this.client.rest.patch(import_types26.Routes.guildSticker(this.guildId, this.id), {
2914
3006
  body: options,
2915
3007
  auth: true
2916
3008
  });
@@ -2965,14 +3057,14 @@ function cacheSticker(guild, data) {
2965
3057
 
2966
3058
  // src/structures/guild/channels.ts
2967
3059
  async function createChannel(guild, data) {
2968
- const created = await guild.client.rest.post(import_types26.Routes.guildChannels(guild.id), {
3060
+ const created = await guild.client.rest.post(import_types27.Routes.guildChannels(guild.id), {
2969
3061
  body: data,
2970
3062
  auth: true
2971
3063
  });
2972
3064
  return cacheChannel(guild, created);
2973
3065
  }
2974
3066
  async function fetchChannels(guild) {
2975
- const data = await guild.client.rest.get(import_types26.Routes.guildChannels(guild.id));
3067
+ const data = await guild.client.rest.get(import_types27.Routes.guildChannels(guild.id));
2976
3068
  const channels = [];
2977
3069
  for (const ch of data) {
2978
3070
  const channel = cacheChannel(guild, ch);
@@ -2981,17 +3073,17 @@ async function fetchChannels(guild) {
2981
3073
  return channels;
2982
3074
  }
2983
3075
  async function setChannelPositions(guild, updates) {
2984
- await guild.client.rest.patch(import_types26.Routes.guildChannels(guild.id), {
3076
+ await guild.client.rest.patch(import_types27.Routes.guildChannels(guild.id), {
2985
3077
  body: toChannelPositionBody(updates),
2986
3078
  auth: true
2987
3079
  });
2988
3080
  }
2989
3081
  async function fetchWebhooks(guild) {
2990
- const data = await guild.client.rest.get(import_types26.Routes.guildWebhooks(guild.id));
3082
+ const data = await guild.client.rest.get(import_types27.Routes.guildWebhooks(guild.id));
2991
3083
  return data.map((w) => new Webhook(guild.client, w));
2992
3084
  }
2993
3085
  async function fetchInvites(guild) {
2994
- const data = await guild.client.rest.get(import_types26.Routes.guildInvites(guild.id));
3086
+ const data = await guild.client.rest.get(import_types27.Routes.guildInvites(guild.id));
2995
3087
  return data.map((invite) => new Invite(guild.client, invite));
2996
3088
  }
2997
3089
  async function fetchInvite(guild, codeOrUrl) {
@@ -2999,14 +3091,14 @@ async function fetchInvite(guild, codeOrUrl) {
2999
3091
  }
3000
3092
 
3001
3093
  // src/structures/guild/emojis.ts
3002
- var import_types28 = require("@fluxerjs/types");
3094
+ var import_types29 = require("@fluxerjs/types");
3003
3095
  async function fetchEmojis(guild) {
3004
- const data = await guild.client.rest.get(import_types28.Routes.guildEmojis(guild.id));
3096
+ const data = await guild.client.rest.get(import_types29.Routes.guildEmojis(guild.id));
3005
3097
  return data.map((e) => cacheEmoji(guild, e));
3006
3098
  }
3007
3099
  async function fetchEmoji(guild, emojiId) {
3008
3100
  try {
3009
- const data = await guild.client.rest.get(import_types28.Routes.guildEmoji(guild.id, emojiId));
3101
+ const data = await guild.client.rest.get(import_types29.Routes.guildEmoji(guild.id, emojiId));
3010
3102
  return cacheEmoji(guild, data);
3011
3103
  } catch (err) {
3012
3104
  rethrowNotFound2(
@@ -3017,14 +3109,14 @@ async function fetchEmoji(guild, emojiId) {
3017
3109
  }
3018
3110
  }
3019
3111
  async function createEmoji(guild, options) {
3020
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojis(guild.id), {
3112
+ const data = await guild.client.rest.post(import_types29.Routes.guildEmojis(guild.id), {
3021
3113
  body: options,
3022
3114
  auth: true
3023
3115
  });
3024
3116
  return cacheEmoji(guild, data);
3025
3117
  }
3026
3118
  async function cloneEmoji(guild, sourceEmojiId) {
3027
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojisClone(guild.id), {
3119
+ const data = await guild.client.rest.post(import_types29.Routes.guildEmojisClone(guild.id), {
3028
3120
  body: { source_emoji_id: sourceEmojiId },
3029
3121
  auth: true
3030
3122
  });
@@ -3032,18 +3124,18 @@ async function cloneEmoji(guild, sourceEmojiId) {
3032
3124
  }
3033
3125
  async function createEmojisBulk(guild, emojis) {
3034
3126
  const data = await guild.client.rest.post(
3035
- import_types28.Routes.guildEmojisBulk(guild.id),
3127
+ import_types29.Routes.guildEmojisBulk(guild.id),
3036
3128
  { body: { emojis }, auth: true }
3037
3129
  );
3038
3130
  return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
3039
3131
  }
3040
3132
 
3041
3133
  // src/structures/guild/members.ts
3042
- var import_types29 = require("@fluxerjs/types");
3134
+ var import_types30 = require("@fluxerjs/types");
3043
3135
  async function fetchMember(guild, userId) {
3044
3136
  try {
3045
3137
  const data = await guild.client.rest.get(
3046
- import_types29.Routes.guildMember(guild.id, userId)
3138
+ import_types30.Routes.guildMember(guild.id, userId)
3047
3139
  );
3048
3140
  return cacheMember(guild, data);
3049
3141
  } catch (err) {
@@ -3056,17 +3148,17 @@ async function fetchMember(guild, userId) {
3056
3148
  }
3057
3149
  async function fetchMe(guild) {
3058
3150
  const data = await guild.client.rest.get(
3059
- import_types29.Routes.guildMemberMe(guild.id),
3151
+ import_types30.Routes.guildMemberMe(guild.id),
3060
3152
  { auth: true }
3061
3153
  );
3062
3154
  return cacheMember(guild, data);
3063
3155
  }
3064
3156
 
3065
3157
  // src/structures/guild/moderation.ts
3066
- var import_types31 = require("@fluxerjs/types");
3158
+ var import_types32 = require("@fluxerjs/types");
3067
3159
 
3068
3160
  // src/structures/GuildBan.ts
3069
- var import_types30 = require("@fluxerjs/types");
3161
+ var import_types31 = require("@fluxerjs/types");
3070
3162
  var GuildBan = class extends Base {
3071
3163
  client;
3072
3164
  guildId;
@@ -3088,7 +3180,7 @@ var GuildBan = class extends Base {
3088
3180
  * Requires Ban Members permission.
3089
3181
  */
3090
3182
  async unban() {
3091
- await this.client.rest.delete(import_types30.Routes.guildBan(this.guildId, this.user.id), {
3183
+ await this.client.rest.delete(import_types31.Routes.guildBan(this.guildId, this.user.id), {
3092
3184
  auth: true
3093
3185
  });
3094
3186
  }
@@ -3097,40 +3189,40 @@ var GuildBan = class extends Base {
3097
3189
  // src/structures/guild/moderation.ts
3098
3190
  async function ban(guild, userId, options) {
3099
3191
  const body = options ? toGuildBanBody(options) : {};
3100
- await guild.client.rest.put(import_types31.Routes.guildBan(guild.id, userId), {
3192
+ await guild.client.rest.put(import_types32.Routes.guildBan(guild.id, userId), {
3101
3193
  body: Object.keys(body).length ? body : void 0,
3102
3194
  auth: true
3103
3195
  });
3104
3196
  }
3105
3197
  async function fetchBans(guild) {
3106
- const data = await guild.client.rest.get(import_types31.Routes.guildBans(guild.id));
3198
+ const data = await guild.client.rest.get(import_types32.Routes.guildBans(guild.id));
3107
3199
  return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
3108
3200
  }
3109
3201
  async function unban(guild, userId) {
3110
- await guild.client.rest.delete(import_types31.Routes.guildBan(guild.id, userId), { auth: true });
3202
+ await guild.client.rest.delete(import_types32.Routes.guildBan(guild.id, userId), { auth: true });
3111
3203
  }
3112
3204
  async function kick(guild, userId) {
3113
- await guild.client.rest.delete(import_types31.Routes.guildMember(guild.id, userId), { auth: true });
3205
+ await guild.client.rest.delete(import_types32.Routes.guildMember(guild.id, userId), { auth: true });
3114
3206
  }
3115
3207
 
3116
3208
  // src/structures/guild/roles.ts
3117
- var import_types33 = require("@fluxerjs/types");
3209
+ var import_types34 = require("@fluxerjs/types");
3118
3210
  var import_util8 = require("@fluxerjs/util");
3119
3211
  async function createRole(guild, options = {}) {
3120
3212
  const body = toRoleRequestBody(options);
3121
- const data = await guild.client.rest.post(import_types33.Routes.guildRoles(guild.id), {
3213
+ const data = await guild.client.rest.post(import_types34.Routes.guildRoles(guild.id), {
3122
3214
  body: Object.keys(body).length ? body : void 0,
3123
3215
  auth: true
3124
3216
  });
3125
3217
  return cacheRole(guild, data);
3126
3218
  }
3127
3219
  async function fetchRoles(guild) {
3128
- const data = await guild.client.rest.get(import_types33.Routes.guildRoles(guild.id));
3220
+ const data = await guild.client.rest.get(import_types34.Routes.guildRoles(guild.id));
3129
3221
  return data.map((r) => cacheRole(guild, r));
3130
3222
  }
3131
3223
  async function fetchRole(guild, roleId2) {
3132
3224
  try {
3133
- const data = await guild.client.rest.get(import_types33.Routes.guildRole(guild.id, roleId2));
3225
+ const data = await guild.client.rest.get(import_types34.Routes.guildRole(guild.id, roleId2));
3134
3226
  return cacheRole(guild, data);
3135
3227
  } catch (err) {
3136
3228
  rethrowNotFound2(
@@ -3148,7 +3240,7 @@ async function resolveRoleId(guild, arg) {
3148
3240
  const needle = trimmed.toLowerCase();
3149
3241
  const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
3150
3242
  if (cached) return cached.id;
3151
- const roles = await guild.client.rest.get(import_types33.Routes.guildRoles(guild.id));
3243
+ const roles = await guild.client.rest.get(import_types34.Routes.guildRoles(guild.id));
3152
3244
  const role = roles.find((r) => r.name?.toLowerCase() === needle);
3153
3245
  if (!role) return null;
3154
3246
  cacheRole(guild, role);
@@ -3157,7 +3249,7 @@ async function resolveRoleId(guild, arg) {
3157
3249
  async function setRolePositions(guild, updates) {
3158
3250
  return replaceRoles(
3159
3251
  guild,
3160
- await guild.client.rest.patch(import_types33.Routes.guildRoles(guild.id), {
3252
+ await guild.client.rest.patch(import_types34.Routes.guildRoles(guild.id), {
3161
3253
  body: updates,
3162
3254
  auth: true
3163
3255
  })
@@ -3166,7 +3258,7 @@ async function setRolePositions(guild, updates) {
3166
3258
  async function setRoleHoistPositions(guild, updates) {
3167
3259
  return replaceRoles(
3168
3260
  guild,
3169
- await guild.client.rest.patch(import_types33.Routes.guildRolesHoistPositions(guild.id), {
3261
+ await guild.client.rest.patch(import_types34.Routes.guildRolesHoistPositions(guild.id), {
3170
3262
  body: updates.map((u) => ({
3171
3263
  id: u.id,
3172
3264
  ...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
@@ -3178,23 +3270,23 @@ async function setRoleHoistPositions(guild, updates) {
3178
3270
  async function resetRoleHoistPositions(guild) {
3179
3271
  return replaceRoles(
3180
3272
  guild,
3181
- await guild.client.rest.delete(import_types33.Routes.guildRolesHoistPositions(guild.id), {
3273
+ await guild.client.rest.delete(import_types34.Routes.guildRolesHoistPositions(guild.id), {
3182
3274
  auth: true
3183
3275
  })
3184
3276
  );
3185
3277
  }
3186
3278
 
3187
3279
  // src/structures/guild/stickers.ts
3188
- var import_types34 = require("@fluxerjs/types");
3280
+ var import_types35 = require("@fluxerjs/types");
3189
3281
  async function createSticker(guild, options) {
3190
- const data = await guild.client.rest.post(import_types34.Routes.guildStickers(guild.id), {
3282
+ const data = await guild.client.rest.post(import_types35.Routes.guildStickers(guild.id), {
3191
3283
  body: options,
3192
3284
  auth: true
3193
3285
  });
3194
3286
  return cacheSticker(guild, data);
3195
3287
  }
3196
3288
  async function cloneSticker(guild, sourceStickerId) {
3197
- const data = await guild.client.rest.post(import_types34.Routes.guildStickersClone(guild.id), {
3289
+ const data = await guild.client.rest.post(import_types35.Routes.guildStickersClone(guild.id), {
3198
3290
  body: { source_sticker_id: sourceStickerId },
3199
3291
  auth: true
3200
3292
  });
@@ -3202,17 +3294,17 @@ async function cloneSticker(guild, sourceStickerId) {
3202
3294
  }
3203
3295
  async function createStickersBulk(guild, stickers) {
3204
3296
  const data = await guild.client.rest.post(
3205
- import_types34.Routes.guildStickersBulk(guild.id),
3297
+ import_types35.Routes.guildStickersBulk(guild.id),
3206
3298
  { body: { stickers }, auth: true }
3207
3299
  );
3208
3300
  return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
3209
3301
  }
3210
3302
  async function fetchStickers(guild) {
3211
- const data = await guild.client.rest.get(import_types34.Routes.guildStickers(guild.id));
3303
+ const data = await guild.client.rest.get(import_types35.Routes.guildStickers(guild.id));
3212
3304
  return data.map((s) => cacheSticker(guild, s));
3213
3305
  }
3214
3306
  async function fetchSticker(guild, stickerId) {
3215
- const data = await guild.client.rest.get(import_types34.Routes.guildSticker(guild.id, stickerId));
3307
+ const data = await guild.client.rest.get(import_types35.Routes.guildSticker(guild.id, stickerId));
3216
3308
  return cacheSticker(guild, data);
3217
3309
  }
3218
3310
 
@@ -3222,6 +3314,8 @@ var Guild = class extends Base {
3222
3314
  client;
3223
3315
  /** Snowflake ID of this guild. */
3224
3316
  id;
3317
+ /** Whether the guild is currently available through the gateway. */
3318
+ available = true;
3225
3319
  /** Guild name. */
3226
3320
  name;
3227
3321
  /** Icon hash (use {@link iconURL} to get full CDN URL). */
@@ -3295,7 +3389,7 @@ var Guild = class extends Base {
3295
3389
  this.afkTimeout = data.afk_timeout ?? 0;
3296
3390
  this.systemChannelId = data.system_channel_id ?? null;
3297
3391
  this.rulesChannelId = data.rules_channel_id ?? null;
3298
- this.nsfwLevel = data.nsfw_level ?? import_types35.GuildNSFWLevel.Safe;
3392
+ this.nsfwLevel = data.nsfw_level ?? import_types36.GuildNSFWLevel.Safe;
3299
3393
  this.mfaLevel = data.mfa_level ?? 0;
3300
3394
  this.bannerWidth = data.banner_width ?? null;
3301
3395
  this.bannerHeight = data.banner_height ?? null;
@@ -3328,7 +3422,7 @@ var Guild = class extends Base {
3328
3422
  if (data.afk_timeout !== void 0) this.afkTimeout = data.afk_timeout ?? 0;
3329
3423
  if (data.system_channel_id !== void 0) this.systemChannelId = data.system_channel_id ?? null;
3330
3424
  if (data.rules_channel_id !== void 0) this.rulesChannelId = data.rules_channel_id ?? null;
3331
- if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types35.GuildNSFWLevel.Safe;
3425
+ if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types36.GuildNSFWLevel.Safe;
3332
3426
  if (data.mfa_level !== void 0) this.mfaLevel = data.mfa_level ?? 0;
3333
3427
  if (data.banner_width !== void 0) this.bannerWidth = data.banner_width ?? null;
3334
3428
  if (data.banner_height !== void 0) this.bannerHeight = data.banner_height ?? null;
@@ -3557,13 +3651,13 @@ var GuildManager = class extends import_collection9.Collection {
3557
3651
  const cached = this.get(guildId);
3558
3652
  if (cached) return cached;
3559
3653
  try {
3560
- const data = await this.client.rest.get(import_types36.Routes.guild(guildId));
3654
+ const data = await this.client.rest.get(import_types37.Routes.guild(guildId));
3561
3655
  const guild = new Guild(this.client, data);
3562
3656
  this.set(guild.id, guild);
3563
3657
  return guild;
3564
3658
  } catch (err) {
3565
- if (err instanceof import_rest5.RateLimitError) throw err;
3566
- if (err instanceof import_rest5.FluxerAPIError && err.statusCode === 404) {
3659
+ if (err instanceof import_rest6.RateLimitError) throw err;
3660
+ if (err instanceof import_rest6.FluxerAPIError && err.statusCode === 404) {
3567
3661
  throw new import_util.FluxerError(`Guild ${guildId} not found`, {
3568
3662
  code: import_util2.ErrorCodes.GuildNotFound,
3569
3663
  cause: err
@@ -3584,7 +3678,7 @@ var DEFAULT_CACHE_LIMITS = {
3584
3678
  };
3585
3679
 
3586
3680
  // src/structures/User.ts
3587
- var import_types37 = require("@fluxerjs/types");
3681
+ var import_types38 = require("@fluxerjs/types");
3588
3682
  var User = class extends Base {
3589
3683
  /** Parent client instance. */
3590
3684
  client;
@@ -3674,7 +3768,7 @@ var User = class extends Base {
3674
3768
  * @returns DM channel instance (cached if already open)
3675
3769
  */
3676
3770
  async createDM() {
3677
- const data = await this.client.rest.post(import_types37.Routes.userMeChannels(), {
3771
+ const data = await this.client.rest.post(import_types38.Routes.userMeChannels(), {
3678
3772
  body: { recipient_id: this.id },
3679
3773
  auth: true
3680
3774
  });
@@ -3684,7 +3778,7 @@ var User = class extends Base {
3684
3778
  }
3685
3779
  /**
3686
3780
  * Send a DM to this user.
3687
- * @param options - Message content or {@link MessageSendOptions}
3781
+ * @param options - {@link MessagePrepareInput}
3688
3782
  * @returns Sent message
3689
3783
  */
3690
3784
  async send(options) {
@@ -3694,7 +3788,7 @@ var User = class extends Base {
3694
3788
 
3695
3789
  // src/client/UserManager.ts
3696
3790
  var import_collection10 = require("@fluxerjs/collection");
3697
- var import_types38 = require("@fluxerjs/types");
3791
+ var import_types39 = require("@fluxerjs/types");
3698
3792
  var soft = (p) => p.catch(() => null);
3699
3793
  var UserManager = class extends import_collection10.Collection {
3700
3794
  constructor(client) {
@@ -3725,7 +3819,7 @@ var UserManager = class extends import_collection10.Collection {
3725
3819
  }
3726
3820
  /** Fetch a user by ID and update cache. */
3727
3821
  async fetch(userId) {
3728
- const data = await this.client.rest.get(import_types38.Routes.user(userId));
3822
+ const data = await this.client.rest.get(import_types39.Routes.user(userId));
3729
3823
  return this.client.getOrCreateUser(data);
3730
3824
  }
3731
3825
  /**
@@ -3739,10 +3833,10 @@ var UserManager = class extends import_collection10.Collection {
3739
3833
  async fetchWithProfile(userId, options) {
3740
3834
  const guildId = options?.guildId ?? void 0;
3741
3835
  const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
3742
- this.client.rest.get(import_types38.Routes.user(userId)),
3743
- soft(this.client.rest.get(import_types38.Routes.userProfile(userId))),
3744
- guildId ? soft(this.client.rest.get(import_types38.Routes.userProfile(userId, guildId))) : null,
3745
- guildId ? soft(this.client.rest.get(import_types38.Routes.guildMember(guildId, userId))) : null
3836
+ this.client.rest.get(import_types39.Routes.user(userId)),
3837
+ soft(this.client.rest.get(import_types39.Routes.userProfile(userId))),
3838
+ guildId ? soft(this.client.rest.get(import_types39.Routes.userProfile(userId, guildId))) : null,
3839
+ guildId ? soft(this.client.rest.get(import_types39.Routes.guildMember(guildId, userId))) : null
3746
3840
  ]);
3747
3841
  const user = this.client.getOrCreateUser(userData);
3748
3842
  let member = null;
@@ -3771,7 +3865,7 @@ var UserManager = class extends import_collection10.Collection {
3771
3865
  };
3772
3866
 
3773
3867
  // src/client/PackManager.ts
3774
- var import_types39 = require("@fluxerjs/types");
3868
+ var import_types40 = require("@fluxerjs/types");
3775
3869
  function toPackSummaryPayload(data) {
3776
3870
  return {
3777
3871
  id: data.id,
@@ -3826,7 +3920,7 @@ var PackManager = class {
3826
3920
  }
3827
3921
  /** Fetch the current user's pack dashboard (camelCase summaries). */
3828
3922
  async fetchDashboard() {
3829
- const data = await this.client.rest.get(import_types39.Routes.packs());
3923
+ const data = await this.client.rest.get(import_types40.Routes.packs());
3830
3924
  return {
3831
3925
  emoji: mapDashboardSection(data.emoji),
3832
3926
  sticker: mapDashboardSection(data.sticker)
@@ -3834,49 +3928,49 @@ var PackManager = class {
3834
3928
  }
3835
3929
  /** Create a pack. */
3836
3930
  async create(packType, body) {
3837
- const data = await this.client.rest.post(import_types39.Routes.packsByType(packType), {
3931
+ const data = await this.client.rest.post(import_types40.Routes.packsByType(packType), {
3838
3932
  body
3839
3933
  });
3840
3934
  return toPackSummaryPayload(data);
3841
3935
  }
3842
3936
  /** Edit a pack. */
3843
3937
  async edit(packId, body) {
3844
- const data = await this.client.rest.patch(import_types39.Routes.pack(packId), { body });
3938
+ const data = await this.client.rest.patch(import_types40.Routes.pack(packId), { body });
3845
3939
  return toPackSummaryPayload(data);
3846
3940
  }
3847
3941
  /** Delete a pack. */
3848
3942
  async delete(packId) {
3849
- await this.client.rest.delete(import_types39.Routes.pack(packId));
3943
+ await this.client.rest.delete(import_types40.Routes.pack(packId));
3850
3944
  }
3851
3945
  /** Install a pack for the current user. */
3852
3946
  async install(packId) {
3853
- await this.client.rest.post(import_types39.Routes.packInstall(packId));
3947
+ await this.client.rest.post(import_types40.Routes.packInstall(packId));
3854
3948
  }
3855
3949
  /** Uninstall a pack for the current user. */
3856
3950
  async uninstall(packId) {
3857
- await this.client.rest.delete(import_types39.Routes.packInstall(packId));
3951
+ await this.client.rest.delete(import_types40.Routes.packInstall(packId));
3858
3952
  }
3859
3953
  /** List invites for a pack. */
3860
3954
  async listInvites(packId) {
3861
- const data = await this.client.rest.get(import_types39.Routes.packInvites(packId));
3955
+ const data = await this.client.rest.get(import_types40.Routes.packInvites(packId));
3862
3956
  return data.map(toInvitePayload);
3863
3957
  }
3864
3958
  /** Create an invite for a pack. */
3865
3959
  async createInvite(packId, options = {}) {
3866
3960
  const body = toPackInviteBody(options);
3867
- const data = await this.client.rest.post(import_types39.Routes.packInvites(packId), {
3961
+ const data = await this.client.rest.post(import_types40.Routes.packInvites(packId), {
3868
3962
  body: Object.keys(body).length ? body : void 0
3869
3963
  });
3870
3964
  return toInvitePayload(data);
3871
3965
  }
3872
3966
  /** List emojis in a pack. */
3873
3967
  async listEmojis(packId) {
3874
- const data = await this.client.rest.get(import_types39.Routes.packEmojis(packId));
3968
+ const data = await this.client.rest.get(import_types40.Routes.packEmojis(packId));
3875
3969
  return data.map(toEmojiPayload);
3876
3970
  }
3877
3971
  /** Create an emoji in a pack. */
3878
3972
  async createEmoji(packId, options) {
3879
- const data = await this.client.rest.post(import_types39.Routes.packEmojis(packId), {
3973
+ const data = await this.client.rest.post(import_types40.Routes.packEmojis(packId), {
3880
3974
  body: toEmojiCreateBody(options)
3881
3975
  });
3882
3976
  return toEmojiPayload(data);
@@ -3884,7 +3978,7 @@ var PackManager = class {
3884
3978
  /** Bulk-create emojis in a pack. */
3885
3979
  async createEmojisBulk(packId, emojis) {
3886
3980
  const data = await this.client.rest.post(
3887
- import_types39.Routes.packEmojisBulk(packId),
3981
+ import_types40.Routes.packEmojisBulk(packId),
3888
3982
  { body: { emojis: emojis.map(toEmojiCreateBody) } }
3889
3983
  );
3890
3984
  return {
@@ -3894,23 +3988,23 @@ var PackManager = class {
3894
3988
  }
3895
3989
  /** Edit an emoji in a pack. */
3896
3990
  async editEmoji(packId, emojiId, options) {
3897
- const data = await this.client.rest.patch(import_types39.Routes.packEmoji(packId, emojiId), {
3991
+ const data = await this.client.rest.patch(import_types40.Routes.packEmoji(packId, emojiId), {
3898
3992
  body: toEmojiEditBody(options)
3899
3993
  });
3900
3994
  return toEmojiPayload(data);
3901
3995
  }
3902
3996
  /** Delete an emoji from a pack. */
3903
3997
  async deleteEmoji(packId, emojiId) {
3904
- await this.client.rest.delete(import_types39.Routes.packEmoji(packId, emojiId));
3998
+ await this.client.rest.delete(import_types40.Routes.packEmoji(packId, emojiId));
3905
3999
  }
3906
4000
  /** List stickers in a pack. */
3907
4001
  async listStickers(packId) {
3908
- const data = await this.client.rest.get(import_types39.Routes.packStickers(packId));
4002
+ const data = await this.client.rest.get(import_types40.Routes.packStickers(packId));
3909
4003
  return data.map(toStickerPayload);
3910
4004
  }
3911
4005
  /** Create a sticker in a pack. */
3912
4006
  async createSticker(packId, options) {
3913
- const data = await this.client.rest.post(import_types39.Routes.packStickers(packId), {
4007
+ const data = await this.client.rest.post(import_types40.Routes.packStickers(packId), {
3914
4008
  body: toStickerCreateBody(options)
3915
4009
  });
3916
4010
  return toStickerPayload(data);
@@ -3918,7 +4012,7 @@ var PackManager = class {
3918
4012
  /** Bulk-create stickers in a pack. */
3919
4013
  async createStickersBulk(packId, stickers) {
3920
4014
  const data = await this.client.rest.post(
3921
- import_types39.Routes.packStickersBulk(packId),
4015
+ import_types40.Routes.packStickersBulk(packId),
3922
4016
  { body: { stickers: stickers.map(toStickerCreateBody) } }
3923
4017
  );
3924
4018
  return {
@@ -3928,14 +4022,14 @@ var PackManager = class {
3928
4022
  }
3929
4023
  /** Edit a sticker in a pack. */
3930
4024
  async editSticker(packId, stickerId, options) {
3931
- const data = await this.client.rest.patch(import_types39.Routes.packSticker(packId, stickerId), {
4025
+ const data = await this.client.rest.patch(import_types40.Routes.packSticker(packId, stickerId), {
3932
4026
  body: toStickerEditBody(options)
3933
4027
  });
3934
4028
  return toStickerPayload(data);
3935
4029
  }
3936
4030
  /** Delete a sticker from a pack. */
3937
4031
  async deleteSticker(packId, stickerId) {
3938
- await this.client.rest.delete(import_types39.Routes.packSticker(packId, stickerId));
4032
+ await this.client.rest.delete(import_types40.Routes.packSticker(packId, stickerId));
3939
4033
  }
3940
4034
  };
3941
4035
 
@@ -3954,10 +4048,10 @@ function createEventMethods(client) {
3954
4048
 
3955
4049
  // src/client/clientEmoji.ts
3956
4050
  var import_collection11 = require("@fluxerjs/collection");
3957
- var import_types40 = require("@fluxerjs/types");
4051
+ var import_types41 = require("@fluxerjs/types");
3958
4052
  var import_util9 = require("@fluxerjs/util");
3959
4053
  async function assertEmojiInGuild(client, emojiId, guildId) {
3960
- const emojis = await client.rest.get(import_types40.Routes.guildEmojis(guildId));
4054
+ const emojis = await client.rest.get(import_types41.Routes.guildEmojis(guildId));
3961
4055
  if (!emojis.some((e) => e.id === emojiId)) {
3962
4056
  throw new import_util.FluxerError("Custom emoji is from another server. Use an emoji from this server.", {
3963
4057
  code: import_util2.ErrorCodes.EmojiNotInGuild
@@ -3983,7 +4077,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
3983
4077
  const unicodeFromShortcode = (0, import_util9.getUnicodeFromShortcode)(parsed.name);
3984
4078
  if (unicodeFromShortcode) return unicodeFromShortcode;
3985
4079
  if (guildId) {
3986
- const emojis = await client.rest.get(import_types40.Routes.guildEmojis(guildId));
4080
+ const emojis = await client.rest.get(import_types41.Routes.guildEmojis(guildId));
3987
4081
  const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
3988
4082
  if (found) return (0, import_util9.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
3989
4083
  throw new import_util.FluxerError(
@@ -4000,28 +4094,28 @@ async function resolveClientEmoji(client, emoji, guildId) {
4000
4094
  return parsed.name;
4001
4095
  }
4002
4096
  async function fetchInstance(client) {
4003
- const raw = await client.rest.get(import_types40.Routes.instanceDiscovery(), { auth: false });
4097
+ const raw = await client.rest.get(import_types41.Routes.instanceDiscovery(), { auth: false });
4004
4098
  return parseInstanceDiscovery(raw);
4005
4099
  }
4006
4100
  function fetchGatewayInfo(client) {
4007
- return client.rest.get(import_types40.Routes.gatewayBot());
4101
+ return client.rest.get(import_types41.Routes.gatewayBot());
4008
4102
  }
4009
4103
  function fetchEmojiMetadata(client, emojiId) {
4010
- return client.rest.get(import_types40.Routes.emojiMetadata(emojiId), { auth: true });
4104
+ return client.rest.get(import_types41.Routes.emojiMetadata(emojiId), { auth: true });
4011
4105
  }
4012
4106
  function fetchStickerMetadata(client, stickerId) {
4013
- return client.rest.get(import_types40.Routes.stickerMetadata(stickerId), { auth: true });
4107
+ return client.rest.get(import_types41.Routes.stickerMetadata(stickerId), { auth: true });
4014
4108
  }
4015
4109
  function fetchApplication(client) {
4016
- return client.rest.get(import_types40.Routes.applicationsMe(), { auth: true });
4110
+ return client.rest.get(import_types41.Routes.applicationsMe(), { auth: true });
4017
4111
  }
4018
4112
  async function fetchOAuthApplications(client) {
4019
- const data = await client.rest.get(import_types40.Routes.oauth2ApplicationsMe(), { auth: true });
4113
+ const data = await client.rest.get(import_types41.Routes.oauth2ApplicationsMe(), { auth: true });
4020
4114
  return Array.isArray(data) ? data : data.applications ?? [];
4021
4115
  }
4022
4116
  function checkUsernameTag(client, username, discriminator) {
4023
4117
  const params = new URLSearchParams({ username, discriminator });
4024
- return client.rest.get(`${import_types40.Routes.checkUsernameTag()}?${params}`, { auth: true });
4118
+ return client.rest.get(`${import_types41.Routes.checkUsernameTag()}?${params}`, { auth: true });
4025
4119
  }
4026
4120
  function assertChannelIdBatch(name, channelIds) {
4027
4121
  if (channelIds.length < 1 || channelIds.length > 100) {
@@ -4032,14 +4126,14 @@ function assertChannelIdBatch(name, channelIds) {
4032
4126
  }
4033
4127
  function preloadMessages(client, channelIds) {
4034
4128
  assertChannelIdBatch("preloadMessages", channelIds);
4035
- return client.rest.post(import_types40.Routes.preloadMessages(), {
4129
+ return client.rest.post(import_types41.Routes.preloadMessages(), {
4036
4130
  body: { channels: channelIds },
4037
4131
  auth: true
4038
4132
  });
4039
4133
  }
4040
4134
  function preloadMessagesAlt(client, channelIds) {
4041
4135
  assertChannelIdBatch("preloadMessagesAlt", channelIds);
4042
- return client.rest.post(import_types40.Routes.preloadMessagesAlt(), {
4136
+ return client.rest.post(import_types41.Routes.preloadMessagesAlt(), {
4043
4137
  body: { channels: channelIds },
4044
4138
  auth: true
4045
4139
  });
@@ -4047,7 +4141,7 @@ function preloadMessagesAlt(client, channelIds) {
4047
4141
  async function bulkFetchMessages(client, requests, options = {}) {
4048
4142
  validateBulkMessageFetchRequests(requests);
4049
4143
  const wire = toBulkFetchWire(requests);
4050
- const data = await client.rest.post(import_types40.Routes.channelsMessagesBulk(), {
4144
+ const data = await client.rest.post(import_types41.Routes.channelsMessagesBulk(), {
4051
4145
  body: { requests: wire },
4052
4146
  auth: true
4053
4147
  });
@@ -4134,62 +4228,6 @@ function buildRegistry(...maps) {
4134
4228
  return registry;
4135
4229
  }
4136
4230
 
4137
- // src/structures/MessageReaction.ts
4138
- var import_types41 = require("@fluxerjs/types");
4139
- var import_rest6 = require("@fluxerjs/rest");
4140
- var MessageReaction = class extends Base {
4141
- client;
4142
- messageId;
4143
- channelId;
4144
- guildId;
4145
- emoji;
4146
- /** Raw gateway payload for low-level access. */
4147
- _data;
4148
- constructor(client, data) {
4149
- super();
4150
- this.client = client;
4151
- this._data = data;
4152
- this.messageId = data.message_id;
4153
- this.channelId = data.channel_id;
4154
- this.guildId = data.guild_id ?? null;
4155
- this.emoji = {
4156
- name: data.emoji.name,
4157
- ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
4158
- ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
4159
- };
4160
- }
4161
- /** Emoji as a string: unicode or "name:id" for custom. */
4162
- get emojiIdentifier() {
4163
- return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
4164
- }
4165
- /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
4166
- get guild() {
4167
- return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
4168
- }
4169
- /**
4170
- * Fetch the message this reaction belongs to.
4171
- * Use when you need to edit, delete, or otherwise interact with the message.
4172
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
4173
- */
4174
- async fetchMessage() {
4175
- try {
4176
- const data = await this.client.rest.get(
4177
- import_types41.Routes.channelMessage(this.channelId, this.messageId)
4178
- );
4179
- return new Message(this.client, data);
4180
- } catch (err) {
4181
- if (err instanceof import_rest6.RateLimitError) throw err;
4182
- if (err instanceof import_rest6.FluxerAPIError && err.statusCode === 404) {
4183
- throw new import_util.FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
4184
- code: import_util2.ErrorCodes.MessageNotFound,
4185
- cause: err
4186
- });
4187
- }
4188
- throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
4189
- }
4190
- }
4191
- };
4192
-
4193
4231
  // src/client/eventHandlers/helpers.ts
4194
4232
  function unknownUser(id) {
4195
4233
  return { id, username: "Unknown", discriminator: "0" };
@@ -4360,13 +4398,50 @@ function normalizeGuildPayload(raw) {
4360
4398
  }
4361
4399
 
4362
4400
  // src/client/eventHandlers/guilds.ts
4401
+ function markGuildUnavailable(client, id) {
4402
+ const guild = client.guilds.get(id);
4403
+ if (!guild || guild.available === false) return;
4404
+ guild.available = false;
4405
+ client.emit(Events.GuildUnavailable, guild);
4406
+ }
4407
+ function refreshRecoveredGuild(guild, data) {
4408
+ guild._patch(data);
4409
+ if (data.roles !== void 0) {
4410
+ guild.roles.clear();
4411
+ for (const role of data.roles) {
4412
+ guild.roles.set(role.id, new Role(guild.client, role, guild.id));
4413
+ }
4414
+ }
4415
+ if (data.channels !== void 0) {
4416
+ const recoveredChannelIds = new Set(data.channels.map((channel) => channel.id));
4417
+ for (const channel of guild.channels.values()) {
4418
+ guild.client.channels.delete(channel.id);
4419
+ if (!recoveredChannelIds.has(channel.id)) guild.client._clearMessageCache(channel.id);
4420
+ }
4421
+ guild.channels.clear();
4422
+ }
4423
+ }
4363
4424
  var guildHandlers = {
4364
4425
  GUILD_CREATE(client, d) {
4426
+ const raw = d;
4427
+ if (raw.unavailable === true) {
4428
+ if (typeof raw.id === "string") {
4429
+ try {
4430
+ markGuildUnavailable(client, raw.id);
4431
+ } finally {
4432
+ client._onGuildReceived(raw.id);
4433
+ }
4434
+ }
4435
+ return;
4436
+ }
4365
4437
  const guildData = normalizeGuildPayload(d);
4366
4438
  if (!guildData) return;
4367
- const guild = new Guild(client, guildData);
4368
- client.guilds.set(guild.id, guild);
4369
4439
  const g = d;
4440
+ const existing = client.guilds.get(guildData.id);
4441
+ const recovered = existing?.available === false;
4442
+ const guild = recovered && existing ? existing : new Guild(client, guildData);
4443
+ if (recovered) refreshRecoveredGuild(guild, g);
4444
+ client.guilds.set(guild.id, guild);
4370
4445
  for (const ch of g.channels ?? []) {
4371
4446
  const channel = Channel.from(client, ch);
4372
4447
  if (channel) {
@@ -4375,7 +4450,8 @@ var guildHandlers = {
4375
4450
  }
4376
4451
  }
4377
4452
  for (const m of g.members ?? []) cacheMember2(client, guild, m);
4378
- client.emit(Events.GuildCreate, guild);
4453
+ if (recovered) guild.available = true;
4454
+ client.emit(recovered ? Events.GuildAvailable : Events.GuildCreate, guild);
4379
4455
  if (g.voice_states?.length) {
4380
4456
  client.emit(Events.VoiceStatesSync, { guildId: guild.id, voiceStates: g.voice_states });
4381
4457
  }
@@ -4396,11 +4472,19 @@ var guildHandlers = {
4396
4472
  client.emit(Events.GuildUpdate, updated, updated);
4397
4473
  },
4398
4474
  GUILD_DELETE(client, d) {
4399
- const { id } = d;
4400
- const guild = client.guilds.get(id);
4401
- if (!guild) return;
4402
- client.guilds.delete(id);
4403
- client.emit(Events.GuildDelete, guild);
4475
+ const { id, unavailable } = d;
4476
+ try {
4477
+ if (unavailable === true) {
4478
+ markGuildUnavailable(client, id);
4479
+ return;
4480
+ }
4481
+ const guild = client.guilds.get(id);
4482
+ if (!guild) return;
4483
+ client.guilds.delete(id);
4484
+ client.emit(Events.GuildDelete, guild);
4485
+ } finally {
4486
+ client._onGuildReceived(id);
4487
+ }
4404
4488
  }
4405
4489
  };
4406
4490
 
@@ -4819,7 +4903,12 @@ function emitClientError(client, err) {
4819
4903
  function shouldDeferGatewayDispatchUntilReady(client, payload) {
4820
4904
  if (client.options.waitForGuilds !== true || client.readyAt !== null) return false;
4821
4905
  if (payload.op !== 0 || !payload.t) return false;
4822
- return payload.t !== "GUILD_CREATE";
4906
+ if (payload.t === "GUILD_CREATE") return false;
4907
+ if (payload.t === "GUILD_DELETE") {
4908
+ const data = payload.d;
4909
+ if (typeof data?.id === "string" && client._pendingGuildIds?.has(data.id)) return false;
4910
+ }
4911
+ return true;
4823
4912
  }
4824
4913
  function handleGatewayDispatch(client, payload, deferred) {
4825
4914
  if (payload.op !== 0 || !payload.t) return Promise.resolve();