@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/index.js CHANGED
@@ -134,8 +134,8 @@ var import_types46 = require("@fluxerjs/types");
134
134
 
135
135
  // src/client/ChannelManager.ts
136
136
  var import_collection5 = require("@fluxerjs/collection");
137
- var import_types16 = require("@fluxerjs/types");
138
- var import_rest3 = require("@fluxerjs/rest");
137
+ var import_types17 = require("@fluxerjs/types");
138
+ var import_rest4 = require("@fluxerjs/rest");
139
139
 
140
140
  // src/errors/FluxerError.ts
141
141
  var import_util = require("@fluxerjs/util");
@@ -330,17 +330,17 @@ async function prepareMessagePostPayload(options, defaults) {
330
330
  }
331
331
 
332
332
  // src/structures/channel/base.ts
333
- var import_types9 = require("@fluxerjs/types");
333
+ var import_types10 = require("@fluxerjs/types");
334
334
 
335
335
  // src/client/MessageManager.ts
336
- var import_types7 = require("@fluxerjs/types");
336
+ var import_types8 = require("@fluxerjs/types");
337
337
  var import_collection3 = require("@fluxerjs/collection");
338
- var import_rest = require("@fluxerjs/rest");
338
+ var import_rest2 = require("@fluxerjs/rest");
339
339
 
340
340
  // src/structures/message/Message.ts
341
341
  var import_collection2 = require("@fluxerjs/collection");
342
342
  var import_builders3 = require("@fluxerjs/builders");
343
- var import_types5 = require("@fluxerjs/types");
343
+ var import_types6 = require("@fluxerjs/types");
344
344
 
345
345
  // src/client/sdkOptions.ts
346
346
  function toMemberSearchBody(options) {
@@ -581,6 +581,68 @@ function toProfilePayload(data) {
581
581
  var import_events = require("events");
582
582
  var import_collection = require("@fluxerjs/collection");
583
583
 
584
+ // src/structures/MessageReaction.ts
585
+ var import_types3 = require("@fluxerjs/types");
586
+ var import_rest = require("@fluxerjs/rest");
587
+
588
+ // src/structures/Base.ts
589
+ var Base = class {
590
+ };
591
+
592
+ // src/structures/MessageReaction.ts
593
+ var MessageReaction = class extends Base {
594
+ client;
595
+ messageId;
596
+ channelId;
597
+ guildId;
598
+ emoji;
599
+ /** Raw gateway payload for low-level access. */
600
+ _data;
601
+ constructor(client, data) {
602
+ super();
603
+ this.client = client;
604
+ this._data = data;
605
+ this.messageId = data.message_id;
606
+ this.channelId = data.channel_id;
607
+ this.guildId = data.guild_id ?? null;
608
+ this.emoji = {
609
+ name: data.emoji.name,
610
+ ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
611
+ ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
612
+ };
613
+ }
614
+ /** Emoji as a string: unicode or "name:id" for custom. */
615
+ get emojiIdentifier() {
616
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
617
+ }
618
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
619
+ get guild() {
620
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
621
+ }
622
+ /**
623
+ * Fetch the message this reaction belongs to.
624
+ * Use when you need to edit, delete, or otherwise interact with the message.
625
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
626
+ */
627
+ async fetchMessage() {
628
+ try {
629
+ const data = await this.client.rest.get(
630
+ import_types3.Routes.channelMessage(this.channelId, this.messageId)
631
+ );
632
+ return new Message(this.client, data);
633
+ } catch (err) {
634
+ if (err instanceof import_rest.RateLimitError) throw err;
635
+ if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
636
+ throw new import_util.FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
637
+ code: import_util2.ErrorCodes.MessageNotFound,
638
+ cause: err
639
+ });
640
+ }
641
+ throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
642
+ }
643
+ }
644
+ };
645
+
584
646
  // src/util/Events.ts
585
647
  var Events = {
586
648
  Ready: "ready",
@@ -594,6 +656,8 @@ var Events = {
594
656
  MessageReactionRemoveAll: "messageReactionRemoveAll",
595
657
  MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
596
658
  GuildCreate: "guildCreate",
659
+ GuildAvailable: "guildAvailable",
660
+ GuildUnavailable: "guildUnavailable",
597
661
  GuildUpdate: "guildUpdate",
598
662
  GuildDelete: "guildDelete",
599
663
  GuildBanAdd: "guildBanAdd",
@@ -642,7 +706,8 @@ var ReactionCollector = class extends import_events.EventEmitter {
642
706
  collected = new import_collection.Collection();
643
707
  _timeout = null;
644
708
  _ended = false;
645
- _listener;
709
+ _onAdd;
710
+ _onAddMany;
646
711
  constructor(client, messageId, channelId, options = {}) {
647
712
  super();
648
713
  this.client = client;
@@ -653,27 +718,58 @@ var ReactionCollector = class extends import_events.EventEmitter {
653
718
  time: options.time ?? 0,
654
719
  max: options.max ?? 0
655
720
  };
656
- this._listener = (payload) => {
721
+ this._onAdd = (payload) => {
657
722
  if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
658
723
  return;
659
724
  }
660
- if (!this.options.filter(payload.reaction, payload.user)) return;
661
- const key = `${payload.userId}:${payload.reaction.emoji.id ?? payload.reaction.emoji.name}`;
662
- this.collected.set(key, { reaction: payload.reaction, user: payload.user });
663
- this.emit("collect", payload.reaction, payload.user);
664
- if (this.options.max > 0 && this.collected.size >= this.options.max) {
665
- this.stop("limit");
725
+ this._collect(payload.reaction, payload.user, payload.userId);
726
+ };
727
+ this._onAddMany = (payload) => {
728
+ if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
729
+ return;
730
+ }
731
+ for (const entry of payload.reactions) {
732
+ if (this._ended) return;
733
+ const reaction = new MessageReaction(this.client, {
734
+ message_id: payload.messageId,
735
+ channel_id: payload.channelId,
736
+ guild_id: payload.guildId ?? void 0,
737
+ user_id: entry.userId,
738
+ emoji: {
739
+ name: entry.emoji.name,
740
+ ...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
741
+ ...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
742
+ }
743
+ });
744
+ const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
745
+ id: entry.userId,
746
+ username: "Unknown",
747
+ discriminator: "0"
748
+ });
749
+ this._collect(reaction, user, entry.userId);
666
750
  }
667
751
  };
668
- this.client.on(Events.MessageReactionAdd, this._listener);
752
+ this.client.on(Events.MessageReactionAdd, this._onAdd);
753
+ this.client.on(Events.MessageReactionAddMany, this._onAddMany);
669
754
  if (this.options.time > 0) {
670
755
  this._timeout = setTimeout(() => this.stop("time"), this.options.time);
671
756
  }
672
757
  }
758
+ _collect(reaction, user, userId) {
759
+ if (this._ended) return;
760
+ if (!this.options.filter(reaction, user)) return;
761
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
762
+ this.collected.set(key, { reaction, user });
763
+ this.emit("collect", reaction, user);
764
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
765
+ this.stop("limit");
766
+ }
767
+ }
673
768
  stop(reason = "user") {
674
769
  if (this._ended) return;
675
770
  this._ended = true;
676
- this.client.off(Events.MessageReactionAdd, this._listener);
771
+ this.client.off(Events.MessageReactionAdd, this._onAdd);
772
+ this.client.off(Events.MessageReactionAddMany, this._onAddMany);
677
773
  if (this._timeout) {
678
774
  clearTimeout(this._timeout);
679
775
  this._timeout = null;
@@ -688,30 +784,26 @@ var ReactionCollector = class extends import_events.EventEmitter {
688
784
  }
689
785
  };
690
786
 
691
- // src/structures/Base.ts
692
- var Base = class {
693
- };
694
-
695
787
  // src/structures/message/reactions.ts
696
- var import_types3 = require("@fluxerjs/types");
788
+ var import_types4 = require("@fluxerjs/types");
697
789
  async function emojiPath(message, emoji) {
698
790
  return message.client.resolveEmoji(emoji, message.guildId);
699
791
  }
700
792
  async function reactToMessage(message, emoji) {
701
793
  const e = await emojiPath(message, emoji);
702
- await message.client.rest.put(import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e));
794
+ await message.client.rest.put(import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e));
703
795
  }
704
796
  async function removeMessageReaction(message, emoji, userId) {
705
797
  const e = await emojiPath(message, emoji);
706
- const route = userId ? import_types3.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e);
798
+ const route = userId ? import_types4.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e);
707
799
  await message.client.rest.delete(route);
708
800
  }
709
801
  async function removeAllMessageReactions(message) {
710
- await message.client.rest.delete(import_types3.Routes.channelMessageReactions(message.channelId, message.id));
802
+ await message.client.rest.delete(import_types4.Routes.channelMessageReactions(message.channelId, message.id));
711
803
  }
712
804
  async function removeMessageReactionEmoji(message, emoji) {
713
805
  const e = await emojiPath(message, emoji);
714
- await message.client.rest.delete(import_types3.Routes.channelMessageReaction(message.channelId, message.id, e));
806
+ await message.client.rest.delete(import_types4.Routes.channelMessageReaction(message.channelId, message.id, e));
715
807
  }
