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