@fluxerjs/core 2.0.2 → 2.1.0

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