716
808
  async function fetchMessageReactionUsers(message, emoji, options) {
717
809
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -722,7 +814,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
722
814
  if (options?.limit != null) params.set("limit", String(options.limit));
723
815
  if (options?.after) params.set("after", options.after);
724
816
  const qs2 = params.toString();
725
- const route = import_types3.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
817
+ const route = import_types4.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
726
818
  const data = await message.client.rest.get(route);
727
819
  if (Array.isArray(data)) {
728
820
  return {
@@ -741,7 +833,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
741
833
 
742
834
  // src/structures/message/send.ts
743
835
  var import_builders2 = require("@fluxerjs/builders");
744
- var import_types4 = require("@fluxerjs/types");
836
+ var import_types5 = require("@fluxerjs/types");
745
837
  function toReplyTarget(ref) {
746
838
  return {
747
839
  channelId: ref.channel_id,
@@ -775,7 +867,7 @@ function asReplyTarget(value) {
775
867
  }
776
868
  async function sendPrepared(message, payload) {
777
869
  const data = await message.client.rest.post(
778
- import_types4.Routes.channelMessages(message.channelId),
870
+ import_types5.Routes.channelMessages(message.channelId),
779
871
  payload
780
872
  );
781
873
  message.client._addMessageToCache(message.channelId, data);
@@ -894,7 +986,7 @@ var Message = class _Message extends Base {
894
986
  this.pinned = data.pinned;
895
987
  this.attachments = new import_collection2.Collection();
896
988
  for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
897
- this.type = data.type ?? import_types5.MessageType.Default;
989
+ this.type = data.type ?? import_types6.MessageType.Default;
898
990
  this.flags = data.flags ?? 0;
899
991
  this.mentionEveryone = data.mention_everyone ?? false;
900
992
  this.tts = data.tts ?? false;
@@ -952,7 +1044,7 @@ var Message = class _Message extends Base {
952
1044
  if (options.attachments !== void 0) {
953
1045
  body.attachments = toMessageAttachmentEditWire(options.attachments);
954
1046
  }
955
- const data = await this.client.rest.patch(import_types5.Routes.channelMessage(this.channelId, this.id), {
1047
+ const data = await this.client.rest.patch(import_types6.Routes.channelMessage(this.channelId, this.id), {
956
1048
  body
957
1049
  });
958
1050
  const updated = new _Message(this.client, data);
@@ -969,25 +1061,25 @@ var Message = class _Message extends Base {
969
1061
  }
970
1062
  /** Delete this message. */
971
1063
  async delete() {
972
- await this.client.rest.delete(import_types5.Routes.channelMessage(this.channelId, this.id));
1064
+ await this.client.rest.delete(import_types6.Routes.channelMessage(this.channelId, this.id));
973
1065
  this.client._removeMessageFromCache(this.channelId, this.id);
974
1066
  }
975
1067
  /** Delete a specific attachment from this message. */
976
1068
  async deleteAttachment(attachmentId) {
977
1069
  await this.client.rest.delete(
978
- import_types5.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
1070
+ import_types6.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
979
1071
  { auth: true }
980
1072
  );
981
1073
  this.attachments.delete(attachmentId);
982
1074
  }
983
1075
  /** Pin this message in the channel. */
984
1076
  async pin() {
985
- await this.client.rest.put(import_types5.Routes.channelPinMessage(this.channelId, this.id));
1077
+ await this.client.rest.put(import_types6.Routes.channelPinMessage(this.channelId, this.id));
986
1078
  this.pinned = true;
987
1079
  }
988
1080
  /** Unpin this message from the channel. */
989
1081
  async unpin() {
990
- await this.client.rest.delete(import_types5.Routes.channelPinMessage(this.channelId, this.id));
1082
+ await this.client.rest.delete(import_types6.Routes.channelPinMessage(this.channelId, this.id));
991
1083
  this.pinned = false;
992
1084
  }
993
1085
  /** React to this message with an emoji. */
@@ -1068,12 +1160,12 @@ var MessageManager = class {
1068
1160
  async fetchOne(messageId) {
1069
1161
  try {
1070
1162
  const data = await this.client.rest.get(
1071
- import_types7.Routes.channelMessage(this.channelId, messageId)
1163
+ import_types8.Routes.channelMessage(this.channelId, messageId)
1072
1164
  );
1073
1165
  return this.wrap(data);
1074
1166
  } catch (err) {
1075
- if (err instanceof import_rest.RateLimitError) throw err;
1076
- if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
1167
+ if (err instanceof import_rest2.RateLimitError) throw err;
1168
+ if (err instanceof import_rest2.FluxerAPIError && err.statusCode === 404) {
1077
1169
  throw new import_util.FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
1078
1170
  code: import_util2.ErrorCodes.MessageNotFound,
1079
1171
  cause: err
@@ -1094,7 +1186,7 @@ var MessageManager = class {
1094
1186
  const value = options[key];
1095
1187
  if (value != null && value !== "") qs2.set(key, String(value));
1096
1188
  }
1097
- const base = import_types7.Routes.channelMessages(this.channelId);
1189
+ const base = import_types8.Routes.channelMessages(this.channelId);
1098
1190
  const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
1099
1191
  const collection = new import_collection3.Collection();
1100
1192
  for (const msg of data) collection.set(msg.id, this.wrap(msg));
@@ -1103,7 +1195,7 @@ var MessageManager = class {
1103
1195
  };
1104
1196
 
1105
1197
  // src/structures/channel/attachments.ts
1106
- var import_types8 = require("@fluxerjs/types");
1198
+ var import_types9 = require("@fluxerjs/types");
1107
1199
  function asBytes(data) {
1108
1200
  const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
1109
1201
  const out = new Uint8Array(src.byteLength);
@@ -1124,7 +1216,7 @@ async function putBlob(url, body, contentType) {
1124
1216
  }
1125
1217
  async function uploadAttachmentsForSend(client, channelId, files) {
1126
1218
  const plan = await client.rest.post(
1127
- import_types8.Routes.channelAttachments(channelId),
1219
+ import_types9.Routes.channelAttachments(channelId),
1128
1220
  {
1129
1221
  body: {
1130
1222
  attachments: files.map((f) => ({
@@ -1170,7 +1262,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
1170
1262
  });
1171
1263
  }
1172
1264
  if (multipart.length) {
1173
- await client.rest.post(import_types8.Routes.channelAttachmentsComplete(channelId), {
1265
+ await client.rest.post(import_types9.Routes.channelAttachmentsComplete(channelId), {
1174
1266
  body: { uploads: multipart },
1175
1267
  auth: true
1176
1268
  });
@@ -1229,11 +1321,11 @@ var Channel = class extends Base {
1229
1321
  }
1230
1322
  /** Check if this is a DM, group DM, or personal notes channel. */
1231
1323
  isDM() {
1232
- return this.type === import_types9.ChannelType.DM || this.type === import_types9.ChannelType.GroupDM || this.type === import_types9.ChannelType.DMPersonalNotes;
1324
+ return this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes;
1233
1325
  }
1234
1326
  /** Check if this is a personal notes channel. */
1235
1327
  isPersonalNotes() {
1236
- return this.type === import_types9.ChannelType.DMPersonalNotes;
1328
+ return this.type === import_types10.ChannelType.DMPersonalNotes;
1237
1329
  }
1238
1330
  /** Check if this is a voice channel. */
1239
1331
  isVoice() {
@@ -1264,7 +1356,7 @@ var Channel = class extends Base {
1264
1356
  }
1265
1357
  if (ids.length === 0) return [];
1266
1358
  if (ids.length === 1) {
1267
- await this.client.rest.delete(import_types9.Routes.channelMessage(this.id, ids[0]), { auth: true });
1359
+ await this.client.rest.delete(import_types10.Routes.channelMessage(this.id, ids[0]), { auth: true });
1268
1360
  this.client._removeMessageFromCache(this.id, ids[0]);
1269
1361
  return ids;
1270
1362
  }
@@ -1273,7 +1365,7 @@ var Channel = class extends Base {
1273
1365
  code: import_util2.ErrorCodes.InvalidBulkDelete
1274
1366
  });
1275
1367
  }
1276
- await this.client.rest.post(import_types9.Routes.channelBulkDelete(this.id), {
1368
+ await this.client.rest.post(import_types10.Routes.channelBulkDelete(this.id), {
1277
1369
  body: { message_ids: ids },
1278
1370
  auth: true
1279
1371
  });
@@ -1283,23 +1375,23 @@ var Channel = class extends Base {
1283
1375
  /** Delete all messages sent by the bot in this channel (user account feature). */
1284
1376
  async bulkDeleteMyMessages(options) {
1285
1377
  const body = options ? toSudoBody(options) : void 0;
1286
- await this.client.rest.post(import_types9.Routes.channelBulkDeleteMine(this.id), {
1378
+ await this.client.rest.post(import_types10.Routes.channelBulkDeleteMine(this.id), {
1287
1379
  body: body && Object.keys(body).length ? body : void 0,
1288
1380
  auth: true
1289
1381
  });
1290
1382
  }
1291
1383
  /** Mark all pinned messages as read in this channel. */
1292
1384
  async acknowledgePins() {
1293
- await this.client.rest.post(import_types9.Routes.channelPinsAck(this.id), { auth: true });
1385
+ await this.client.rest.post(import_types10.Routes.channelPinsAck(this.id), { auth: true });
1294
1386
  }
1295
1387
  /** Clear the read state for this channel. */
1296
1388
  async clearReadState() {
1297
- await this.client.rest.delete(import_types9.Routes.channelMessagesAck(this.id), { auth: true });
1389
+ await this.client.rest.delete(import_types10.Routes.channelMessagesAck(this.id), { auth: true });
1298
1390
  }
1299
1391
  /** Request upload URLs for attachments before sending a message. */
1300
1392
  async requestAttachmentUploads(attachments) {
1301
1393
  const data = await this.client.rest.post(
1302
- import_types9.Routes.channelAttachments(this.id),
1394
+ import_types10.Routes.channelAttachments(this.id),
1303
1395
  {
1304
1396
  body: toAttachmentUploadPlanBody(attachments),
1305
1397
  auth: true
@@ -1310,7 +1402,7 @@ var Channel = class extends Base {
1310
1402
  /** Complete the attachment upload flow after uploading to the CDN. */
1311
1403
  async completeAttachmentUploads(uploads) {
1312
1404
  const data = await this.client.rest.post(
1313
- import_types9.Routes.channelAttachmentsComplete(this.id),
1405
+ import_types10.Routes.channelAttachmentsComplete(this.id),
1314
1406
  {
1315
1407
  body: toAttachmentUploadCompleteBody(uploads),
1316
1408
  auth: true
@@ -1326,11 +1418,11 @@ var Channel = class extends Base {
1326
1418
  }
1327
1419
  /** Trigger the typing indicator in this channel. */
1328
1420
  async sendTyping() {
1329
- await this.client.rest.post(import_types9.Routes.channelTyping(this.id), { auth: true });
1421
+ await this.client.rest.post(import_types10.Routes.channelTyping(this.id), { auth: true });
1330
1422
  }
1331
1423
  /** Fetch available RTC regions for voice channels. */
1332
1424
  async fetchRtcRegions() {
1333
- const data = await this.client.rest.get(import_types9.Routes.channelRtcRegions(this.id), {
1425
+ const data = await this.client.rest.get(import_types10.Routes.channelRtcRegions(this.id), {
1334
1426
  auth: true
1335
1427
  });
1336
1428
  return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
@@ -1338,7 +1430,7 @@ var Channel = class extends Base {
1338
1430
  /** Fetch slowmode state for this channel. */
1339
1431
  async fetchSlowmode() {
1340
1432
  const data = await this.client.rest.get(
1341
- import_types9.Routes.channelSlowmode(this.id),
1433
+ import_types10.Routes.channelSlowmode(this.id),
1342
1434
  { auth: true }
1343
1435
  );
1344
1436
  return {
@@ -1354,14 +1446,14 @@ var Channel = class extends Base {
1354
1446
  };
1355
1447
 
1356
1448
  // src/structures/channel/guild.ts
1357
- var import_types13 = require("@fluxerjs/types");
1449
+ var import_types14 = require("@fluxerjs/types");
1358
1450
  var import_util3 = require("@fluxerjs/util");
1359
1451
 
1360
1452
  // src/structures/Invite.ts
1361
- var import_types10 = require("@fluxerjs/types");
1453
+ var import_types11 = require("@fluxerjs/types");
1362
1454
 
1363
1455
  // src/util/Constants.ts
1364
- var import_rest2 = require("@fluxerjs/rest");
1456
+ var import_rest3 = require("@fluxerjs/rest");
1365
1457
  var CDN_URL = "https://fluxerusercontent.com";
1366
1458
  var STATIC_CDN_URL = "https://fluxerstatic.com";
1367
1459
 
@@ -1545,12 +1637,12 @@ var Invite = class _Invite extends Base {
1545
1637
  this.client = client;
1546
1638
  this.code = data.code;
1547
1639
  this.type = data.type;
1548
- this.guild = (0, import_types10.isGuildInvite)(data) ? data.guild : null;
1549
- this.channel = (0, import_types10.isGuildInvite)(data) || (0, import_types10.isGroupDmInvite)(data) ? data.channel : null;
1550
- this.pack = (0, import_types10.isPackInvite)(data) ? data.pack : null;
1640
+ this.guild = (0, import_types11.isGuildInvite)(data) ? data.guild : null;
1641
+ this.channel = (0, import_types11.isGuildInvite)(data) || (0, import_types11.isGroupDmInvite)(data) ? data.channel : null;
1642
+ this.pack = (0, import_types11.isPackInvite)(data) ? data.pack : null;
1551
1643
  this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
1552
- this.memberCount = (0, import_types10.isPackInvite)(data) ? null : data.member_count ?? null;
1553
- this.presenceCount = (0, import_types10.isGuildInvite)(data) ? data.presence_count ?? null : null;
1644
+ this.memberCount = (0, import_types11.isPackInvite)(data) ? null : data.member_count ?? null;
1645
+ this.presenceCount = (0, import_types11.isGuildInvite)(data) ? data.presence_count ?? null : null;
1554
1646
  this.expiresAt = data.expires_at ?? null;
1555
1647
  this.temporary = data.temporary ?? null;
1556
1648
  this.createdAt = data.created_at ?? null;
@@ -1559,13 +1651,13 @@ var Invite = class _Invite extends Base {
1559
1651
  this.maxAge = data.max_age ?? null;
1560
1652
  }
1561
1653
  isGuild() {
1562
- return this.type === import_types10.InviteType.Guild;
1654
+ return this.type === import_types11.InviteType.Guild;
1563
1655
  }
1564
1656
  isGroupDM() {
1565
- return this.type === import_types10.InviteType.GroupDM;
1657
+ return this.type === import_types11.InviteType.GroupDM;
1566
1658
  }
1567
1659
  isPack() {
1568
- return this.type === import_types10.InviteType.EmojiPack || this.type === import_types10.InviteType.StickerPack;
1660
+ return this.type === import_types11.InviteType.EmojiPack || this.type === import_types11.InviteType.StickerPack;
1569
1661
  }
1570
1662
  /** Full invite URL (uses this client's instance invite base). */
1571
1663
  get url() {
@@ -1577,18 +1669,18 @@ var Invite = class _Invite extends Base {
1577
1669
  }
1578
1670
  /** Fetch invite metadata by code or URL (does not join). */
1579
1671
  static async fetch(client, codeOrUrl) {
1580
- const data = await client.rest.get(import_types10.Routes.invite(parseInviteCode(codeOrUrl)));
1672
+ const data = await client.rest.get(import_types11.Routes.invite(parseInviteCode(codeOrUrl)));
1581
1673
  return new _Invite(client, data);
1582
1674
  }
1583
1675
  /** Delete this invite. Requires Manage Guild or Create Instant Invite. */
1584
1676
  async delete() {
1585
- await this.client.rest.delete(import_types10.Routes.invite(this.code), { auth: true });
1677
+ await this.client.rest.delete(import_types11.Routes.invite(this.code), { auth: true });
1586
1678
  }
1587
1679
  };
1588
1680
 
1589
1681
  // src/structures/Webhook.ts
1590
1682
  var import_builders4 = require("@fluxerjs/builders");
1591
- var import_types11 = require("@fluxerjs/types");
1683
+ var import_types12 = require("@fluxerjs/types");
1592
1684
 
1593
1685
  // src/util/cdn.ts
1594
1686
  function mediaBase(options) {
@@ -1688,10 +1780,10 @@ var Webhook = class _Webhook extends Base {
1688
1780
  /** Delete this webhook (token auth when available, otherwise bot auth). */
1689
1781
  async delete() {
1690
1782
  if (this.token) {
1691
- await this.client.rest.delete(import_types11.Routes.webhookExecute(this.id, this.token), { auth: false });
1783
+ await this.client.rest.delete(import_types12.Routes.webhookExecute(this.id, this.token), { auth: false });
1692
1784
  return;
1693
1785
  }
1694
- await this.client.rest.delete(import_types11.Routes.webhook(this.id), { auth: true });
1786
+ await this.client.rest.delete(import_types12.Routes.webhook(this.id), { auth: true });
1695
1787
  }
1696
1788
  /**
1697
1789
  * Edit name/avatar. With bot auth (no token), `channelId` may also be set.
@@ -1703,10 +1795,10 @@ var Webhook = class _Webhook extends Base {
1703
1795
  if (!this.token && options.channelId !== void 0) {
1704
1796
  body.channel_id = options.channelId;
1705
1797
  }
1706
- const data = this.token ? await this.client.rest.patch(import_types11.Routes.webhookExecute(this.id, this.token), {
1798
+ const data = this.token ? await this.client.rest.patch(import_types12.Routes.webhookExecute(this.id, this.token), {
1707
1799
  body,
1708
1800
  auth: false
1709
- }) : await this.client.rest.patch(import_types11.Routes.webhook(this.id), { body, auth: true });
1801
+ }) : await this.client.rest.patch(import_types12.Routes.webhook(this.id), { body, auth: true });
1710
1802
  this.name = data.name ?? this.name;
1711
1803
  this.avatar = data.avatar ?? null;
1712
1804
  if (!this.token) this.channelId = data.channel_id ?? this.channelId;
@@ -1727,7 +1819,7 @@ var Webhook = class _Webhook extends Base {
1727
1819
  if (overrides.avatarUrl !== void 0) {
1728
1820
  body.avatar_url = overrides.avatarUrl;
1729
1821
  }
1730
- const route = `${import_types11.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1822
+ const route = `${import_types12.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1731
1823
  const data = await this.client.rest.post(route, {
1732
1824
  body,
1733
1825
  ...files?.length ? { files } : {},
@@ -1768,7 +1860,7 @@ var Webhook = class _Webhook extends Base {
1768
1860
  }
1769
1861
  /** Fetch a webhook by ID (bot auth; no token). */
1770
1862
  static async fetch(client, webhookId) {
1771
- const data = await client.rest.get(import_types11.Routes.webhook(webhookId));
1863
+ const data = await client.rest.get(import_types12.Routes.webhook(webhookId));
1772
1864
  return new _Webhook(client, data);
1773
1865
  }
1774
1866
  /** Build a webhook from a stored id + token (e.g. webhook URL). */
@@ -1793,12 +1885,12 @@ var Webhook = class _Webhook extends Base {
1793
1885
  return this.token;
1794
1886
  }
1795
1887
  messageRoute(messageId) {
1796
- return import_types11.Routes.webhookMessage(this.id, this.requireToken(), messageId);
1888
+ return import_types12.Routes.webhookMessage(this.id, this.requireToken(), messageId);
1797
1889
  }
1798
1890
  };
1799
1891
 
1800
1892
  // src/structures/channel/textCapable.ts
1801
- var import_types12 = require("@fluxerjs/types");
1893
+ var import_types13 = require("@fluxerjs/types");
1802
1894
 
1803
1895
  // src/util/MessageCollector.ts
1804
1896
  var import_events2 = require("events");
@@ -1859,7 +1951,7 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
1859
1951
  if (options?.before) params.set("before", options.before);
1860
1952
  const qs2 = params.toString();
1861
1953
  const data = await client.rest.get(
1862
- import_types12.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1954
+ import_types13.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1863
1955
  );
1864
1956
  const items = data.items ?? [];
1865
1957
  return {
@@ -1875,7 +1967,7 @@ function TextCapable(Base2) {
1875
1967
  const payload = await prepareMessagePostPayload(options, {
1876
1968
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
1877
1969
  });
1878
- const data = await this.client.rest.post(import_types12.Routes.channelMessages(this.id), payload);
1970
+ const data = await this.client.rest.post(import_types13.Routes.channelMessages(this.id), payload);
1879
1971
  this.client._addMessageToCache(this.id, data);
1880
1972
  return new Message(this.client, data);
1881
1973
  }
@@ -1932,7 +2024,7 @@ var GuildChannel = class extends Channel {
1932
2024
  }
1933
2025
  /** Create a webhook for this channel. Requires Manage Webhooks. */
1934
2026
  async createWebhook(options) {
1935
- const data = await this.client.rest.post(import_types13.Routes.channelWebhooks(this.id), {
2027
+ const data = await this.client.rest.post(import_types14.Routes.channelWebhooks(this.id), {
1936
2028
  body: options,
1937
2029
  auth: true
1938
2030
  });
@@ -1940,13 +2032,13 @@ var GuildChannel = class extends Channel {
1940
2032
  }
1941
2033
  /** Fetch all webhooks in this channel. Requires Manage Webhooks. */
1942
2034
  async fetchWebhooks() {
1943
- const data = await this.client.rest.get(import_types13.Routes.channelWebhooks(this.id));
2035
+ const data = await this.client.rest.get(import_types14.Routes.channelWebhooks(this.id));
1944
2036
  return data.map((w) => new Webhook(this.client, w));
1945
2037
  }
1946
2038
  /** Create an invite for this channel. Requires Create Instant Invite. */
1947
2039
  async createInvite(options) {
1948
2040
  const body = options ? toChannelInviteBody(options) : {};
1949
- const data = await this.client.rest.post(import_types13.Routes.channelInvites(this.id), {
2041
+ const data = await this.client.rest.post(import_types14.Routes.channelInvites(this.id), {
1950
2042
  body: Object.keys(body).length ? body : void 0,
1951
2043
  auth: true
1952
2044
  });
@@ -1954,12 +2046,12 @@ var GuildChannel = class extends Channel {
1954
2046
  }
1955
2047
  /** Fetch all invites for this channel. Requires Manage Channels. */
1956
2048
  async fetchInvites() {
1957
- const data = await this.client.rest.get(import_types13.Routes.channelInvites(this.id));
2049
+ const data = await this.client.rest.get(import_types14.Routes.channelInvites(this.id));
1958
2050
  return data.map((i) => new Invite(this.client, i));
1959
2051
  }
1960
2052
  /** Edit or create a permission overwrite. Requires Manage Roles. */
1961
2053
  async editPermission(overwriteId, options) {
1962
- await this.client.rest.put(import_types13.Routes.channelPermission(this.id, overwriteId), {
2054
+ await this.client.rest.put(import_types14.Routes.channelPermission(this.id, overwriteId), {
1963
2055
  body: options,
1964
2056
  auth: true
1965
2057
  });
@@ -1975,7 +2067,7 @@ var GuildChannel = class extends Channel {
1975
2067
  }
1976
2068
  /** Delete a permission overwrite. Requires Manage Roles. */
1977
2069
  async deletePermission(overwriteId) {
1978
- await this.client.rest.delete(import_types13.Routes.channelPermission(this.id, overwriteId), { auth: true });
2070
+ await this.client.rest.delete(import_types14.Routes.channelPermission(this.id, overwriteId), { auth: true });
1979
2071
  const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
1980
2072
  if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
1981
2073
  }
@@ -1988,7 +2080,7 @@ var GuildChannel = class extends Channel {
1988
2080
  }
1989
2081
  /** Edit this channel's settings. Requires Manage Channels. */
1990
2082
  async edit(options) {
1991
- const data = await this.client.rest.patch(import_types13.Routes.channel(this.id), {
2083
+ const data = await this.client.rest.patch(import_types14.Routes.channel(this.id), {
1992
2084
  body: toChannelEditBody(options),
1993
2085
  auth: true
1994
2086
  });
@@ -2008,7 +2100,7 @@ var GuildChannel = class extends Channel {
2008
2100
  const qs2 = params.toString();
2009
2101
  const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
2010
2102
  const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
2011
- await this.client.rest.delete(import_types13.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
2103
+ await this.client.rest.delete(import_types14.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
2012
2104
  body,
2013
2105
  auth: true
2014
2106
  });
@@ -2070,7 +2162,7 @@ var LinkChannel = class extends GuildChannel {
2070
2162
  };
2071
2163
 
2072
2164
  // src/structures/channel/dm.ts
2073
- var import_types14 = require("@fluxerjs/types");
2165
+ var import_types15 = require("@fluxerjs/types");
2074
2166
  var DMChannel = class extends TextCapable(Channel) {
2075
2167
  /** ID of the last message sent in this channel. */
2076
2168
  lastMessageId;
@@ -2090,34 +2182,34 @@ var DMChannel = class extends TextCapable(Channel) {
2090
2182
  }
2091
2183
  /** Purge all messages from personal notes. Only works on personal notes channels. */
2092
2184
  async purgeMessages() {
2093
- if (this.type !== import_types14.ChannelType.DMPersonalNotes) {
2185
+ if (this.type !== import_types15.ChannelType.DMPersonalNotes) {
2094
2186
  throw new import_util.FluxerError("purgeMessages is only available on personal notes channels", {
2095
2187
  code: import_util2.ErrorCodes.InvalidChannelType
2096
2188
  });
2097
2189
  }
2098
2190
  const data = await this.client.rest.post(
2099
- import_types14.Routes.channelMessagesPurge(this.id),
2191
+ import_types15.Routes.channelMessagesPurge(this.id),
2100
2192
  { auth: true }
2101
2193
  );
2102
2194
  return data.deleted_count;
2103
2195
  }
2104
2196
  /** Pin this DM channel to the top of the DM list. */
2105
2197
  async pinInList() {
2106
- await this.client.rest.put(import_types14.Routes.userMeChannelPin(this.id), { auth: true });
2198
+ await this.client.rest.put(import_types15.Routes.userMeChannelPin(this.id), { auth: true });
2107
2199
  }
2108
2200
  /** Unpin this DM channel from the DM list. */
2109
2201
  async unpinFromList() {
2110
- await this.client.rest.delete(import_types14.Routes.userMeChannelPin(this.id), { auth: true });
2202
+ await this.client.rest.delete(import_types15.Routes.userMeChannelPin(this.id), { auth: true });
2111
2203
  }
2112
2204
  /** Add a user to this group DM. */
2113
2205
  async addRecipient(userId) {
2114
- await this.client.rest.put(import_types14.Routes.channelRecipient(this.id, userId), { auth: true });
2206
+ await this.client.rest.put(import_types15.Routes.channelRecipient(this.id, userId), { auth: true });
2115
2207
  const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
2116
2208
  if (user) this.recipients.push(user);
2117
2209
  }
2118
2210
  /** Remove a user from this group DM. */
2119
2211
  async removeRecipient(userId, options) {
2120
- const url = import_types14.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2212
+ const url = import_types15.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2121
2213
  await this.client.rest.delete(url, { auth: true });
2122
2214
  const idx = this.recipients.findIndex((u) => u.id === userId);
2123
2215
  if (idx >= 0) this.recipients.splice(idx, 1);
@@ -2125,17 +2217,17 @@ var DMChannel = class extends TextCapable(Channel) {
2125
2217
  };
2126
2218
 
2127
2219
  // src/structures/channel/factory.ts
2128
- var import_types15 = require("@fluxerjs/types");
2220
+ var import_types16 = require("@fluxerjs/types");
2129
2221
  var GUILD_FACTORIES = {
2130
- [import_types15.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
2131
- [import_types15.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
2132
- [import_types15.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
2133
- [import_types15.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d)
2222
+ [import_types16.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
2223
+ [import_types16.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
2224
+ [import_types16.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
2225
+ [import_types16.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d)
2134
2226
  };
2135
2227
  var DM_TYPES = /* @__PURE__ */ new Set([
2136
- import_types15.ChannelType.DM,
2137
- import_types15.ChannelType.GroupDM,
2138
- import_types15.ChannelType.DMPersonalNotes
2228
+ import_types16.ChannelType.DM,
2229
+ import_types16.ChannelType.GroupDM,
2230
+ import_types16.ChannelType.DMPersonalNotes
2139
2231
  ]);
2140
2232
  function createDM(client, data) {
2141
2233
  return new DMChannel(client, data);
@@ -2155,8 +2247,8 @@ Channel.createDM = createDM;
2155
2247
 
2156
2248
  // src/client/ChannelManager.ts
2157
2249
  function rethrowNotFound(err, message, code) {
2158
- if (err instanceof import_rest3.RateLimitError) throw err;
2159
- if (err instanceof import_rest3.FluxerAPIError && err.statusCode === 404) {
2250
+ if (err instanceof import_rest4.RateLimitError) throw err;
2251
+ if (err instanceof import_rest4.FluxerAPIError && err.statusCode === 404) {
2160
2252
  throw new import_util.FluxerError(message, { code, cause: err });
2161
2253
  }
2162
2254
  throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
@@ -2188,7 +2280,7 @@ var ChannelManager = class extends import_collection5.Collection {
2188
2280
  const cached = this.get(channelId);
2189
2281
  if (cached) return cached;
2190
2282
  try {
2191
- const data = await this.client.rest.get(import_types16.Routes.channel(channelId));
2283
+ const data = await this.client.rest.get(import_types17.Routes.channel(channelId));
2192
2284
  const channel = Channel.fromOrCreate(this.client, data);
2193
2285
  if (!channel) {
2194
2286
  throw new import_util.FluxerError("Channel data invalid or unsupported type", {
@@ -2221,7 +2313,7 @@ var ChannelManager = class extends import_collection5.Collection {
2221
2313
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
2222
2314
  });
2223
2315
  const data = await this.client.rest.post(
2224
- import_types16.Routes.channelMessages(channelId),
2316
+ import_types17.Routes.channelMessages(channelId),
2225
2317
  postPayload
2226
2318
  );
2227
2319
  this.client._addMessageToCache(channelId, data);
@@ -2231,29 +2323,29 @@ var ChannelManager = class extends import_collection5.Collection {
2231
2323
 
2232
2324
  // src/client/GuildManager.ts
2233
2325
  var import_collection9 = require("@fluxerjs/collection");
2234
- var import_types36 = require("@fluxerjs/types");
2235
- var import_rest5 = require("@fluxerjs/rest");
2326
+ var import_types37 = require("@fluxerjs/types");
2327
+ var import_rest6 = require("@fluxerjs/rest");
2236
2328
 
2237
2329
  // src/structures/guild/Guild.ts
2238
2330
  var import_collection8 = require("@fluxerjs/collection");
2239
- var import_types35 = require("@fluxerjs/types");
2331
+ var import_types36 = require("@fluxerjs/types");
2240
2332
 
2241
2333
  // src/client/GuildMemberManager.ts
2242
2334
  var import_collection7 = require("@fluxerjs/collection");
2243
- var import_types20 = require("@fluxerjs/types");
2335
+ var import_types21 = require("@fluxerjs/types");
2244
2336
 
2245
2337
  // src/structures/GuildMember.ts
2246
- var import_types19 = require("@fluxerjs/types");
2338
+ var import_types20 = require("@fluxerjs/types");
2247
2339
  var import_util5 = require("@fluxerjs/util");
2248
2340
 
2249
2341
  // src/util/permissions.ts
2250
- var import_types17 = require("@fluxerjs/types");
2342
+ var import_types18 = require("@fluxerjs/types");
2251
2343
  var import_util4 = require("@fluxerjs/util");
2252
2344
  function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
2253
2345
  if (isOwner) return import_util4.ALL_PERMISSIONS_BIGINT;
2254
2346
  let perms = basePermissions;
2255
2347
  for (const overwrite of overwrites ?? []) {
2256
- const applies = overwrite.type === import_types17.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types17.OverwriteType.Member && overwrite.id === memberId;
2348
+ const applies = overwrite.type === import_types18.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types18.OverwriteType.Member && overwrite.id === memberId;
2257
2349
  if (!applies) continue;
2258
2350
  const allow = BigInt(overwrite.allow || "0");
2259
2351
  const deny = BigInt(overwrite.deny || "0");
@@ -2264,7 +2356,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
2264
2356
 
2265
2357
  // src/structures/GuildMemberRoleManager.ts
2266
2358
  var import_collection6 = require("@fluxerjs/collection");
2267
- var import_types18 = require("@fluxerjs/types");
2359
+ var import_types19 = require("@fluxerjs/types");
2268
2360
  function roleId(roleOrId) {
2269
2361
  return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
2270
2362
  }
@@ -2293,7 +2385,7 @@ var GuildMemberRoleManager = class {
2293
2385
  const id = roleId(roleOrId);
2294
2386
  if (this.ids.includes(id)) return;
2295
2387
  await this.member.client.rest.put(
2296
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2388
+ import_types19.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2297
2389
  );
2298
2390
  this.ids.push(id);
2299
2391
  }
@@ -2302,13 +2394,13 @@ var GuildMemberRoleManager = class {
2302
2394
  const idx = this.ids.indexOf(id);
2303
2395
  if (idx === -1) return;
2304
2396
  await this.member.client.rest.delete(
2305
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2397
+ import_types19.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
2306
2398
  );
2307
2399
  this.ids.splice(idx, 1);
2308
2400
  }
2309
2401
  async set(roleIds) {
2310
2402
  const data = await this.member.client.rest.patch(
2311
- import_types18.Routes.guildMember(this.member.guild.id, this.member.id),
2403
+ import_types19.Routes.guildMember(this.member.guild.id, this.member.id),
2312
2404
  { body: { roles: roleIds }, auth: true }
2313
2405
  );
2314
2406
  this.ids = data.roles ? [...data.roles] : [];
@@ -2435,7 +2527,7 @@ var GuildMember = class _GuildMember extends Base {
2435
2527
  /** PATCH member (`/members/@me` when editing the bot). */
2436
2528
  async edit(options) {
2437
2529
  const isMe = this.client.user?.id === this.id;
2438
- const route = isMe ? import_types19.Routes.guildMemberMe(this.guild.id) : import_types19.Routes.guildMember(this.guild.id, this.id);
2530
+ const route = isMe ? import_types20.Routes.guildMemberMe(this.guild.id) : import_types20.Routes.guildMember(this.guild.id, this.id);
2439
2531
  const data = await this.client.rest.patch(route, {
2440
2532
  body: toMemberEditBody(options),
2441
2533
  auth: true
@@ -2564,7 +2656,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2564
2656
  if (options?.limit != null) params.set("limit", String(options.limit));
2565
2657
  if (options?.after) params.set("after", options.after);
2566
2658
  const qs2 = params.toString();
2567
- const url = import_types20.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2659
+ const url = import_types21.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2568
2660
  const data = await this.guild.client.rest.get(url, { auth: true });
2569
2661
  const members = [];
2570
2662
  for (const m of data) {
@@ -2587,7 +2679,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2587
2679
  */
2588
2680
  async search(options = {}) {
2589
2681
  const data = await this.guild.client.rest.post(
2590
- import_types20.Routes.guildMembersSearch(this.guild.id),
2682
+ import_types21.Routes.guildMembersSearch(this.guild.id),
2591
2683
  { body: toMemberSearchBody(options), auth: true }
2592
2684
  );
2593
2685
  const offset = options.offset ?? 0;
@@ -2613,7 +2705,7 @@ var GuildMemberManager = class extends import_collection7.Collection {
2613
2705
  };
2614
2706
 
2615
2707
  // src/structures/Role.ts
2616
- var import_types21 = require("@fluxerjs/types");
2708
+ var import_types22 = require("@fluxerjs/types");
2617
2709
  var import_util7 = require("@fluxerjs/util");
2618
2710
 
2619
2711
  // src/structures/roleOptions.ts
@@ -2726,7 +2818,7 @@ var Role = class _Role extends Base {
2726
2818
  */
2727
2819
  async edit(options) {
2728
2820
  const body = toRoleRequestBody(options);
2729
- const data = await this.client.rest.patch(import_types21.Routes.guildRole(this.guildId, this.id), {
2821
+ const data = await this.client.rest.patch(import_types22.Routes.guildRole(this.guildId, this.id), {
2730
2822
  body: Object.keys(body).length ? body : void 0,
2731
2823
  auth: true
2732
2824
  });
@@ -2737,18 +2829,18 @@ var Role = class _Role extends Base {
2737
2829
  * DELETE role. Requires Manage Roles.
2738
2830
  */
2739
2831
  async delete() {
2740
- await this.client.rest.delete(import_types21.Routes.guildRole(this.guildId, this.id), { auth: true });
2832
+ await this.client.rest.delete(import_types22.Routes.guildRole(this.guildId, this.id), { auth: true });
2741
2833
  this.client.guilds.get(this.guildId)?.roles.delete(this.id);
2742
2834
  }
2743
2835
  };
2744
2836
 
2745
2837
  // src/structures/guild/admin.ts
2746
- var import_types22 = require("@fluxerjs/types");
2838
+ var import_types23 = require("@fluxerjs/types");
2747
2839
 
2748
2840
  // src/structures/guild/http.ts
2749
- var import_rest4 = require("@fluxerjs/rest");
2841
+ var import_rest5 = require("@fluxerjs/rest");
2750
2842
  function httpStatus(err) {
2751
- if (err instanceof import_rest4.FluxerAPIError) return err.statusCode;
2843
+ if (err instanceof import_rest5.FluxerAPIError) return err.statusCode;
2752
2844
  if (typeof err === "object" && err !== null && "statusCode" in err) {
2753
2845
  const code = err.statusCode;
2754
2846
  return typeof code === "number" ? code : void 0;
@@ -2848,7 +2940,7 @@ function toVanityPayload(data) {
2848
2940
  return { code: data.code ?? null, uses: data.uses };
2849
2941
  }
2850
2942
  async function fetchAuditLogs(guild, options) {
2851
- const url = import_types22.Routes.guildAuditLogs(guild.id) + qs({
2943
+ const url = import_types23.Routes.guildAuditLogs(guild.id) + qs({
2852
2944
  limit: options?.limit,
2853
2945
  before: options?.before,
2854
2946
  after: options?.after,
@@ -2869,7 +2961,7 @@ async function fetchAuditLogs(guild, options) {
2869
2961
  };
2870
2962
  }
2871
2963
  async function editGuild(guild, options) {
2872
- const data = await guild.client.rest.patch(import_types22.Routes.guild(guild.id), {
2964
+ const data = await guild.client.rest.patch(import_types23.Routes.guild(guild.id), {
2873
2965
  body: toGuildEditBody(options),
2874
2966
  auth: true
2875
2967
  });
@@ -2877,13 +2969,13 @@ async function editGuild(guild, options) {
2877
2969
  return guild;
2878
2970
  }
2879
2971
  async function fetchVanityURL(guild) {
2880
- const data = await guild.client.rest.get(import_types22.Routes.guildVanityUrl(guild.id), {
2972
+ const data = await guild.client.rest.get(import_types23.Routes.guildVanityUrl(guild.id), {
2881
2973
  auth: true
2882
2974
  });
2883
2975
  return toVanityPayload(data);
2884
2976
  }
2885
2977
  async function editVanityURL(guild, code) {
2886
- const data = await guild.client.rest.patch(import_types22.Routes.guildVanityUrl(guild.id), {
2978
+ const data = await guild.client.rest.patch(import_types23.Routes.guildVanityUrl(guild.id), {
2887
2979
  body: { code },
2888
2980
  auth: true
2889
2981
  });
@@ -2891,14 +2983,14 @@ async function editVanityURL(guild, code) {
2891
2983
  return toVanityPayload(data);
2892
2984
  }
2893
2985
  async function fetchDiscoveryStatus(guild) {
2894
- const data = await guild.client.rest.get(import_types22.Routes.guildDiscovery(guild.id), {
2986
+ const data = await guild.client.rest.get(import_types23.Routes.guildDiscovery(guild.id), {
2895
2987
  auth: true
2896
2988
  });
2897
2989
  return toDiscoveryStatusPayload(data);
2898
2990
  }
2899
2991
  async function applyForDiscovery(guild, options) {
2900
2992
  const data = await guild.client.rest.post(
2901
- import_types22.Routes.guildDiscovery(guild.id),
2993
+ import_types23.Routes.guildDiscovery(guild.id),
2902
2994
  {
2903
2995
  body: toDiscoveryBody(options),
2904
2996
  auth: true
@@ -2908,7 +3000,7 @@ async function applyForDiscovery(guild, options) {
2908
3000
  }
2909
3001
  async function editDiscoveryApplication(guild, options) {
2910
3002
  const data = await guild.client.rest.patch(
2911
- import_types22.Routes.guildDiscovery(guild.id),
3003
+ import_types23.Routes.guildDiscovery(guild.id),
2912
3004
  {
2913
3005
  body: toDiscoveryBody(options),
2914
3006
  auth: true
@@ -2917,28 +3009,28 @@ async function editDiscoveryApplication(guild, options) {
2917
3009
  return toDiscoveryApplicationPayload(data);
2918
3010
  }
2919
3011
  async function withdrawDiscoveryApplication(guild) {
2920
- await guild.client.rest.delete(import_types22.Routes.guildDiscovery(guild.id), { auth: true });
3012
+ await guild.client.rest.delete(import_types23.Routes.guildDiscovery(guild.id), { auth: true });
2921
3013
  }
2922
3014
  async function deleteGuild(guild, options) {
2923
3015
  const body = options ? toSudoBody(options) : {};
2924
- await guild.client.rest.post(import_types22.Routes.guildDelete(guild.id), {
3016
+ await guild.client.rest.post(import_types23.Routes.guildDelete(guild.id), {
2925
3017
  body,
2926
3018
  auth: true
2927
3019
  });
2928
3020
  guild.client.guilds.delete(guild.id);
2929
3021
  }
2930
3022
  async function transferOwnership(guild, newOwnerId, password) {
2931
- await guild.client.rest.post(import_types22.Routes.guildTransferOwnership(guild.id), {
3023
+ await guild.client.rest.post(import_types23.Routes.guildTransferOwnership(guild.id), {
2932
3024
  body: { new_owner_id: newOwnerId, ...password != null && { password } },
2933
3025
  auth: true
2934
3026
  });
2935
3027
  }
2936
3028
 
2937
3029
  // src/structures/guild/channels.ts
2938
- var import_types26 = require("@fluxerjs/types");
3030
+ var import_types27 = require("@fluxerjs/types");
2939
3031
 
2940
3032
  // src/structures/GuildEmoji.ts
2941
- var import_types24 = require("@fluxerjs/types");
3033
+ var import_types25 = require("@fluxerjs/types");
2942
3034
  var GuildEmoji = class extends Base {
2943
3035
  client;
2944
3036
  id;
@@ -2966,7 +3058,7 @@ var GuildEmoji = class extends Base {
2966
3058
  }
2967
3059
  /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
2968
3060
  async delete() {
2969
- await this.client.rest.delete(import_types24.Routes.guildEmoji(this.guildId, this.id), {
3061
+ await this.client.rest.delete(import_types25.Routes.guildEmoji(this.guildId, this.id), {
2970
3062
  auth: true
2971
3063
  });
2972
3064
  const guild = this.client.guilds.get(this.guildId);
@@ -2977,7 +3069,7 @@ var GuildEmoji = class extends Base {
2977
3069
  * Requires Manage Emojis and Stickers permission.
2978
3070
  */
2979
3071
  async edit(options) {
2980
- const data = await this.client.rest.patch(import_types24.Routes.guildEmoji(this.guildId, this.id), {
3072
+ const data = await this.client.rest.patch(import_types25.Routes.guildEmoji(this.guildId, this.id), {
2981
3073
  body: options,
2982
3074
  auth: true
2983
3075
  });
@@ -2987,7 +3079,7 @@ var GuildEmoji = class extends Base {
2987
3079
  };
2988
3080
 
2989
3081
  // src/structures/GuildSticker.ts
2990
- var import_types25 = require("@fluxerjs/types");
3082
+ var import_types26 = require("@fluxerjs/types");
2991
3083
  var GuildSticker = class extends Base {
2992
3084
  client;
2993
3085
  id;
@@ -3018,7 +3110,7 @@ var GuildSticker = class extends Base {
3018
3110
  }
3019
3111
  /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
3020
3112
  async delete() {
3021
- await this.client.rest.delete(import_types25.Routes.guildSticker(this.guildId, this.id), {
3113
+ await this.client.rest.delete(import_types26.Routes.guildSticker(this.guildId, this.id), {
3022
3114
  auth: true
3023
3115
  });
3024
3116
  }
@@ -3027,7 +3119,7 @@ var GuildSticker = class extends Base {
3027
3119
  * Requires Manage Emojis and Stickers permission.
3028
3120
  */
3029
3121
  async edit(options) {
3030
- const data = await this.client.rest.patch(import_types25.Routes.guildSticker(this.guildId, this.id), {
3122
+ const data = await this.client.rest.patch(import_types26.Routes.guildSticker(this.guildId, this.id), {
3031
3123
  body: options,
3032
3124
  auth: true
3033
3125
  });
@@ -3082,14 +3174,14 @@ function cacheSticker(guild, data) {
3082
3174
 
3083
3175
  // src/structures/guild/channels.ts
3084
3176
  async function createChannel(guild, data) {
3085
- const created = await guild.client.rest.post(import_types26.Routes.guildChannels(guild.id), {
3177
+ const created = await guild.client.rest.post(import_types27.Routes.guildChannels(guild.id), {
3086
3178
  body: data,
3087
3179
  auth: true
3088
3180
  });
3089
3181
  return cacheChannel(guild, created);
3090
3182
  }
3091
3183
  async function fetchChannels(guild) {
3092
- const data = await guild.client.rest.get(import_types26.Routes.guildChannels(guild.id));
3184
+ const data = await guild.client.rest.get(import_types27.Routes.guildChannels(guild.id));
3093
3185
  const channels = [];
3094
3186
  for (const ch of data) {
3095
3187
  const channel = cacheChannel(guild, ch);
@@ -3098,17 +3190,17 @@ async function fetchChannels(guild) {
3098
3190
  return channels;
3099
3191
  }
3100
3192
  async function setChannelPositions(guild, updates) {
3101
- await guild.client.rest.patch(import_types26.Routes.guildChannels(guild.id), {
3193
+ await guild.client.rest.patch(import_types27.Routes.guildChannels(guild.id), {
3102
3194
  body: toChannelPositionBody(updates),
3103
3195
  auth: true
3104
3196
  });
3105
3197
  }
3106
3198
  async function fetchWebhooks(guild) {
3107
- const data = await guild.client.rest.get(import_types26.Routes.guildWebhooks(guild.id));
3199
+ const data = await guild.client.rest.get(import_types27.Routes.guildWebhooks(guild.id));
3108
3200
  return data.map((w) => new Webhook(guild.client, w));
3109
3201
  }
3110
3202
  async function fetchInvites(guild) {
3111
- const data = await guild.client.rest.get(import_types26.Routes.guildInvites(guild.id));
3203
+ const data = await guild.client.rest.get(import_types27.Routes.guildInvites(guild.id));
3112
3204
  return data.map((invite) => new Invite(guild.client, invite));
3113
3205
  }
3114
3206
  async function fetchInvite(guild, codeOrUrl) {
@@ -3116,14 +3208,14 @@ async function fetchInvite(guild, codeOrUrl) {
3116
3208
  }
3117
3209
 
3118
3210
  // src/structures/guild/emojis.ts
3119
- var import_types28 = require("@fluxerjs/types");
3211
+ var import_types29 = require("@fluxerjs/types");
3120
3212
  async function fetchEmojis(guild) {
3121
- const data = await guild.client.rest.get(import_types28.Routes.guildEmojis(guild.id));
3213
+ const data = await guild.client.rest.get(import_types29.Routes.guildEmojis(guild.id));
3122
3214
  return data.map((e) => cacheEmoji(guild, e));
3123
3215
  }
3124
3216
  async function fetchEmoji(guild, emojiId) {
3125
3217
  try {
3126
- const data = await guild.client.rest.get(import_types28.Routes.guildEmoji(guild.id, emojiId));
3218
+ const data = await guild.client.rest.get(import_types29.Routes.guildEmoji(guild.id, emojiId));
3127
3219
  return cacheEmoji(guild, data);
3128
3220
  } catch (err) {
3129
3221
  rethrowNotFound2(
@@ -3134,14 +3226,14 @@ async function fetchEmoji(guild, emojiId) {
3134
3226
  }
3135
3227
  }
3136
3228
  async function createEmoji(guild, options) {
3137
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojis(guild.id), {
3229
+ const data = await guild.client.rest.post(import_types29.Routes.guildEmojis(guild.id), {
3138
3230
  body: options,
3139
3231
  auth: true
3140
3232
  });
3141
3233
  return cacheEmoji(guild, data);
3142
3234
  }
3143
3235
  async function cloneEmoji(guild, sourceEmojiId) {
3144
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojisClone(guild.id), {
3236
+ const data = await guild.client.rest.post(import_types29.Routes.guildEmojisClone(guild.id), {
3145
3237
  body: { source_emoji_id: sourceEmojiId },
3146
3238
  auth: true
3147
3239
  });
@@ -3149,18 +3241,18 @@ async function cloneEmoji(guild, sourceEmojiId) {
3149
3241
  }
3150
3242
  async function createEmojisBulk(guild, emojis) {
3151
3243
  const data = await guild.client.rest.post(
3152
- import_types28.Routes.guildEmojisBulk(guild.id),
3244
+ import_types29.Routes.guildEmojisBulk(guild.id),
3153
3245
  { body: { emojis }, auth: true }
3154
3246
  );
3155
3247
  return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
3156
3248
  }
3157
3249
 
3158
3250
  // src/structures/guild/members.ts
3159
- var import_types29 = require("@fluxerjs/types");
3251
+ var import_types30 = require("@fluxerjs/types");
3160
3252
  async function fetchMember(guild, userId) {
3161
3253
  try {
3162
3254
  const data = await guild.client.rest.get(
3163
- import_types29.Routes.guildMember(guild.id, userId)
3255
+ import_types30.Routes.guildMember(guild.id, userId)
3164
3256
  );
3165
3257
  return cacheMember(guild, data);
3166
3258
  } catch (err) {
@@ -3173,17 +3265,17 @@ async function fetchMember(guild, userId) {
3173
3265
  }
3174
3266
  async function fetchMe(guild) {
3175
3267
  const data = await guild.client.rest.get(
3176
- import_types29.Routes.guildMemberMe(guild.id),
3268
+ import_types30.Routes.guildMemberMe(guild.id),
3177
3269
  { auth: true }
3178
3270
  );
3179
3271
  return cacheMember(guild, data);
3180
3272
  }
3181
3273
 
3182
3274
  // src/structures/guild/moderation.ts
3183
- var import_types31 = require("@fluxerjs/types");
3275
+ var import_types32 = require("@fluxerjs/types");
3184
3276
 
3185
3277
  // src/structures/GuildBan.ts
3186
- var import_types30 = require("@fluxerjs/types");
3278
+ var import_types31 = require("@fluxerjs/types");
3187
3279
  var GuildBan = class extends Base {
3188
3280
  client;
3189
3281
  guildId;
@@ -3205,7 +3297,7 @@ var GuildBan = class extends Base {
3205
3297
  * Requires Ban Members permission.
3206
3298
  */
3207
3299
  async unban() {
3208
- await this.client.rest.delete(import_types30.Routes.guildBan(this.guildId, this.user.id), {
3300
+ await this.client.rest.delete(import_types31.Routes.guildBan(this.guildId, this.user.id), {
3209
3301
  auth: true
3210
3302
  });
3211
3303
  }
@@ -3214,40 +3306,40 @@ var GuildBan = class extends Base {
3214
3306
  // src/structures/guild/moderation.ts
3215
3307
  async function ban(guild, userId, options) {
3216
3308
  const body = options ? toGuildBanBody(options) : {};
3217
- await guild.client.rest.put(import_types31.Routes.guildBan(guild.id, userId), {
3309
+ await guild.client.rest.put(import_types32.Routes.guildBan(guild.id, userId), {
3218
3310
  body: Object.keys(body).length ? body : void 0,
3219
3311
  auth: true
3220
3312
  });
3221
3313
  }
3222
3314
  async function fetchBans(guild) {
3223
- const data = await guild.client.rest.get(import_types31.Routes.guildBans(guild.id));
3315
+ const data = await guild.client.rest.get(import_types32.Routes.guildBans(guild.id));
3224
3316
  return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
3225
3317
  }
3226
3318
  async function unban(guild, userId) {
3227
- await guild.client.rest.delete(import_types31.Routes.guildBan(guild.id, userId), { auth: true });
3319
+ await guild.client.rest.delete(import_types32.Routes.guildBan(guild.id, userId), { auth: true });
3228
3320
  }
3229
3321
  async function kick(guild, userId) {
3230
- await guild.client.rest.delete(import_types31.Routes.guildMember(guild.id, userId), { auth: true });
3322
+ await guild.client.rest.delete(import_types32.Routes.guildMember(guild.id, userId), { auth: true });
3231
3323
  }
3232
3324
 
3233
3325
  // src/structures/guild/roles.ts
3234
- var import_types33 = require("@fluxerjs/types");
3326
+ var import_types34 = require("@fluxerjs/types");
3235
3327
  var import_util8 = require("@fluxerjs/util");
3236
3328
  async function createRole(guild, options = {}) {
3237
3329
  const body = toRoleRequestBody(options);
3238
- const data = await guild.client.rest.post(import_types33.Routes.guildRoles(guild.id), {
3330
+ const data = await guild.client.rest.post(import_types34.Routes.guildRoles(guild.id), {
3239
3331
  body: Object.keys(body).length ? body : void 0,
3240
3332
  auth: true
3241
3333
  });
3242
3334
  return cacheRole(guild, data);
3243
3335
  }
3244
3336
  async function fetchRoles(guild) {
3245
- const data = await guild.client.rest.get(import_types33.Routes.guildRoles(guild.id));
3337
+ const data = await guild.client.rest.get(import_types34.Routes.guildRoles(guild.id));
3246
3338
  return data.map((r) => cacheRole(guild, r));
3247
3339
  }
3248
3340
  async function fetchRole(guild, roleId2) {
3249
3341
  try {
3250
- const data = await guild.client.rest.get(import_types33.Routes.guildRole(guild.id, roleId2));
3342
+ const data = await guild.client.rest.get(import_types34.Routes.guildRole(guild.id, roleId2));
3251
3343
  return cacheRole(guild, data);
3252
3344
  } catch (err) {
3253
3345
  rethrowNotFound2(
@@ -3265,7 +3357,7 @@ async function resolveRoleId(guild, arg) {
3265
3357
  const needle = trimmed.toLowerCase();
3266
3358
  const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
3267
3359
  if (cached) return cached.id;
3268
- const roles = await guild.client.rest.get(import_types33.Routes.guildRoles(guild.id));
3360
+ const roles = await guild.client.rest.get(import_types34.Routes.guildRoles(guild.id));
3269
3361
  const role = roles.find((r) => r.name?.toLowerCase() === needle);
3270
3362
  if (!role) return null;
3271
3363
  cacheRole(guild, role);
@@ -3274,7 +3366,7 @@ async function resolveRoleId(guild, arg) {
3274
3366
  async function setRolePositions(guild, updates) {
3275
3367
  return replaceRoles(
3276
3368
  guild,
3277
- await guild.client.rest.patch(import_types33.Routes.guildRoles(guild.id), {
3369
+ await guild.client.rest.patch(import_types34.Routes.guildRoles(guild.id), {
3278
3370
  body: updates,
3279
3371
  auth: true
3280
3372
  })
@@ -3283,7 +3375,7 @@ async function setRolePositions(guild, updates) {
3283
3375
  async function setRoleHoistPositions(guild, updates) {
3284
3376
  return replaceRoles(
3285
3377
  guild,
3286
- await guild.client.rest.patch(import_types33.Routes.guildRolesHoistPositions(guild.id), {
3378
+ await guild.client.rest.patch(import_types34.Routes.guildRolesHoistPositions(guild.id), {
3287
3379
  body: updates.map((u) => ({
3288
3380
  id: u.id,
3289
3381
  ...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
@@ -3295,23 +3387,23 @@ async function setRoleHoistPositions(guild, updates) {
3295
3387
  async function resetRoleHoistPositions(guild) {
3296
3388
  return replaceRoles(
3297
3389
  guild,
3298
- await guild.client.rest.delete(import_types33.Routes.guildRolesHoistPositions(guild.id), {
3390
+ await guild.client.rest.delete(import_types34.Routes.guildRolesHoistPositions(guild.id), {
3299
3391
  auth: true
3300
3392
  })
3301
3393
  );
3302
3394
  }
3303
3395
 
3304
3396
  // src/structures/guild/stickers.ts
3305
- var import_types34 = require("@fluxerjs/types");
3397
+ var import_types35 = require("@fluxerjs/types");
3306
3398
  async function createSticker(guild, options) {
3307
- const data = await guild.client.rest.post(import_types34.Routes.guildStickers(guild.id), {
3399
+ const data = await guild.client.rest.post(import_types35.Routes.guildStickers(guild.id), {
3308
3400
  body: options,
3309
3401
  auth: true
3310
3402
  });
3311
3403
  return cacheSticker(guild, data);
3312
3404
  }
3313
3405
  async function cloneSticker(guild, sourceStickerId) {
3314
- const data = await guild.client.rest.post(import_types34.Routes.guildStickersClone(guild.id), {
3406
+ const data = await guild.client.rest.post(import_types35.Routes.guildStickersClone(guild.id), {
3315
3407
  body: { source_sticker_id: sourceStickerId },
3316
3408
  auth: true
3317
3409
  });
@@ -3319,17 +3411,17 @@ async function cloneSticker(guild, sourceStickerId) {
3319
3411
  }
3320
3412
  async function createStickersBulk(guild, stickers) {
3321
3413
  const data = await guild.client.rest.post(
3322
- import_types34.Routes.guildStickersBulk(guild.id),
3414
+ import_types35.Routes.guildStickersBulk(guild.id),
3323
3415
  { body: { stickers }, auth: true }
3324
3416
  );
3325
3417
  return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
3326
3418
  }
3327
3419
  async function fetchStickers(guild) {
3328
- const data = await guild.client.rest.get(import_types34.Routes.guildStickers(guild.id));
3420
+ const data = await guild.client.rest.get(import_types35.Routes.guildStickers(guild.id));
3329
3421
  return data.map((s) => cacheSticker(guild, s));
3330
3422
  }
3331
3423
  async function fetchSticker(guild, stickerId) {
3332
- const data = await guild.client.rest.get(import_types34.Routes.guildSticker(guild.id, stickerId));
3424
+ const data = await guild.client.rest.get(import_types35.Routes.guildSticker(guild.id, stickerId));
3333
3425
  return cacheSticker(guild, data);
3334
3426
  }
3335
3427
 
@@ -3339,6 +3431,8 @@ var Guild = class extends Base {
3339
3431
  client;
3340
3432
  /** Snowflake ID of this guild. */
3341
3433
  id;
3434
+ /** Whether the guild is currently available through the gateway. */
3435
+ available = true;
3342
3436
  /** Guild name. */
3343
3437
  name;
3344
3438
  /** Icon hash (use {@link iconURL} to get full CDN URL). */
@@ -3412,7 +3506,7 @@ var Guild = class extends Base {
3412
3506
  this.afkTimeout = data.afk_timeout ?? 0;
3413
3507
  this.systemChannelId = data.system_channel_id ?? null;
3414
3508
  this.rulesChannelId = data.rules_channel_id ?? null;
3415
- this.nsfwLevel = data.nsfw_level ?? import_types35.GuildNSFWLevel.Safe;
3509
+ this.nsfwLevel = data.nsfw_level ?? import_types36.GuildNSFWLevel.Safe;
3416
3510
  this.mfaLevel = data.mfa_level ?? 0;
3417
3511
  this.bannerWidth = data.banner_width ?? null;
3418
3512
  this.bannerHeight = data.banner_height ?? null;
@@ -3445,7 +3539,7 @@ var Guild = class extends Base {
3445
3539
  if (data.afk_timeout !== void 0) this.afkTimeout = data.afk_timeout ?? 0;
3446
3540
  if (data.system_channel_id !== void 0) this.systemChannelId = data.system_channel_id ?? null;
3447
3541
  if (data.rules_channel_id !== void 0) this.rulesChannelId = data.rules_channel_id ?? null;
3448
- if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types35.GuildNSFWLevel.Safe;
3542
+ if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types36.GuildNSFWLevel.Safe;
3449
3543
  if (data.mfa_level !== void 0) this.mfaLevel = data.mfa_level ?? 0;
3450
3544
  if (data.banner_width !== void 0) this.bannerWidth = data.banner_width ?? null;
3451
3545
  if (data.banner_height !== void 0) this.bannerHeight = data.banner_height ?? null;
@@ -3674,13 +3768,13 @@ var GuildManager = class extends import_collection9.Collection {
3674
3768
  const cached = this.get(guildId);
3675
3769
  if (cached) return cached;
3676
3770
  try {
3677
- const data = await this.client.rest.get(import_types36.Routes.guild(guildId));
3771
+ const data = await this.client.rest.get(import_types37.Routes.guild(guildId));
3678
3772
  const guild = new Guild(this.client, data);
3679
3773
  this.set(guild.id, guild);
3680
3774
  return guild;
3681
3775
  } catch (err) {
3682
- if (err instanceof import_rest5.RateLimitError) throw err;
3683
- if (err instanceof import_rest5.FluxerAPIError && err.statusCode === 404) {
3776
+ if (err instanceof import_rest6.RateLimitError) throw err;
3777
+ if (err instanceof import_rest6.FluxerAPIError && err.statusCode === 404) {
3684
3778
  throw new import_util.FluxerError(`Guild ${guildId} not found`, {
3685
3779
  code: import_util2.ErrorCodes.GuildNotFound,
3686
3780
  cause: err
@@ -3701,7 +3795,7 @@ var DEFAULT_CACHE_LIMITS = {
3701
3795
  };
3702
3796
 
3703
3797
  // src/structures/User.ts
3704
- var import_types37 = require("@fluxerjs/types");
3798
+ var import_types38 = require("@fluxerjs/types");
3705
3799
  var User = class extends Base {
3706
3800
  /** Parent client instance. */
3707
3801
  client;
@@ -3791,7 +3885,7 @@ var User = class extends Base {
3791
3885
  * @returns DM channel instance (cached if already open)
3792
3886
  */
3793
3887
  async createDM() {
3794
- const data = await this.client.rest.post(import_types37.Routes.userMeChannels(), {
3888
+ const data = await this.client.rest.post(import_types38.Routes.userMeChannels(), {
3795
3889
  body: { recipient_id: this.id },
3796
3890
  auth: true
3797
3891
  });
@@ -3801,7 +3895,7 @@ var User = class extends Base {
3801
3895
  }
3802
3896
  /**
3803
3897
  * Send a DM to this user.
3804
- * @param options - Message content or {@link MessageSendOptions}
3898
+ * @param options - {@link MessagePrepareInput}
3805
3899
  * @returns Sent message
3806
3900
  */
3807
3901
  async send(options) {
@@ -3811,7 +3905,7 @@ var User = class extends Base {
3811
3905
 
3812
3906
  // src/client/UserManager.ts
3813
3907
  var import_collection10 = require("@fluxerjs/collection");
3814
- var import_types38 = require("@fluxerjs/types");
3908
+ var import_types39 = require("@fluxerjs/types");
3815
3909
  var soft = (p) => p.catch(() => null);
3816
3910
  var UserManager = class extends import_collection10.Collection {
3817
3911
  constructor(client) {
@@ -3842,7 +3936,7 @@ var UserManager = class extends import_collection10.Collection {
3842
3936
  }
3843
3937
  /** Fetch a user by ID and update cache. */
3844
3938
  async fetch(userId) {
3845
- const data = await this.client.rest.get(import_types38.Routes.user(userId));
3939
+ const data = await this.client.rest.get(import_types39.Routes.user(userId));
3846
3940
  return this.client.getOrCreateUser(data);
3847
3941
  }
3848
3942
  /**
@@ -3856,10 +3950,10 @@ var UserManager = class extends import_collection10.Collection {
3856
3950
  async fetchWithProfile(userId, options) {
3857
3951
  const guildId = options?.guildId ?? void 0;
3858
3952
  const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
3859
- this.client.rest.get(import_types38.Routes.user(userId)),
3860
- soft(this.client.rest.get(import_types38.Routes.userProfile(userId))),
3861
- guildId ? soft(this.client.rest.get(import_types38.Routes.userProfile(userId, guildId))) : null,
3862
- guildId ? soft(this.client.rest.get(import_types38.Routes.guildMember(guildId, userId))) : null
3953
+ this.client.rest.get(import_types39.Routes.user(userId)),
3954
+ soft(this.client.rest.get(import_types39.Routes.userProfile(userId))),
3955
+ guildId ? soft(this.client.rest.get(import_types39.Routes.userProfile(userId, guildId))) : null,
3956
+ guildId ? soft(this.client.rest.get(import_types39.Routes.guildMember(guildId, userId))) : null
3863
3957
  ]);
3864
3958
  const user = this.client.getOrCreateUser(userData);
3865
3959
  let member = null;
@@ -3888,7 +3982,7 @@ var UserManager = class extends import_collection10.Collection {
3888
3982
  };
3889
3983
 
3890
3984
  // src/client/PackManager.ts
3891
- var import_types39 = require("@fluxerjs/types");
3985
+ var import_types40 = require("@fluxerjs/types");
3892
3986
  function toPackSummaryPayload(data) {
3893
3987
  return {
3894
3988
  id: data.id,
@@ -3943,7 +4037,7 @@ var PackManager = class {
3943
4037
  }
3944
4038
  /** Fetch the current user's pack dashboard (camelCase summaries). */
3945
4039
  async fetchDashboard() {
3946
- const data = await this.client.rest.get(import_types39.Routes.packs());
4040
+ const data = await this.client.rest.get(import_types40.Routes.packs());
3947
4041
  return {
3948
4042
  emoji: mapDashboardSection(data.emoji),
3949
4043
  sticker: mapDashboardSection(data.sticker)
@@ -3951,49 +4045,49 @@ var PackManager = class {
3951
4045
  }
3952
4046
  /** Create a pack. */
3953
4047
  async create(packType, body) {
3954
- const data = await this.client.rest.post(import_types39.Routes.packsByType(packType), {
4048
+ const data = await this.client.rest.post(import_types40.Routes.packsByType(packType), {
3955
4049
  body
3956
4050
  });
3957
4051
  return toPackSummaryPayload(data);
3958
4052
  }
3959
4053
  /** Edit a pack. */
3960
4054
  async edit(packId, body) {
3961
- const data = await this.client.rest.patch(import_types39.Routes.pack(packId), { body });
4055
+ const data = await this.client.rest.patch(import_types40.Routes.pack(packId), { body });
3962
4056
  return toPackSummaryPayload(data);
3963
4057
  }
3964
4058
  /** Delete a pack. */
3965
4059
  async delete(packId) {
3966
- await this.client.rest.delete(import_types39.Routes.pack(packId));
4060
+ await this.client.rest.delete(import_types40.Routes.pack(packId));
3967
4061
  }
3968
4062
  /** Install a pack for the current user. */
3969
4063
  async install(packId) {
3970
- await this.client.rest.post(import_types39.Routes.packInstall(packId));
4064
+ await this.client.rest.post(import_types40.Routes.packInstall(packId));
3971
4065
  }
3972
4066
  /** Uninstall a pack for the current user. */
3973
4067
  async uninstall(packId) {
3974
- await this.client.rest.delete(import_types39.Routes.packInstall(packId));
4068
+ await this.client.rest.delete(import_types40.Routes.packInstall(packId));
3975
4069
  }
3976
4070
  /** List invites for a pack. */
3977
4071
  async listInvites(packId) {
3978
- const data = await this.client.rest.get(import_types39.Routes.packInvites(packId));
4072
+ const data = await this.client.rest.get(import_types40.Routes.packInvites(packId));
3979
4073
  return data.map(toInvitePayload);
3980
4074
  }
3981
4075
  /** Create an invite for a pack. */
3982
4076
  async createInvite(packId, options = {}) {
3983
4077
  const body = toPackInviteBody(options);
3984
- const data = await this.client.rest.post(import_types39.Routes.packInvites(packId), {
4078
+ const data = await this.client.rest.post(import_types40.Routes.packInvites(packId), {
3985
4079
  body: Object.keys(body).length ? body : void 0
3986
4080
  });
3987
4081
  return toInvitePayload(data);
3988
4082
  }
3989
4083
  /** List emojis in a pack. */
3990
4084
  async listEmojis(packId) {
3991
- const data = await this.client.rest.get(import_types39.Routes.packEmojis(packId));
4085
+ const data = await this.client.rest.get(import_types40.Routes.packEmojis(packId));
3992
4086
  return data.map(toEmojiPayload);
3993
4087
  }
3994
4088
  /** Create an emoji in a pack. */
3995
4089
  async createEmoji(packId, options) {
3996
- const data = await this.client.rest.post(import_types39.Routes.packEmojis(packId), {
4090
+ const data = await this.client.rest.post(import_types40.Routes.packEmojis(packId), {
3997
4091
  body: toEmojiCreateBody(options)
3998
4092
  });
3999
4093
  return toEmojiPayload(data);
@@ -4001,7 +4095,7 @@ var PackManager = class {
4001
4095
  /** Bulk-create emojis in a pack. */
4002
4096
  async createEmojisBulk(packId, emojis) {
4003
4097
  const data = await this.client.rest.post(
4004
- import_types39.Routes.packEmojisBulk(packId),
4098
+ import_types40.Routes.packEmojisBulk(packId),
4005
4099
  { body: { emojis: emojis.map(toEmojiCreateBody) } }
4006
4100
  );
4007
4101
  return {
@@ -4011,23 +4105,23 @@ var PackManager = class {
4011
4105
  }
4012
4106
  /** Edit an emoji in a pack. */
4013
4107
  async editEmoji(packId, emojiId, options) {
4014
- const data = await this.client.rest.patch(import_types39.Routes.packEmoji(packId, emojiId), {
4108
+ const data = await this.client.rest.patch(import_types40.Routes.packEmoji(packId, emojiId), {
4015
4109
  body: toEmojiEditBody(options)
4016
4110
  });
4017
4111
  return toEmojiPayload(data);
4018
4112
  }
4019
4113
  /** Delete an emoji from a pack. */
4020
4114
  async deleteEmoji(packId, emojiId) {
4021
- await this.client.rest.delete(import_types39.Routes.packEmoji(packId, emojiId));
4115
+ await this.client.rest.delete(import_types40.Routes.packEmoji(packId, emojiId));
4022
4116
  }
4023
4117
  /** List stickers in a pack. */
4024
4118
  async listStickers(packId) {
4025
- const data = await this.client.rest.get(import_types39.Routes.packStickers(packId));
4119
+ const data = await this.client.rest.get(import_types40.Routes.packStickers(packId));
4026
4120
  return data.map(toStickerPayload);
4027
4121
  }
4028
4122
  /** Create a sticker in a pack. */
4029
4123
  async createSticker(packId, options) {
4030
- const data = await this.client.rest.post(import_types39.Routes.packStickers(packId), {
4124
+ const data = await this.client.rest.post(import_types40.Routes.packStickers(packId), {
4031
4125
  body: toStickerCreateBody(options)
4032
4126
  });
4033
4127
  return toStickerPayload(data);
@@ -4035,7 +4129,7 @@ var PackManager = class {
4035
4129
  /** Bulk-create stickers in a pack. */
4036
4130
  async createStickersBulk(packId, stickers) {
4037
4131
  const data = await this.client.rest.post(
4038
- import_types39.Routes.packStickersBulk(packId),
4132
+ import_types40.Routes.packStickersBulk(packId),
4039
4133
  { body: { stickers: stickers.map(toStickerCreateBody) } }
4040
4134
  );
4041
4135
  return {
@@ -4045,14 +4139,14 @@ var PackManager = class {
4045
4139
  }
4046
4140
  /** Edit a sticker in a pack. */
4047
4141
  async editSticker(packId, stickerId, options) {
4048
- const data = await this.client.rest.patch(import_types39.Routes.packSticker(packId, stickerId), {
4142
+ const data = await this.client.rest.patch(import_types40.Routes.packSticker(packId, stickerId), {
4049
4143
  body: toStickerEditBody(options)
4050
4144
  });
4051
4145
  return toStickerPayload(data);
4052
4146
  }
4053
4147
  /** Delete a sticker from a pack. */
4054
4148
  async deleteSticker(packId, stickerId) {
4055
- await this.client.rest.delete(import_types39.Routes.packSticker(packId, stickerId));
4149
+ await this.client.rest.delete(import_types40.Routes.packSticker(packId, stickerId));
4056
4150
  }
4057
4151
  };
4058
4152
 
@@ -4071,10 +4165,10 @@ function createEventMethods(client) {
4071
4165
 
4072
4166
  // src/client/clientEmoji.ts
4073
4167
  var import_collection11 = require("@fluxerjs/collection");
4074
- var import_types40 = require("@fluxerjs/types");
4168
+ var import_types41 = require("@fluxerjs/types");
4075
4169
  var import_util9 = require("@fluxerjs/util");
4076
4170
  async function assertEmojiInGuild(client, emojiId, guildId) {
4077
- const emojis = await client.rest.get(import_types40.Routes.guildEmojis(guildId));
4171
+ const emojis = await client.rest.get(import_types41.Routes.guildEmojis(guildId));
4078
4172
  if (!emojis.some((e) => e.id === emojiId)) {
4079
4173
  throw new import_util.FluxerError("Custom emoji is from another server. Use an emoji from this server.", {
4080
4174
  code: import_util2.ErrorCodes.EmojiNotInGuild
@@ -4100,7 +4194,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
4100
4194
  const unicodeFromShortcode = (0, import_util9.getUnicodeFromShortcode)(parsed.name);
4101
4195
  if (unicodeFromShortcode) return unicodeFromShortcode;
4102
4196
  if (guildId) {
4103
- const emojis = await client.rest.get(import_types40.Routes.guildEmojis(guildId));
4197
+ const emojis = await client.rest.get(import_types41.Routes.guildEmojis(guildId));
4104
4198
  const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
4105
4199
  if (found) return (0, import_util9.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
4106
4200
  throw new import_util.FluxerError(
@@ -4117,28 +4211,28 @@ async function resolveClientEmoji(client, emoji, guildId) {
4117
4211
  return parsed.name;
4118
4212
  }
4119
4213
  async function fetchInstance(client) {
4120
- const raw = await client.rest.get(import_types40.Routes.instanceDiscovery(), { auth: false });
4214
+ const raw = await client.rest.get(import_types41.Routes.instanceDiscovery(), { auth: false });
4121
4215
  return parseInstanceDiscovery(raw);
4122
4216
  }
4123
4217
  function fetchGatewayInfo(client) {
4124
- return client.rest.get(import_types40.Routes.gatewayBot());
4218
+ return client.rest.get(import_types41.Routes.gatewayBot());
4125
4219
  }
4126
4220
  function fetchEmojiMetadata(client, emojiId) {
4127
- return client.rest.get(import_types40.Routes.emojiMetadata(emojiId), { auth: true });
4221
+ return client.rest.get(import_types41.Routes.emojiMetadata(emojiId), { auth: true });
4128
4222
  }
4129
4223
  function fetchStickerMetadata(client, stickerId) {
4130
- return client.rest.get(import_types40.Routes.stickerMetadata(stickerId), { auth: true });
4224
+ return client.rest.get(import_types41.Routes.stickerMetadata(stickerId), { auth: true });
4131
4225
  }
4132
4226
  function fetchApplication(client) {
4133
- return client.rest.get(import_types40.Routes.applicationsMe(), { auth: true });
4227
+ return client.rest.get(import_types41.Routes.applicationsMe(), { auth: true });
4134
4228
  }
4135
4229
  async function fetchOAuthApplications(client) {
4136
- const data = await client.rest.get(import_types40.Routes.oauth2ApplicationsMe(), { auth: true });
4230
+ const data = await client.rest.get(import_types41.Routes.oauth2ApplicationsMe(), { auth: true });
4137
4231
  return Array.isArray(data) ? data : data.applications ?? [];
4138
4232
  }
4139
4233
  function checkUsernameTag(client, username, discriminator) {
4140
4234
  const params = new URLSearchParams({ username, discriminator });
4141
- return client.rest.get(`${import_types40.Routes.checkUsernameTag()}?${params}`, { auth: true });
4235
+ return client.rest.get(`${import_types41.Routes.checkUsernameTag()}?${params}`, { auth: true });
4142
4236
  }
4143
4237
  function assertChannelIdBatch(name, channelIds) {
4144
4238
  if (channelIds.length < 1 || channelIds.length > 100) {
@@ -4149,14 +4243,14 @@ function assertChannelIdBatch(name, channelIds) {
4149
4243
  }
4150
4244
  function preloadMessages(client, channelIds) {
4151
4245
  assertChannelIdBatch("preloadMessages", channelIds);
4152
- return client.rest.post(import_types40.Routes.preloadMessages(), {
4246
+ return client.rest.post(import_types41.Routes.preloadMessages(), {
4153
4247
  body: { channels: channelIds },
4154
4248
  auth: true
4155
4249
  });
4156
4250
  }
4157
4251
  function preloadMessagesAlt(client, channelIds) {
4158
4252
  assertChannelIdBatch("preloadMessagesAlt", channelIds);
4159
- return client.rest.post(import_types40.Routes.preloadMessagesAlt(), {
4253
+ return client.rest.post(import_types41.Routes.preloadMessagesAlt(), {
4160
4254
  body: { channels: channelIds },
4161
4255
  auth: true
4162
4256
  });
@@ -4164,7 +4258,7 @@ function preloadMessagesAlt(client, channelIds) {
4164
4258
  async function bulkFetchMessages(client, requests, options = {}) {
4165
4259
  validateBulkMessageFetchRequests(requests);
4166
4260
  const wire = toBulkFetchWire(requests);
4167
- const data = await client.rest.post(import_types40.Routes.channelsMessagesBulk(), {
4261
+ const data = await client.rest.post(import_types41.Routes.channelsMessagesBulk(), {
4168
4262
  body: { requests: wire },
4169
4263
  auth: true
4170
4264
  });
@@ -4251,62 +4345,6 @@ function buildRegistry(...maps) {
4251
4345
  return registry;
4252
4346
  }
4253
4347
 
4254
- // src/structures/MessageReaction.ts
4255
- var import_types41 = require("@fluxerjs/types");
4256
- var import_rest6 = require("@fluxerjs/rest");
4257
- var MessageReaction = class extends Base {
4258
- client;
4259
- messageId;
4260
- channelId;
4261
- guildId;
4262
- emoji;
4263
- /** Raw gateway payload for low-level access. */
4264
- _data;
4265
- constructor(client, data) {
4266
- super();
4267
- this.client = client;
4268
- this._data = data;
4269
- this.messageId = data.message_id;
4270
- this.channelId = data.channel_id;
4271
- this.guildId = data.guild_id ?? null;
4272
- this.emoji = {
4273
- name: data.emoji.name,
4274
- ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
4275
- ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
4276
- };
4277
- }
4278
- /** Emoji as a string: unicode or "name:id" for custom. */
4279
- get emojiIdentifier() {
4280
- return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
4281
- }
4282
- /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
4283
- get guild() {
4284
- return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
4285
- }
4286
- /**
4287
- * Fetch the message this reaction belongs to.
4288
- * Use when you need to edit, delete, or otherwise interact with the message.
4289
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
4290
- */
4291
- async fetchMessage() {
4292
- try {
4293
- const data = await this.client.rest.get(
4294
- import_types41.Routes.channelMessage(this.channelId, this.messageId)
4295
- );
4296
- return new Message(this.client, data);
4297
- } catch (err) {
4298
- if (err instanceof import_rest6.RateLimitError) throw err;
4299
- if (err instanceof import_rest6.FluxerAPIError && err.statusCode === 404) {
4300
- throw new import_util.FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
4301
- code: import_util2.ErrorCodes.MessageNotFound,
4302
- cause: err
4303
- });
4304
- }
4305
- throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
4306
- }
4307
- }
4308
- };
4309
-
4310
4348
  // src/client/eventHandlers/helpers.ts
4311
4349
  function unknownUser(id) {
4312
4350
  return { id, username: "Unknown", discriminator: "0" };
@@ -4477,13 +4515,50 @@ function normalizeGuildPayload(raw) {
4477
4515
  }
4478
4516
 
4479
4517
  // src/client/eventHandlers/guilds.ts
4518
+ function markGuildUnavailable(client, id) {
4519
+ const guild = client.guilds.get(id);
4520
+ if (!guild || guild.available === false) return;
4521
+ guild.available = false;
4522
+ client.emit(Events.GuildUnavailable, guild);
4523
+ }
4524
+ function refreshRecoveredGuild(guild, data) {
4525
+ guild._patch(data);
4526
+ if (data.roles !== void 0) {
4527
+ guild.roles.clear();
4528
+ for (const role of data.roles) {
4529
+ guild.roles.set(role.id, new Role(guild.client, role, guild.id));
4530
+ }
4531
+ }
4532
+ if (data.channels !== void 0) {
4533
+ const recoveredChannelIds = new Set(data.channels.map((channel) => channel.id));
4534
+ for (const channel of guild.channels.values()) {
4535
+ guild.client.channels.delete(channel.id);
4536
+ if (!recoveredChannelIds.has(channel.id)) guild.client._clearMessageCache(channel.id);
4537
+ }
4538
+ guild.channels.clear();
4539
+ }
4540
+ }
4480
4541
  var guildHandlers = {
4481
4542
  GUILD_CREATE(client, d) {
4543
+ const raw = d;
4544
+ if (raw.unavailable === true) {
4545
+ if (typeof raw.id === "string") {
4546
+ try {
4547
+ markGuildUnavailable(client, raw.id);
4548
+ } finally {
4549
+ client._onGuildReceived(raw.id);
4550
+ }
4551
+ }
4552
+ return;
4553
+ }
4482
4554
  const guildData = normalizeGuildPayload(d);
4483
4555
  if (!guildData) return;
4484
- const guild = new Guild(client, guildData);
4485
- client.guilds.set(guild.id, guild);
4486
4556
  const g = d;
4557
+ const existing = client.guilds.get(guildData.id);
4558
+ const recovered = existing?.available === false;
4559
+ const guild = recovered && existing ? existing : new Guild(client, guildData);
4560
+ if (recovered) refreshRecoveredGuild(guild, g);
4561
+ client.guilds.set(guild.id, guild);
4487
4562
  for (const ch of g.channels ?? []) {
4488
4563
  const channel = Channel.from(client, ch);
4489
4564
  if (channel) {
@@ -4492,7 +4567,8 @@ var guildHandlers = {
4492
4567
  }
4493
4568
  }
4494
4569
  for (const m of g.members ?? []) cacheMember2(client, guild, m);
4495
- client.emit(Events.GuildCreate, guild);
4570
+ if (recovered) guild.available = true;
4571
+ client.emit(recovered ? Events.GuildAvailable : Events.GuildCreate, guild);
4496
4572
  if (g.voice_states?.length) {
4497
4573
  client.emit(Events.VoiceStatesSync, { guildId: guild.id, voiceStates: g.voice_states });
4498
4574
  }
@@ -4513,11 +4589,19 @@ var guildHandlers = {
4513
4589
  client.emit(Events.GuildUpdate, updated, updated);
4514
4590
  },
4515
4591
  GUILD_DELETE(client, d) {
4516
- const { id } = d;
4517
- const guild = client.guilds.get(id);
4518
- if (!guild) return;
4519
- client.guilds.delete(id);
4520
- client.emit(Events.GuildDelete, guild);
4592
+ const { id, unavailable } = d;
4593
+ try {
4594
+ if (unavailable === true) {
4595
+ markGuildUnavailable(client, id);
4596
+ return;
4597
+ }
4598
+ const guild = client.guilds.get(id);
4599
+ if (!guild) return;
4600
+ client.guilds.delete(id);
4601
+ client.emit(Events.GuildDelete, guild);
4602
+ } finally {
4603
+ client._onGuildReceived(id);
4604
+ }
4521
4605
  }
4522
4606
  };
4523
4607
 
@@ -4936,7 +5020,12 @@ function emitClientError(client, err) {
4936
5020
  function shouldDeferGatewayDispatchUntilReady(client, payload) {
4937
5021
  if (client.options.waitForGuilds !== true || client.readyAt !== null) return false;
4938
5022
  if (payload.op !== 0 || !payload.t) return false;
4939
- return payload.t !== "GUILD_CREATE";
5023
+ if (payload.t === "GUILD_CREATE") return false;
5024
+ if (payload.t === "GUILD_DELETE") {
5025
+ const data = payload.d;
5026
+ if (typeof data?.id === "string" && client._pendingGuildIds?.has(data.id)) return false;
5027
+ }
5028
+ return true;
4940
5029
  }
4941
5030
  function handleGatewayDispatch(client, payload, deferred) {
4942
5031
  if (payload.op !== 0 || !payload.t) return Promise.resolve();