@fluxerjs/core 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5,8 +5,8 @@ import { Routes as Routes34 } from "@fluxerjs/types";
5
5
 
6
6
  // src/client/ChannelManager.ts
7
7
  import { Collection as Collection5 } from "@fluxerjs/collection";
8
- import { Routes as Routes12 } from "@fluxerjs/types";
9
- import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
8
+ import { Routes as Routes13 } from "@fluxerjs/types";
9
+ import { FluxerAPIError as FluxerAPIError3, RateLimitError as RateLimitError3 } from "@fluxerjs/rest";
10
10
 
11
11
  // src/errors/FluxerError.ts
12
12
  import { FluxerError } from "@fluxerjs/util";
@@ -201,19 +201,19 @@ async function prepareMessagePostPayload(options, defaults) {
201
201
  }
202
202
 
203
203
  // src/structures/channel/base.ts
204
- import { ChannelType, Routes as Routes6 } from "@fluxerjs/types";
204
+ import { ChannelType, Routes as Routes7 } from "@fluxerjs/types";
205
205
 
206
206
  // src/client/MessageManager.ts
207
- import { Routes as Routes4 } from "@fluxerjs/types";
207
+ import { Routes as Routes5 } from "@fluxerjs/types";
208
208
  import { Collection as Collection3 } from "@fluxerjs/collection";
209
- import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
209
+ import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
210
210
 
211
211
  // src/structures/message/Message.ts
212
212
  import { Collection as Collection2 } from "@fluxerjs/collection";
213
213
  import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
214
214
  import {
215
215
  MessageType,
216
- Routes as Routes3
216
+ Routes as Routes4
217
217
  } from "@fluxerjs/types";
218
218
 
219
219
  // src/client/sdkOptions.ts
@@ -455,6 +455,68 @@ function toProfilePayload(data) {
455
455
  import { EventEmitter } from "events";
456
456
  import { Collection } from "@fluxerjs/collection";
457
457
 
458
+ // src/structures/MessageReaction.ts
459
+ import { Routes } from "@fluxerjs/types";
460
+ import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
461
+
462
+ // src/structures/Base.ts
463
+ var Base = class {
464
+ };
465
+
466
+ // src/structures/MessageReaction.ts
467
+ var MessageReaction = class extends Base {
468
+ client;
469
+ messageId;
470
+ channelId;
471
+ guildId;
472
+ emoji;
473
+ /** Raw gateway payload for low-level access. */
474
+ _data;
475
+ constructor(client, data) {
476
+ super();
477
+ this.client = client;
478
+ this._data = data;
479
+ this.messageId = data.message_id;
480
+ this.channelId = data.channel_id;
481
+ this.guildId = data.guild_id ?? null;
482
+ this.emoji = {
483
+ name: data.emoji.name,
484
+ ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
485
+ ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
486
+ };
487
+ }
488
+ /** Emoji as a string: unicode or "name:id" for custom. */
489
+ get emojiIdentifier() {
490
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
491
+ }
492
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
493
+ get guild() {
494
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
495
+ }
496
+ /**
497
+ * Fetch the message this reaction belongs to.
498
+ * Use when you need to edit, delete, or otherwise interact with the message.
499
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
500
+ */
501
+ async fetchMessage() {
502
+ try {
503
+ const data = await this.client.rest.get(
504
+ Routes.channelMessage(this.channelId, this.messageId)
505
+ );
506
+ return new Message(this.client, data);
507
+ } catch (err) {
508
+ if (err instanceof RateLimitError) throw err;
509
+ if (err instanceof FluxerAPIError && err.statusCode === 404) {
510
+ throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
511
+ code: ErrorCodes.MessageNotFound,
512
+ cause: err
513
+ });
514
+ }
515
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
516
+ }
517
+ }
518
+ };
519
+
458
520
  // src/util/Events.ts
459
521
  var Events = {
460
522
  Ready: "ready",
@@ -468,6 +530,8 @@ var Events = {
468
530
  MessageReactionRemoveAll: "messageReactionRemoveAll",
469
531
  MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
470
532
  GuildCreate: "guildCreate",
533
+ GuildAvailable: "guildAvailable",
534
+ GuildUnavailable: "guildUnavailable",
471
535
  GuildUpdate: "guildUpdate",
472
536
  GuildDelete: "guildDelete",
473
537
  GuildBanAdd: "guildBanAdd",
@@ -516,7 +580,8 @@ var ReactionCollector = class extends EventEmitter {
516
580
  collected = new Collection();
517
581
  _timeout = null;
518
582
  _ended = false;
519
- _listener;
583
+ _onAdd;
584
+ _onAddMany;
520
585
  constructor(client, messageId, channelId, options = {}) {
521
586
  super();
522
587
  this.client = client;
@@ -527,27 +592,58 @@ var ReactionCollector = class extends EventEmitter {
527
592
  time: options.time ?? 0,
528
593
  max: options.max ?? 0
529
594
  };
530
- this._listener = (payload) => {
595
+ this._onAdd = (payload) => {
531
596
  if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
532
597
  return;
533
598
  }
534
- if (!this.options.filter(payload.reaction, payload.user)) return;
535
- const key = `${payload.userId}:${payload.reaction.emoji.id ?? payload.reaction.emoji.name}`;
536
- this.collected.set(key, { reaction: payload.reaction, user: payload.user });
537
- this.emit("collect", payload.reaction, payload.user);
538
- if (this.options.max > 0 && this.collected.size >= this.options.max) {
539
- this.stop("limit");
599
+ this._collect(payload.reaction, payload.user, payload.userId);
600
+ };
601
+ this._onAddMany = (payload) => {
602
+ if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
603
+ return;
604
+ }
605
+ for (const entry of payload.reactions) {
606
+ if (this._ended) return;
607
+ const reaction = new MessageReaction(this.client, {
608
+ message_id: payload.messageId,
609
+ channel_id: payload.channelId,
610
+ guild_id: payload.guildId ?? void 0,
611
+ user_id: entry.userId,
612
+ emoji: {
613
+ name: entry.emoji.name,
614
+ ...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
615
+ ...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
616
+ }
617
+ });
618
+ const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
619
+ id: entry.userId,
620
+ username: "Unknown",
621
+ discriminator: "0"
622
+ });
623
+ this._collect(reaction, user, entry.userId);
540
624
  }
541
625
  };
542
- this.client.on(Events.MessageReactionAdd, this._listener);
626
+ this.client.on(Events.MessageReactionAdd, this._onAdd);
627
+ this.client.on(Events.MessageReactionAddMany, this._onAddMany);
543
628
  if (this.options.time > 0) {
544
629
  this._timeout = setTimeout(() => this.stop("time"), this.options.time);
545
630
  }
546
631
  }
632
+ _collect(reaction, user, userId) {
633
+ if (this._ended) return;
634
+ if (!this.options.filter(reaction, user)) return;
635
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
636
+ this.collected.set(key, { reaction, user });
637
+ this.emit("collect", reaction, user);
638
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
639
+ this.stop("limit");
640
+ }
641
+ }
547
642
  stop(reason = "user") {
548
643
  if (this._ended) return;
549
644
  this._ended = true;
550
- this.client.off(Events.MessageReactionAdd, this._listener);
645
+ this.client.off(Events.MessageReactionAdd, this._onAdd);
646
+ this.client.off(Events.MessageReactionAddMany, this._onAddMany);
551
647
  if (this._timeout) {
552
648
  clearTimeout(this._timeout);
553
649
  this._timeout = null;
@@ -562,30 +658,26 @@ var ReactionCollector = class extends EventEmitter {
562
658
  }
563
659
  };
564
660
 
565
- // src/structures/Base.ts
566
- var Base = class {
567
- };
568
-
569
661
  // src/structures/message/reactions.ts
570
- import { Routes } from "@fluxerjs/types";
662
+ import { Routes as Routes2 } from "@fluxerjs/types";
571
663
  async function emojiPath(message, emoji) {
572
664
  return message.client.resolveEmoji(emoji, message.guildId);
573
665
  }
574
666
  async function reactToMessage(message, emoji) {
575
667
  const e = await emojiPath(message, emoji);
576
- await message.client.rest.put(Routes.channelMessageReactionMe(message.channelId, message.id, e));
668
+ await message.client.rest.put(Routes2.channelMessageReactionMe(message.channelId, message.id, e));
577
669
  }
578
670
  async function removeMessageReaction(message, emoji, userId) {
579
671
  const e = await emojiPath(message, emoji);
580
- const route = userId ? Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes.channelMessageReactionMe(message.channelId, message.id, e);
672
+ const route = userId ? Routes2.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes2.channelMessageReactionMe(message.channelId, message.id, e);
581
673
  await message.client.rest.delete(route);
582
674
  }
583
675
  async function removeAllMessageReactions(message) {
584
- await message.client.rest.delete(Routes.channelMessageReactions(message.channelId, message.id));
676
+ await message.client.rest.delete(Routes2.channelMessageReactions(message.channelId, message.id));
585
677
  }
586
678
  async function removeMessageReactionEmoji(message, emoji) {
587
679
  const e = await emojiPath(message, emoji);
588
- await message.client.rest.delete(Routes.channelMessageReaction(message.channelId, message.id, e));
680
+ await message.client.rest.delete(Routes2.channelMessageReaction(message.channelId, message.id, e));
589
681
  }
590
682
  async function fetchMessageReactionUsers(message, emoji, options) {
591
683
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -596,7 +688,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
596
688
  if (options?.limit != null) params.set("limit", String(options.limit));
597
689
  if (options?.after) params.set("after", options.after);
598
690
  const qs2 = params.toString();
599
- const route = Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
691
+ const route = Routes2.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
600
692
  const data = await message.client.rest.get(route);
601
693
  if (Array.isArray(data)) {
602
694
  return {
@@ -615,7 +707,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
615
707
 
616
708
  // src/structures/message/send.ts
617
709
  import { MessagePayload as MessagePayloadBuilder } from "@fluxerjs/builders";
618
- import { Routes as Routes2 } from "@fluxerjs/types";
710
+ import { Routes as Routes3 } from "@fluxerjs/types";
619
711
  function toReplyTarget(ref) {
620
712
  return {
621
713
  channelId: ref.channel_id,
@@ -649,7 +741,7 @@ function asReplyTarget(value) {
649
741
  }
650
742
  async function sendPrepared(message, payload) {
651
743
  const data = await message.client.rest.post(
652
- Routes2.channelMessages(message.channelId),
744
+ Routes3.channelMessages(message.channelId),
653
745
  payload
654
746
  );
655
747
  message.client._addMessageToCache(message.channelId, data);
@@ -826,7 +918,7 @@ var Message = class _Message extends Base {
826
918
  if (options.attachments !== void 0) {
827
919
  body.attachments = toMessageAttachmentEditWire(options.attachments);
828
920
  }
829
- const data = await this.client.rest.patch(Routes3.channelMessage(this.channelId, this.id), {
921
+ const data = await this.client.rest.patch(Routes4.channelMessage(this.channelId, this.id), {
830
922
  body
831
923
  });
832
924
  const updated = new _Message(this.client, data);
@@ -843,25 +935,25 @@ var Message = class _Message extends Base {
843
935
  }
844
936
  /** Delete this message. */
845
937
  async delete() {
846
- await this.client.rest.delete(Routes3.channelMessage(this.channelId, this.id));
938
+ await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id));
847
939
  this.client._removeMessageFromCache(this.channelId, this.id);
848
940
  }
849
941
  /** Delete a specific attachment from this message. */
850
942
  async deleteAttachment(attachmentId) {
851
943
  await this.client.rest.delete(
852
- Routes3.channelMessageAttachment(this.channelId, this.id, attachmentId),
944
+ Routes4.channelMessageAttachment(this.channelId, this.id, attachmentId),
853
945
  { auth: true }
854
946
  );
855
947
  this.attachments.delete(attachmentId);
856
948
  }
857
949
  /** Pin this message in the channel. */
858
950
  async pin() {
859
- await this.client.rest.put(Routes3.channelPinMessage(this.channelId, this.id));
951
+ await this.client.rest.put(Routes4.channelPinMessage(this.channelId, this.id));
860
952
  this.pinned = true;
861
953
  }
862
954
  /** Unpin this message from the channel. */
863
955
  async unpin() {
864
- await this.client.rest.delete(Routes3.channelPinMessage(this.channelId, this.id));
956
+ await this.client.rest.delete(Routes4.channelPinMessage(this.channelId, this.id));
865
957
  this.pinned = false;
866
958
  }
867
959
  /** React to this message with an emoji. */
@@ -942,12 +1034,12 @@ var MessageManager = class {
942
1034
  async fetchOne(messageId) {
943
1035
  try {
944
1036
  const data = await this.client.rest.get(
945
- Routes4.channelMessage(this.channelId, messageId)
1037
+ Routes5.channelMessage(this.channelId, messageId)
946
1038
  );
947
1039
  return this.wrap(data);
948
1040
  } catch (err) {
949
- if (err instanceof RateLimitError) throw err;
950
- if (err instanceof FluxerAPIError && err.statusCode === 404) {
1041
+ if (err instanceof RateLimitError2) throw err;
1042
+ if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
951
1043
  throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
952
1044
  code: ErrorCodes.MessageNotFound,
953
1045
  cause: err
@@ -968,7 +1060,7 @@ var MessageManager = class {
968
1060
  const value = options[key];
969
1061
  if (value != null && value !== "") qs2.set(key, String(value));
970
1062
  }
971
- const base = Routes4.channelMessages(this.channelId);
1063
+ const base = Routes5.channelMessages(this.channelId);
972
1064
  const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
973
1065
  const collection = new Collection3();
974
1066
  for (const msg of data) collection.set(msg.id, this.wrap(msg));
@@ -977,7 +1069,7 @@ var MessageManager = class {
977
1069
  };
978
1070
 
979
1071
  // src/structures/channel/attachments.ts
980
- import { Routes as Routes5 } from "@fluxerjs/types";
1072
+ import { Routes as Routes6 } from "@fluxerjs/types";
981
1073
  function asBytes(data) {
982
1074
  const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
983
1075
  const out = new Uint8Array(src.byteLength);
@@ -998,7 +1090,7 @@ async function putBlob(url, body, contentType) {
998
1090
  }
999
1091
  async function uploadAttachmentsForSend(client, channelId, files) {
1000
1092
  const plan = await client.rest.post(
1001
- Routes5.channelAttachments(channelId),
1093
+ Routes6.channelAttachments(channelId),
1002
1094
  {
1003
1095
  body: {
1004
1096
  attachments: files.map((f) => ({
@@ -1044,7 +1136,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
1044
1136
  });
1045
1137
  }
1046
1138
  if (multipart.length) {
1047
- await client.rest.post(Routes5.channelAttachmentsComplete(channelId), {
1139
+ await client.rest.post(Routes6.channelAttachmentsComplete(channelId), {
1048
1140
  body: { uploads: multipart },
1049
1141
  auth: true
1050
1142
  });
@@ -1138,7 +1230,7 @@ var Channel = class extends Base {
1138
1230
  }
1139
1231
  if (ids.length === 0) return [];
1140
1232
  if (ids.length === 1) {
1141
- await this.client.rest.delete(Routes6.channelMessage(this.id, ids[0]), { auth: true });
1233
+ await this.client.rest.delete(Routes7.channelMessage(this.id, ids[0]), { auth: true });
1142
1234
  this.client._removeMessageFromCache(this.id, ids[0]);
1143
1235
  return ids;
1144
1236
  }
@@ -1147,7 +1239,7 @@ var Channel = class extends Base {
1147
1239
  code: ErrorCodes.InvalidBulkDelete
1148
1240
  });
1149
1241
  }
1150
- await this.client.rest.post(Routes6.channelBulkDelete(this.id), {
1242
+ await this.client.rest.post(Routes7.channelBulkDelete(this.id), {
1151
1243
  body: { message_ids: ids },
1152
1244
  auth: true
1153
1245
  });
@@ -1157,23 +1249,23 @@ var Channel = class extends Base {
1157
1249
  /** Delete all messages sent by the bot in this channel (user account feature). */
1158
1250
  async bulkDeleteMyMessages(options) {
1159
1251
  const body = options ? toSudoBody(options) : void 0;
1160
- await this.client.rest.post(Routes6.channelBulkDeleteMine(this.id), {
1252
+ await this.client.rest.post(Routes7.channelBulkDeleteMine(this.id), {
1161
1253
  body: body && Object.keys(body).length ? body : void 0,
1162
1254
  auth: true
1163
1255
  });
1164
1256
  }
1165
1257
  /** Mark all pinned messages as read in this channel. */
1166
1258
  async acknowledgePins() {
1167
- await this.client.rest.post(Routes6.channelPinsAck(this.id), { auth: true });
1259
+ await this.client.rest.post(Routes7.channelPinsAck(this.id), { auth: true });
1168
1260
  }
1169
1261
  /** Clear the read state for this channel. */
1170
1262
  async clearReadState() {
1171
- await this.client.rest.delete(Routes6.channelMessagesAck(this.id), { auth: true });
1263
+ await this.client.rest.delete(Routes7.channelMessagesAck(this.id), { auth: true });
1172
1264
  }
1173
1265
  /** Request upload URLs for attachments before sending a message. */
1174
1266
  async requestAttachmentUploads(attachments) {
1175
1267
  const data = await this.client.rest.post(
1176
- Routes6.channelAttachments(this.id),
1268
+ Routes7.channelAttachments(this.id),
1177
1269
  {
1178
1270
  body: toAttachmentUploadPlanBody(attachments),
1179
1271
  auth: true
@@ -1184,7 +1276,7 @@ var Channel = class extends Base {
1184
1276
  /** Complete the attachment upload flow after uploading to the CDN. */
1185
1277
  async completeAttachmentUploads(uploads) {
1186
1278
  const data = await this.client.rest.post(
1187
- Routes6.channelAttachmentsComplete(this.id),
1279
+ Routes7.channelAttachmentsComplete(this.id),
1188
1280
  {
1189
1281
  body: toAttachmentUploadCompleteBody(uploads),
1190
1282
  auth: true
@@ -1200,11 +1292,11 @@ var Channel = class extends Base {
1200
1292
  }
1201
1293
  /** Trigger the typing indicator in this channel. */
1202
1294
  async sendTyping() {
1203
- await this.client.rest.post(Routes6.channelTyping(this.id), { auth: true });
1295
+ await this.client.rest.post(Routes7.channelTyping(this.id), { auth: true });
1204
1296
  }
1205
1297
  /** Fetch available RTC regions for voice channels. */
1206
1298
  async fetchRtcRegions() {
1207
- const data = await this.client.rest.get(Routes6.channelRtcRegions(this.id), {
1299
+ const data = await this.client.rest.get(Routes7.channelRtcRegions(this.id), {
1208
1300
  auth: true
1209
1301
  });
1210
1302
  return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
@@ -1212,7 +1304,7 @@ var Channel = class extends Base {
1212
1304
  /** Fetch slowmode state for this channel. */
1213
1305
  async fetchSlowmode() {
1214
1306
  const data = await this.client.rest.get(
1215
- Routes6.channelSlowmode(this.id),
1307
+ Routes7.channelSlowmode(this.id),
1216
1308
  { auth: true }
1217
1309
  );
1218
1310
  return {
@@ -1228,7 +1320,7 @@ var Channel = class extends Base {
1228
1320
  };
1229
1321
 
1230
1322
  // src/structures/channel/guild.ts
1231
- import { Routes as Routes10 } from "@fluxerjs/types";
1323
+ import { Routes as Routes11 } from "@fluxerjs/types";
1232
1324
  import { PermissionFlags } from "@fluxerjs/util";
1233
1325
 
1234
1326
  // src/structures/Invite.ts
@@ -1237,7 +1329,7 @@ import {
1237
1329
  isGroupDmInvite,
1238
1330
  isGuildInvite,
1239
1331
  isPackInvite,
1240
- Routes as Routes7
1332
+ Routes as Routes8
1241
1333
  } from "@fluxerjs/types";
1242
1334
 
1243
1335
  // src/util/Constants.ts
@@ -1457,19 +1549,19 @@ var Invite = class _Invite extends Base {
1457
1549
  }
1458
1550
  /** Fetch invite metadata by code or URL (does not join). */
1459
1551
  static async fetch(client, codeOrUrl) {
1460
- const data = await client.rest.get(Routes7.invite(parseInviteCode(codeOrUrl)));
1552
+ const data = await client.rest.get(Routes8.invite(parseInviteCode(codeOrUrl)));
1461
1553
  return new _Invite(client, data);
1462
1554
  }
1463
1555
  /** Delete this invite. Requires Manage Guild or Create Instant Invite. */
1464
1556
  async delete() {
1465
- await this.client.rest.delete(Routes7.invite(this.code), { auth: true });
1557
+ await this.client.rest.delete(Routes8.invite(this.code), { auth: true });
1466
1558
  }
1467
1559
  };
1468
1560
 
1469
1561
  // src/structures/Webhook.ts
1470
1562
  import { EmbedBuilder as EmbedBuilder3 } from "@fluxerjs/builders";
1471
1563
  import {
1472
- Routes as Routes8
1564
+ Routes as Routes9
1473
1565
  } from "@fluxerjs/types";
1474
1566
 
1475
1567
  // src/util/cdn.ts
@@ -1570,10 +1662,10 @@ var Webhook = class _Webhook extends Base {
1570
1662
  /** Delete this webhook (token auth when available, otherwise bot auth). */
1571
1663
  async delete() {
1572
1664
  if (this.token) {
1573
- await this.client.rest.delete(Routes8.webhookExecute(this.id, this.token), { auth: false });
1665
+ await this.client.rest.delete(Routes9.webhookExecute(this.id, this.token), { auth: false });
1574
1666
  return;
1575
1667
  }
1576
- await this.client.rest.delete(Routes8.webhook(this.id), { auth: true });
1668
+ await this.client.rest.delete(Routes9.webhook(this.id), { auth: true });
1577
1669
  }
1578
1670
  /**
1579
1671
  * Edit name/avatar. With bot auth (no token), `channelId` may also be set.
@@ -1585,10 +1677,10 @@ var Webhook = class _Webhook extends Base {
1585
1677
  if (!this.token && options.channelId !== void 0) {
1586
1678
  body.channel_id = options.channelId;
1587
1679
  }
1588
- const data = this.token ? await this.client.rest.patch(Routes8.webhookExecute(this.id, this.token), {
1680
+ const data = this.token ? await this.client.rest.patch(Routes9.webhookExecute(this.id, this.token), {
1589
1681
  body,
1590
1682
  auth: false
1591
- }) : await this.client.rest.patch(Routes8.webhook(this.id), { body, auth: true });
1683
+ }) : await this.client.rest.patch(Routes9.webhook(this.id), { body, auth: true });
1592
1684
  this.name = data.name ?? this.name;
1593
1685
  this.avatar = data.avatar ?? null;
1594
1686
  if (!this.token) this.channelId = data.channel_id ?? this.channelId;
@@ -1609,7 +1701,7 @@ var Webhook = class _Webhook extends Base {
1609
1701
  if (overrides.avatarUrl !== void 0) {
1610
1702
  body.avatar_url = overrides.avatarUrl;
1611
1703
  }
1612
- const route = `${Routes8.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1704
+ const route = `${Routes9.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
1613
1705
  const data = await this.client.rest.post(route, {
1614
1706
  body,
1615
1707
  ...files?.length ? { files } : {},
@@ -1650,7 +1742,7 @@ var Webhook = class _Webhook extends Base {
1650
1742
  }
1651
1743
  /** Fetch a webhook by ID (bot auth; no token). */
1652
1744
  static async fetch(client, webhookId) {
1653
- const data = await client.rest.get(Routes8.webhook(webhookId));
1745
+ const data = await client.rest.get(Routes9.webhook(webhookId));
1654
1746
  return new _Webhook(client, data);
1655
1747
  }
1656
1748
  /** Build a webhook from a stored id + token (e.g. webhook URL). */
@@ -1675,12 +1767,12 @@ var Webhook = class _Webhook extends Base {
1675
1767
  return this.token;
1676
1768
  }
1677
1769
  messageRoute(messageId) {
1678
- return Routes8.webhookMessage(this.id, this.requireToken(), messageId);
1770
+ return Routes9.webhookMessage(this.id, this.requireToken(), messageId);
1679
1771
  }
1680
1772
  };
1681
1773
 
1682
1774
  // src/structures/channel/textCapable.ts
1683
- import { Routes as Routes9 } from "@fluxerjs/types";
1775
+ import { Routes as Routes10 } from "@fluxerjs/types";
1684
1776
 
1685
1777
  // src/util/MessageCollector.ts
1686
1778
  import { EventEmitter as EventEmitter2 } from "events";
@@ -1741,7 +1833,7 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
1741
1833
  if (options?.before) params.set("before", options.before);
1742
1834
  const qs2 = params.toString();
1743
1835
  const data = await client.rest.get(
1744
- Routes9.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1836
+ Routes10.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
1745
1837
  );
1746
1838
  const items = data.items ?? [];
1747
1839
  return {
@@ -1757,7 +1849,7 @@ function TextCapable(Base2) {
1757
1849
  const payload = await prepareMessagePostPayload(options, {
1758
1850
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
1759
1851
  });
1760
- const data = await this.client.rest.post(Routes9.channelMessages(this.id), payload);
1852
+ const data = await this.client.rest.post(Routes10.channelMessages(this.id), payload);
1761
1853
  this.client._addMessageToCache(this.id, data);
1762
1854
  return new Message(this.client, data);
1763
1855
  }
@@ -1814,7 +1906,7 @@ var GuildChannel = class extends Channel {
1814
1906
  }
1815
1907
  /** Create a webhook for this channel. Requires Manage Webhooks. */
1816
1908
  async createWebhook(options) {
1817
- const data = await this.client.rest.post(Routes10.channelWebhooks(this.id), {
1909
+ const data = await this.client.rest.post(Routes11.channelWebhooks(this.id), {
1818
1910
  body: options,
1819
1911
  auth: true
1820
1912
  });
@@ -1822,13 +1914,13 @@ var GuildChannel = class extends Channel {
1822
1914
  }
1823
1915
  /** Fetch all webhooks in this channel. Requires Manage Webhooks. */
1824
1916
  async fetchWebhooks() {
1825
- const data = await this.client.rest.get(Routes10.channelWebhooks(this.id));
1917
+ const data = await this.client.rest.get(Routes11.channelWebhooks(this.id));
1826
1918
  return data.map((w) => new Webhook(this.client, w));
1827
1919
  }
1828
1920
  /** Create an invite for this channel. Requires Create Instant Invite. */
1829
1921
  async createInvite(options) {
1830
1922
  const body = options ? toChannelInviteBody(options) : {};
1831
- const data = await this.client.rest.post(Routes10.channelInvites(this.id), {
1923
+ const data = await this.client.rest.post(Routes11.channelInvites(this.id), {
1832
1924
  body: Object.keys(body).length ? body : void 0,
1833
1925
  auth: true
1834
1926
  });
@@ -1836,12 +1928,12 @@ var GuildChannel = class extends Channel {
1836
1928
  }
1837
1929
  /** Fetch all invites for this channel. Requires Manage Channels. */
1838
1930
  async fetchInvites() {
1839
- const data = await this.client.rest.get(Routes10.channelInvites(this.id));
1931
+ const data = await this.client.rest.get(Routes11.channelInvites(this.id));
1840
1932
  return data.map((i) => new Invite(this.client, i));
1841
1933
  }
1842
1934
  /** Edit or create a permission overwrite. Requires Manage Roles. */
1843
1935
  async editPermission(overwriteId, options) {
1844
- await this.client.rest.put(Routes10.channelPermission(this.id, overwriteId), {
1936
+ await this.client.rest.put(Routes11.channelPermission(this.id, overwriteId), {
1845
1937
  body: options,
1846
1938
  auth: true
1847
1939
  });
@@ -1857,7 +1949,7 @@ var GuildChannel = class extends Channel {
1857
1949
  }
1858
1950
  /** Delete a permission overwrite. Requires Manage Roles. */
1859
1951
  async deletePermission(overwriteId) {
1860
- await this.client.rest.delete(Routes10.channelPermission(this.id, overwriteId), { auth: true });
1952
+ await this.client.rest.delete(Routes11.channelPermission(this.id, overwriteId), { auth: true });
1861
1953
  const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
1862
1954
  if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
1863
1955
  }
@@ -1870,7 +1962,7 @@ var GuildChannel = class extends Channel {
1870
1962
  }
1871
1963
  /** Edit this channel's settings. Requires Manage Channels. */
1872
1964
  async edit(options) {
1873
- const data = await this.client.rest.patch(Routes10.channel(this.id), {
1965
+ const data = await this.client.rest.patch(Routes11.channel(this.id), {
1874
1966
  body: toChannelEditBody(options),
1875
1967
  auth: true
1876
1968
  });
@@ -1890,7 +1982,7 @@ var GuildChannel = class extends Channel {
1890
1982
  const qs2 = params.toString();
1891
1983
  const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
1892
1984
  const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
1893
- await this.client.rest.delete(Routes10.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1985
+ await this.client.rest.delete(Routes11.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
1894
1986
  body,
1895
1987
  auth: true
1896
1988
  });
@@ -1952,7 +2044,7 @@ var LinkChannel = class extends GuildChannel {
1952
2044
  };
1953
2045
 
1954
2046
  // src/structures/channel/dm.ts
1955
- import { ChannelType as ChannelType2, Routes as Routes11 } from "@fluxerjs/types";
2047
+ import { ChannelType as ChannelType2, Routes as Routes12 } from "@fluxerjs/types";
1956
2048
  var DMChannel = class extends TextCapable(Channel) {
1957
2049
  /** ID of the last message sent in this channel. */
1958
2050
  lastMessageId;
@@ -1978,28 +2070,28 @@ var DMChannel = class extends TextCapable(Channel) {
1978
2070
  });
1979
2071
  }
1980
2072
  const data = await this.client.rest.post(
1981
- Routes11.channelMessagesPurge(this.id),
2073
+ Routes12.channelMessagesPurge(this.id),
1982
2074
  { auth: true }
1983
2075
  );
1984
2076
  return data.deleted_count;
1985
2077
  }
1986
2078
  /** Pin this DM channel to the top of the DM list. */
1987
2079
  async pinInList() {
1988
- await this.client.rest.put(Routes11.userMeChannelPin(this.id), { auth: true });
2080
+ await this.client.rest.put(Routes12.userMeChannelPin(this.id), { auth: true });
1989
2081
  }
1990
2082
  /** Unpin this DM channel from the DM list. */
1991
2083
  async unpinFromList() {
1992
- await this.client.rest.delete(Routes11.userMeChannelPin(this.id), { auth: true });
2084
+ await this.client.rest.delete(Routes12.userMeChannelPin(this.id), { auth: true });
1993
2085
  }
1994
2086
  /** Add a user to this group DM. */
1995
2087
  async addRecipient(userId) {
1996
- await this.client.rest.put(Routes11.channelRecipient(this.id, userId), { auth: true });
2088
+ await this.client.rest.put(Routes12.channelRecipient(this.id, userId), { auth: true });
1997
2089
  const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
1998
2090
  if (user) this.recipients.push(user);
1999
2091
  }
2000
2092
  /** Remove a user from this group DM. */
2001
2093
  async removeRecipient(userId, options) {
2002
- const url = Routes11.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2094
+ const url = Routes12.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2003
2095
  await this.client.rest.delete(url, { auth: true });
2004
2096
  const idx = this.recipients.findIndex((u) => u.id === userId);
2005
2097
  if (idx >= 0) this.recipients.splice(idx, 1);
@@ -2037,8 +2129,8 @@ Channel.createDM = createDM;
2037
2129
 
2038
2130
  // src/client/ChannelManager.ts
2039
2131
  function rethrowNotFound(err, message, code) {
2040
- if (err instanceof RateLimitError2) throw err;
2041
- if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
2132
+ if (err instanceof RateLimitError3) throw err;
2133
+ if (err instanceof FluxerAPIError3 && err.statusCode === 404) {
2042
2134
  throw new FluxerError(message, { code, cause: err });
2043
2135
  }
2044
2136
  throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
@@ -2070,7 +2162,7 @@ var ChannelManager = class extends Collection5 {
2070
2162
  const cached = this.get(channelId);
2071
2163
  if (cached) return cached;
2072
2164
  try {
2073
- const data = await this.client.rest.get(Routes12.channel(channelId));
2165
+ const data = await this.client.rest.get(Routes13.channel(channelId));
2074
2166
  const channel = Channel.fromOrCreate(this.client, data);
2075
2167
  if (!channel) {
2076
2168
  throw new FluxerError("Channel data invalid or unsupported type", {
@@ -2103,7 +2195,7 @@ var ChannelManager = class extends Collection5 {
2103
2195
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
2104
2196
  });
2105
2197
  const data = await this.client.rest.post(
2106
- Routes12.channelMessages(channelId),
2198
+ Routes13.channelMessages(channelId),
2107
2199
  postPayload
2108
2200
  );
2109
2201
  this.client._addMessageToCache(channelId, data);
@@ -2113,8 +2205,8 @@ var ChannelManager = class extends Collection5 {
2113
2205
 
2114
2206
  // src/client/GuildManager.ts
2115
2207
  import { Collection as Collection9 } from "@fluxerjs/collection";
2116
- import { Routes as Routes27 } from "@fluxerjs/types";
2117
- import { FluxerAPIError as FluxerAPIError4, RateLimitError as RateLimitError3 } from "@fluxerjs/rest";
2208
+ import { Routes as Routes28 } from "@fluxerjs/types";
2209
+ import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
2118
2210
 
2119
2211
  // src/structures/guild/Guild.ts
2120
2212
  import { Collection as Collection8 } from "@fluxerjs/collection";
@@ -2122,10 +2214,10 @@ import { GuildNSFWLevel } from "@fluxerjs/types";
2122
2214
 
2123
2215
  // src/client/GuildMemberManager.ts
2124
2216
  import { Collection as Collection7 } from "@fluxerjs/collection";
2125
- import { Routes as Routes15 } from "@fluxerjs/types";
2217
+ import { Routes as Routes16 } from "@fluxerjs/types";
2126
2218
 
2127
2219
  // src/structures/GuildMember.ts
2128
- import { Routes as Routes14 } from "@fluxerjs/types";
2220
+ import { Routes as Routes15 } from "@fluxerjs/types";
2129
2221
  import { PermissionsBitField } from "@fluxerjs/util";
2130
2222
 
2131
2223
  // src/util/permissions.ts
@@ -2146,7 +2238,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
2146
2238
 
2147
2239
  // src/structures/GuildMemberRoleManager.ts
2148
2240
  import { Collection as Collection6 } from "@fluxerjs/collection";
2149
- import { Routes as Routes13 } from "@fluxerjs/types";
2241
+ import { Routes as Routes14 } from "@fluxerjs/types";
2150
2242
  function roleId(roleOrId) {
2151
2243
  return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
2152
2244
  }
@@ -2175,7 +2267,7 @@ var GuildMemberRoleManager = class {
2175
2267
  const id = roleId(roleOrId);
2176
2268
  if (this.ids.includes(id)) return;
2177
2269
  await this.member.client.rest.put(
2178
- Routes13.guildMemberRole(this.member.guild.id, this.member.id, id)
2270
+ Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
2179
2271
  );
2180
2272
  this.ids.push(id);
2181
2273
  }
@@ -2184,13 +2276,13 @@ var GuildMemberRoleManager = class {
2184
2276
  const idx = this.ids.indexOf(id);
2185
2277
  if (idx === -1) return;
2186
2278
  await this.member.client.rest.delete(
2187
- Routes13.guildMemberRole(this.member.guild.id, this.member.id, id)
2279
+ Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
2188
2280
  );
2189
2281
  this.ids.splice(idx, 1);
2190
2282
  }
2191
2283
  async set(roleIds) {
2192
2284
  const data = await this.member.client.rest.patch(
2193
- Routes13.guildMember(this.member.guild.id, this.member.id),
2285
+ Routes14.guildMember(this.member.guild.id, this.member.id),
2194
2286
  { body: { roles: roleIds }, auth: true }
2195
2287
  );
2196
2288
  this.ids = data.roles ? [...data.roles] : [];
@@ -2317,7 +2409,7 @@ var GuildMember = class _GuildMember extends Base {
2317
2409
  /** PATCH member (`/members/@me` when editing the bot). */
2318
2410
  async edit(options) {
2319
2411
  const isMe = this.client.user?.id === this.id;
2320
- const route = isMe ? Routes14.guildMemberMe(this.guild.id) : Routes14.guildMember(this.guild.id, this.id);
2412
+ const route = isMe ? Routes15.guildMemberMe(this.guild.id) : Routes15.guildMember(this.guild.id, this.id);
2321
2413
  const data = await this.client.rest.patch(route, {
2322
2414
  body: toMemberEditBody(options),
2323
2415
  auth: true
@@ -2446,7 +2538,7 @@ var GuildMemberManager = class extends Collection7 {
2446
2538
  if (options?.limit != null) params.set("limit", String(options.limit));
2447
2539
  if (options?.after) params.set("after", options.after);
2448
2540
  const qs2 = params.toString();
2449
- const url = Routes15.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2541
+ const url = Routes16.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
2450
2542
  const data = await this.guild.client.rest.get(url, { auth: true });
2451
2543
  const members = [];
2452
2544
  for (const m of data) {
@@ -2469,7 +2561,7 @@ var GuildMemberManager = class extends Collection7 {
2469
2561
  */
2470
2562
  async search(options = {}) {
2471
2563
  const data = await this.guild.client.rest.post(
2472
- Routes15.guildMembersSearch(this.guild.id),
2564
+ Routes16.guildMembersSearch(this.guild.id),
2473
2565
  { body: toMemberSearchBody(options), auth: true }
2474
2566
  );
2475
2567
  const offset = options.offset ?? 0;
@@ -2495,7 +2587,7 @@ var GuildMemberManager = class extends Collection7 {
2495
2587
  };
2496
2588
 
2497
2589
  // src/structures/Role.ts
2498
- import { Routes as Routes16 } from "@fluxerjs/types";
2590
+ import { Routes as Routes17 } from "@fluxerjs/types";
2499
2591
  import { ALL_PERMISSIONS_BIGINT as ALL_PERMISSIONS_BIGINT2, PermissionFlags as PermissionFlags4, PermissionsBitField as PermissionsBitField2 } from "@fluxerjs/util";
2500
2592
 
2501
2593
  // src/structures/roleOptions.ts
@@ -2608,7 +2700,7 @@ var Role = class _Role extends Base {
2608
2700
  */
2609
2701
  async edit(options) {
2610
2702
  const body = toRoleRequestBody(options);
2611
- const data = await this.client.rest.patch(Routes16.guildRole(this.guildId, this.id), {
2703
+ const data = await this.client.rest.patch(Routes17.guildRole(this.guildId, this.id), {
2612
2704
  body: Object.keys(body).length ? body : void 0,
2613
2705
  auth: true
2614
2706
  });
@@ -2619,18 +2711,18 @@ var Role = class _Role extends Base {
2619
2711
  * DELETE role. Requires Manage Roles.
2620
2712
  */
2621
2713
  async delete() {
2622
- await this.client.rest.delete(Routes16.guildRole(this.guildId, this.id), { auth: true });
2714
+ await this.client.rest.delete(Routes17.guildRole(this.guildId, this.id), { auth: true });
2623
2715
  this.client.guilds.get(this.guildId)?.roles.delete(this.id);
2624
2716
  }
2625
2717
  };
2626
2718
 
2627
2719
  // src/structures/guild/admin.ts
2628
- import { Routes as Routes17 } from "@fluxerjs/types";
2720
+ import { Routes as Routes18 } from "@fluxerjs/types";
2629
2721
 
2630
2722
  // src/structures/guild/http.ts
2631
- import { FluxerAPIError as FluxerAPIError3 } from "@fluxerjs/rest";
2723
+ import { FluxerAPIError as FluxerAPIError4 } from "@fluxerjs/rest";
2632
2724
  function httpStatus(err) {
2633
- if (err instanceof FluxerAPIError3) return err.statusCode;
2725
+ if (err instanceof FluxerAPIError4) return err.statusCode;
2634
2726
  if (typeof err === "object" && err !== null && "statusCode" in err) {
2635
2727
  const code = err.statusCode;
2636
2728
  return typeof code === "number" ? code : void 0;
@@ -2730,7 +2822,7 @@ function toVanityPayload(data) {
2730
2822
  return { code: data.code ?? null, uses: data.uses };
2731
2823
  }
2732
2824
  async function fetchAuditLogs(guild, options) {
2733
- const url = Routes17.guildAuditLogs(guild.id) + qs({
2825
+ const url = Routes18.guildAuditLogs(guild.id) + qs({
2734
2826
  limit: options?.limit,
2735
2827
  before: options?.before,
2736
2828
  after: options?.after,
@@ -2751,7 +2843,7 @@ async function fetchAuditLogs(guild, options) {
2751
2843
  };
2752
2844
  }
2753
2845
  async function editGuild(guild, options) {
2754
- const data = await guild.client.rest.patch(Routes17.guild(guild.id), {
2846
+ const data = await guild.client.rest.patch(Routes18.guild(guild.id), {
2755
2847
  body: toGuildEditBody(options),
2756
2848
  auth: true
2757
2849
  });
@@ -2759,13 +2851,13 @@ async function editGuild(guild, options) {
2759
2851
  return guild;
2760
2852
  }
2761
2853
  async function fetchVanityURL(guild) {
2762
- const data = await guild.client.rest.get(Routes17.guildVanityUrl(guild.id), {
2854
+ const data = await guild.client.rest.get(Routes18.guildVanityUrl(guild.id), {
2763
2855
  auth: true
2764
2856
  });
2765
2857
  return toVanityPayload(data);
2766
2858
  }
2767
2859
  async function editVanityURL(guild, code) {
2768
- const data = await guild.client.rest.patch(Routes17.guildVanityUrl(guild.id), {
2860
+ const data = await guild.client.rest.patch(Routes18.guildVanityUrl(guild.id), {
2769
2861
  body: { code },
2770
2862
  auth: true
2771
2863
  });
@@ -2773,14 +2865,14 @@ async function editVanityURL(guild, code) {
2773
2865
  return toVanityPayload(data);
2774
2866
  }
2775
2867
  async function fetchDiscoveryStatus(guild) {
2776
- const data = await guild.client.rest.get(Routes17.guildDiscovery(guild.id), {
2868
+ const data = await guild.client.rest.get(Routes18.guildDiscovery(guild.id), {
2777
2869
  auth: true
2778
2870
  });
2779
2871
  return toDiscoveryStatusPayload(data);
2780
2872
  }
2781
2873
  async function applyForDiscovery(guild, options) {
2782
2874
  const data = await guild.client.rest.post(
2783
- Routes17.guildDiscovery(guild.id),
2875
+ Routes18.guildDiscovery(guild.id),
2784
2876
  {
2785
2877
  body: toDiscoveryBody(options),
2786
2878
  auth: true
@@ -2790,7 +2882,7 @@ async function applyForDiscovery(guild, options) {
2790
2882
  }
2791
2883
  async function editDiscoveryApplication(guild, options) {
2792
2884
  const data = await guild.client.rest.patch(
2793
- Routes17.guildDiscovery(guild.id),
2885
+ Routes18.guildDiscovery(guild.id),
2794
2886
  {
2795
2887
  body: toDiscoveryBody(options),
2796
2888
  auth: true
@@ -2799,28 +2891,28 @@ async function editDiscoveryApplication(guild, options) {
2799
2891
  return toDiscoveryApplicationPayload(data);
2800
2892
  }
2801
2893
  async function withdrawDiscoveryApplication(guild) {
2802
- await guild.client.rest.delete(Routes17.guildDiscovery(guild.id), { auth: true });
2894
+ await guild.client.rest.delete(Routes18.guildDiscovery(guild.id), { auth: true });
2803
2895
  }
2804
2896
  async function deleteGuild(guild, options) {
2805
2897
  const body = options ? toSudoBody(options) : {};
2806
- await guild.client.rest.post(Routes17.guildDelete(guild.id), {
2898
+ await guild.client.rest.post(Routes18.guildDelete(guild.id), {
2807
2899
  body,
2808
2900
  auth: true
2809
2901
  });
2810
2902
  guild.client.guilds.delete(guild.id);
2811
2903
  }
2812
2904
  async function transferOwnership(guild, newOwnerId, password) {
2813
- await guild.client.rest.post(Routes17.guildTransferOwnership(guild.id), {
2905
+ await guild.client.rest.post(Routes18.guildTransferOwnership(guild.id), {
2814
2906
  body: { new_owner_id: newOwnerId, ...password != null && { password } },
2815
2907
  auth: true
2816
2908
  });
2817
2909
  }
2818
2910
 
2819
2911
  // src/structures/guild/channels.ts
2820
- import { Routes as Routes20 } from "@fluxerjs/types";
2912
+ import { Routes as Routes21 } from "@fluxerjs/types";
2821
2913
 
2822
2914
  // src/structures/GuildEmoji.ts
2823
- import { Routes as Routes18 } from "@fluxerjs/types";
2915
+ import { Routes as Routes19 } from "@fluxerjs/types";
2824
2916
  var GuildEmoji = class extends Base {
2825
2917
  client;
2826
2918
  id;
@@ -2848,7 +2940,7 @@ var GuildEmoji = class extends Base {
2848
2940
  }
2849
2941
  /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
2850
2942
  async delete() {
2851
- await this.client.rest.delete(Routes18.guildEmoji(this.guildId, this.id), {
2943
+ await this.client.rest.delete(Routes19.guildEmoji(this.guildId, this.id), {
2852
2944
  auth: true
2853
2945
  });
2854
2946
  const guild = this.client.guilds.get(this.guildId);
@@ -2859,7 +2951,7 @@ var GuildEmoji = class extends Base {
2859
2951
  * Requires Manage Emojis and Stickers permission.
2860
2952
  */
2861
2953
  async edit(options) {
2862
- const data = await this.client.rest.patch(Routes18.guildEmoji(this.guildId, this.id), {
2954
+ const data = await this.client.rest.patch(Routes19.guildEmoji(this.guildId, this.id), {
2863
2955
  body: options,
2864
2956
  auth: true
2865
2957
  });
@@ -2869,7 +2961,7 @@ var GuildEmoji = class extends Base {
2869
2961
  };
2870
2962
 
2871
2963
  // src/structures/GuildSticker.ts
2872
- import { Routes as Routes19 } from "@fluxerjs/types";
2964
+ import { Routes as Routes20 } from "@fluxerjs/types";
2873
2965
  var GuildSticker = class extends Base {
2874
2966
  client;
2875
2967
  id;
@@ -2900,7 +2992,7 @@ var GuildSticker = class extends Base {
2900
2992
  }
2901
2993
  /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
2902
2994
  async delete() {
2903
- await this.client.rest.delete(Routes19.guildSticker(this.guildId, this.id), {
2995
+ await this.client.rest.delete(Routes20.guildSticker(this.guildId, this.id), {
2904
2996
  auth: true
2905
2997
  });
2906
2998
  }
@@ -2909,7 +3001,7 @@ var GuildSticker = class extends Base {
2909
3001
  * Requires Manage Emojis and Stickers permission.
2910
3002
  */
2911
3003
  async edit(options) {
2912
- const data = await this.client.rest.patch(Routes19.guildSticker(this.guildId, this.id), {
3004
+ const data = await this.client.rest.patch(Routes20.guildSticker(this.guildId, this.id), {
2913
3005
  body: options,
2914
3006
  auth: true
2915
3007
  });
@@ -2964,14 +3056,14 @@ function cacheSticker(guild, data) {
2964
3056
 
2965
3057
  // src/structures/guild/channels.ts
2966
3058
  async function createChannel(guild, data) {
2967
- const created = await guild.client.rest.post(Routes20.guildChannels(guild.id), {
3059
+ const created = await guild.client.rest.post(Routes21.guildChannels(guild.id), {
2968
3060
  body: data,
2969
3061
  auth: true
2970
3062
  });
2971
3063
  return cacheChannel(guild, created);
2972
3064
  }
2973
3065
  async function fetchChannels(guild) {
2974
- const data = await guild.client.rest.get(Routes20.guildChannels(guild.id));
3066
+ const data = await guild.client.rest.get(Routes21.guildChannels(guild.id));
2975
3067
  const channels = [];
2976
3068
  for (const ch of data) {
2977
3069
  const channel = cacheChannel(guild, ch);
@@ -2980,17 +3072,17 @@ async function fetchChannels(guild) {
2980
3072
  return channels;
2981
3073
  }
2982
3074
  async function setChannelPositions(guild, updates) {
2983
- await guild.client.rest.patch(Routes20.guildChannels(guild.id), {
3075
+ await guild.client.rest.patch(Routes21.guildChannels(guild.id), {
2984
3076
  body: toChannelPositionBody(updates),
2985
3077
  auth: true
2986
3078
  });
2987
3079
  }
2988
3080
  async function fetchWebhooks(guild) {
2989
- const data = await guild.client.rest.get(Routes20.guildWebhooks(guild.id));
3081
+ const data = await guild.client.rest.get(Routes21.guildWebhooks(guild.id));
2990
3082
  return data.map((w) => new Webhook(guild.client, w));
2991
3083
  }
2992
3084
  async function fetchInvites(guild) {
2993
- const data = await guild.client.rest.get(Routes20.guildInvites(guild.id));
3085
+ const data = await guild.client.rest.get(Routes21.guildInvites(guild.id));
2994
3086
  return data.map((invite) => new Invite(guild.client, invite));
2995
3087
  }
2996
3088
  async function fetchInvite(guild, codeOrUrl) {
@@ -2998,14 +3090,14 @@ async function fetchInvite(guild, codeOrUrl) {
2998
3090
  }
2999
3091
 
3000
3092
  // src/structures/guild/emojis.ts
3001
- import { Routes as Routes21 } from "@fluxerjs/types";
3093
+ import { Routes as Routes22 } from "@fluxerjs/types";
3002
3094
  async function fetchEmojis(guild) {
3003
- const data = await guild.client.rest.get(Routes21.guildEmojis(guild.id));
3095
+ const data = await guild.client.rest.get(Routes22.guildEmojis(guild.id));
3004
3096
  return data.map((e) => cacheEmoji(guild, e));
3005
3097
  }
3006
3098
  async function fetchEmoji(guild, emojiId) {
3007
3099
  try {
3008
- const data = await guild.client.rest.get(Routes21.guildEmoji(guild.id, emojiId));
3100
+ const data = await guild.client.rest.get(Routes22.guildEmoji(guild.id, emojiId));
3009
3101
  return cacheEmoji(guild, data);
3010
3102
  } catch (err) {
3011
3103
  rethrowNotFound2(
@@ -3016,14 +3108,14 @@ async function fetchEmoji(guild, emojiId) {
3016
3108
  }
3017
3109
  }
3018
3110
  async function createEmoji(guild, options) {
3019
- const data = await guild.client.rest.post(Routes21.guildEmojis(guild.id), {
3111
+ const data = await guild.client.rest.post(Routes22.guildEmojis(guild.id), {
3020
3112
  body: options,
3021
3113
  auth: true
3022
3114
  });
3023
3115
  return cacheEmoji(guild, data);
3024
3116
  }
3025
3117
  async function cloneEmoji(guild, sourceEmojiId) {
3026
- const data = await guild.client.rest.post(Routes21.guildEmojisClone(guild.id), {
3118
+ const data = await guild.client.rest.post(Routes22.guildEmojisClone(guild.id), {
3027
3119
  body: { source_emoji_id: sourceEmojiId },
3028
3120
  auth: true
3029
3121
  });
@@ -3031,18 +3123,18 @@ async function cloneEmoji(guild, sourceEmojiId) {
3031
3123
  }
3032
3124
  async function createEmojisBulk(guild, emojis) {
3033
3125
  const data = await guild.client.rest.post(
3034
- Routes21.guildEmojisBulk(guild.id),
3126
+ Routes22.guildEmojisBulk(guild.id),
3035
3127
  { body: { emojis }, auth: true }
3036
3128
  );
3037
3129
  return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
3038
3130
  }
3039
3131
 
3040
3132
  // src/structures/guild/members.ts
3041
- import { Routes as Routes22 } from "@fluxerjs/types";
3133
+ import { Routes as Routes23 } from "@fluxerjs/types";
3042
3134
  async function fetchMember(guild, userId) {
3043
3135
  try {
3044
3136
  const data = await guild.client.rest.get(
3045
- Routes22.guildMember(guild.id, userId)
3137
+ Routes23.guildMember(guild.id, userId)
3046
3138
  );
3047
3139
  return cacheMember(guild, data);
3048
3140
  } catch (err) {
@@ -3055,17 +3147,17 @@ async function fetchMember(guild, userId) {
3055
3147
  }
3056
3148
  async function fetchMe(guild) {
3057
3149
  const data = await guild.client.rest.get(
3058
- Routes22.guildMemberMe(guild.id),
3150
+ Routes23.guildMemberMe(guild.id),
3059
3151
  { auth: true }
3060
3152
  );
3061
3153
  return cacheMember(guild, data);
3062
3154
  }
3063
3155
 
3064
3156
  // src/structures/guild/moderation.ts
3065
- import { Routes as Routes24 } from "@fluxerjs/types";
3157
+ import { Routes as Routes25 } from "@fluxerjs/types";
3066
3158
 
3067
3159
  // src/structures/GuildBan.ts
3068
- import { Routes as Routes23 } from "@fluxerjs/types";
3160
+ import { Routes as Routes24 } from "@fluxerjs/types";
3069
3161
  var GuildBan = class extends Base {
3070
3162
  client;
3071
3163
  guildId;
@@ -3087,7 +3179,7 @@ var GuildBan = class extends Base {
3087
3179
  * Requires Ban Members permission.
3088
3180
  */
3089
3181
  async unban() {
3090
- await this.client.rest.delete(Routes23.guildBan(this.guildId, this.user.id), {
3182
+ await this.client.rest.delete(Routes24.guildBan(this.guildId, this.user.id), {
3091
3183
  auth: true
3092
3184
  });
3093
3185
  }
@@ -3096,40 +3188,40 @@ var GuildBan = class extends Base {
3096
3188
  // src/structures/guild/moderation.ts
3097
3189
  async function ban(guild, userId, options) {
3098
3190
  const body = options ? toGuildBanBody(options) : {};
3099
- await guild.client.rest.put(Routes24.guildBan(guild.id, userId), {
3191
+ await guild.client.rest.put(Routes25.guildBan(guild.id, userId), {
3100
3192
  body: Object.keys(body).length ? body : void 0,
3101
3193
  auth: true
3102
3194
  });
3103
3195
  }
3104
3196
  async function fetchBans(guild) {
3105
- const data = await guild.client.rest.get(Routes24.guildBans(guild.id));
3197
+ const data = await guild.client.rest.get(Routes25.guildBans(guild.id));
3106
3198
  return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
3107
3199
  }
3108
3200
  async function unban(guild, userId) {
3109
- await guild.client.rest.delete(Routes24.guildBan(guild.id, userId), { auth: true });
3201
+ await guild.client.rest.delete(Routes25.guildBan(guild.id, userId), { auth: true });
3110
3202
  }
3111
3203
  async function kick(guild, userId) {
3112
- await guild.client.rest.delete(Routes24.guildMember(guild.id, userId), { auth: true });
3204
+ await guild.client.rest.delete(Routes25.guildMember(guild.id, userId), { auth: true });
3113
3205
  }
3114
3206
 
3115
3207
  // src/structures/guild/roles.ts
3116
- import { Routes as Routes25 } from "@fluxerjs/types";
3208
+ import { Routes as Routes26 } from "@fluxerjs/types";
3117
3209
  import { parseRoleMention } from "@fluxerjs/util";
3118
3210
  async function createRole(guild, options = {}) {
3119
3211
  const body = toRoleRequestBody(options);
3120
- const data = await guild.client.rest.post(Routes25.guildRoles(guild.id), {
3212
+ const data = await guild.client.rest.post(Routes26.guildRoles(guild.id), {
3121
3213
  body: Object.keys(body).length ? body : void 0,
3122
3214
  auth: true
3123
3215
  });
3124
3216
  return cacheRole(guild, data);
3125
3217
  }
3126
3218
  async function fetchRoles(guild) {
3127
- const data = await guild.client.rest.get(Routes25.guildRoles(guild.id));
3219
+ const data = await guild.client.rest.get(Routes26.guildRoles(guild.id));
3128
3220
  return data.map((r) => cacheRole(guild, r));
3129
3221
  }
3130
3222
  async function fetchRole(guild, roleId2) {
3131
3223
  try {
3132
- const data = await guild.client.rest.get(Routes25.guildRole(guild.id, roleId2));
3224
+ const data = await guild.client.rest.get(Routes26.guildRole(guild.id, roleId2));
3133
3225
  return cacheRole(guild, data);
3134
3226
  } catch (err) {
3135
3227
  rethrowNotFound2(
@@ -3147,7 +3239,7 @@ async function resolveRoleId(guild, arg) {
3147
3239
  const needle = trimmed.toLowerCase();
3148
3240
  const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
3149
3241
  if (cached) return cached.id;
3150
- const roles = await guild.client.rest.get(Routes25.guildRoles(guild.id));
3242
+ const roles = await guild.client.rest.get(Routes26.guildRoles(guild.id));
3151
3243
  const role = roles.find((r) => r.name?.toLowerCase() === needle);
3152
3244
  if (!role) return null;
3153
3245
  cacheRole(guild, role);
@@ -3156,7 +3248,7 @@ async function resolveRoleId(guild, arg) {
3156
3248
  async function setRolePositions(guild, updates) {
3157
3249
  return replaceRoles(
3158
3250
  guild,
3159
- await guild.client.rest.patch(Routes25.guildRoles(guild.id), {
3251
+ await guild.client.rest.patch(Routes26.guildRoles(guild.id), {
3160
3252
  body: updates,
3161
3253
  auth: true
3162
3254
  })
@@ -3165,7 +3257,7 @@ async function setRolePositions(guild, updates) {
3165
3257
  async function setRoleHoistPositions(guild, updates) {
3166
3258
  return replaceRoles(
3167
3259
  guild,
3168
- await guild.client.rest.patch(Routes25.guildRolesHoistPositions(guild.id), {
3260
+ await guild.client.rest.patch(Routes26.guildRolesHoistPositions(guild.id), {
3169
3261
  body: updates.map((u) => ({
3170
3262
  id: u.id,
3171
3263
  ...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
@@ -3177,23 +3269,23 @@ async function setRoleHoistPositions(guild, updates) {
3177
3269
  async function resetRoleHoistPositions(guild) {
3178
3270
  return replaceRoles(
3179
3271
  guild,
3180
- await guild.client.rest.delete(Routes25.guildRolesHoistPositions(guild.id), {
3272
+ await guild.client.rest.delete(Routes26.guildRolesHoistPositions(guild.id), {
3181
3273
  auth: true
3182
3274
  })
3183
3275
  );
3184
3276
  }
3185
3277
 
3186
3278
  // src/structures/guild/stickers.ts
3187
- import { Routes as Routes26 } from "@fluxerjs/types";
3279
+ import { Routes as Routes27 } from "@fluxerjs/types";
3188
3280
  async function createSticker(guild, options) {
3189
- const data = await guild.client.rest.post(Routes26.guildStickers(guild.id), {
3281
+ const data = await guild.client.rest.post(Routes27.guildStickers(guild.id), {
3190
3282
  body: options,
3191
3283
  auth: true
3192
3284
  });
3193
3285
  return cacheSticker(guild, data);
3194
3286
  }
3195
3287
  async function cloneSticker(guild, sourceStickerId) {
3196
- const data = await guild.client.rest.post(Routes26.guildStickersClone(guild.id), {
3288
+ const data = await guild.client.rest.post(Routes27.guildStickersClone(guild.id), {
3197
3289
  body: { source_sticker_id: sourceStickerId },
3198
3290
  auth: true
3199
3291
  });
@@ -3201,17 +3293,17 @@ async function cloneSticker(guild, sourceStickerId) {
3201
3293
  }
3202
3294
  async function createStickersBulk(guild, stickers) {
3203
3295
  const data = await guild.client.rest.post(
3204
- Routes26.guildStickersBulk(guild.id),
3296
+ Routes27.guildStickersBulk(guild.id),
3205
3297
  { body: { stickers }, auth: true }
3206
3298
  );
3207
3299
  return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
3208
3300
  }
3209
3301
  async function fetchStickers(guild) {
3210
- const data = await guild.client.rest.get(Routes26.guildStickers(guild.id));
3302
+ const data = await guild.client.rest.get(Routes27.guildStickers(guild.id));
3211
3303
  return data.map((s) => cacheSticker(guild, s));
3212
3304
  }
3213
3305
  async function fetchSticker(guild, stickerId) {
3214
- const data = await guild.client.rest.get(Routes26.guildSticker(guild.id, stickerId));
3306
+ const data = await guild.client.rest.get(Routes27.guildSticker(guild.id, stickerId));
3215
3307
  return cacheSticker(guild, data);
3216
3308
  }
3217
3309
 
@@ -3221,6 +3313,8 @@ var Guild = class extends Base {
3221
3313
  client;
3222
3314
  /** Snowflake ID of this guild. */
3223
3315
  id;
3316
+ /** Whether the guild is currently available through the gateway. */
3317
+ available = true;
3224
3318
  /** Guild name. */
3225
3319
  name;
3226
3320
  /** Icon hash (use {@link iconURL} to get full CDN URL). */
@@ -3556,13 +3650,13 @@ var GuildManager = class extends Collection9 {
3556
3650
  const cached = this.get(guildId);
3557
3651
  if (cached) return cached;
3558
3652
  try {
3559
- const data = await this.client.rest.get(Routes27.guild(guildId));
3653
+ const data = await this.client.rest.get(Routes28.guild(guildId));
3560
3654
  const guild = new Guild(this.client, data);
3561
3655
  this.set(guild.id, guild);
3562
3656
  return guild;
3563
3657
  } catch (err) {
3564
- if (err instanceof RateLimitError3) throw err;
3565
- if (err instanceof FluxerAPIError4 && err.statusCode === 404) {
3658
+ if (err instanceof RateLimitError4) throw err;
3659
+ if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
3566
3660
  throw new FluxerError(`Guild ${guildId} not found`, {
3567
3661
  code: ErrorCodes.GuildNotFound,
3568
3662
  cause: err
@@ -3583,7 +3677,7 @@ var DEFAULT_CACHE_LIMITS = {
3583
3677
  };
3584
3678
 
3585
3679
  // src/structures/User.ts
3586
- import { Routes as Routes28 } from "@fluxerjs/types";
3680
+ import { Routes as Routes29 } from "@fluxerjs/types";
3587
3681
  var User = class extends Base {
3588
3682
  /** Parent client instance. */
3589
3683
  client;
@@ -3673,7 +3767,7 @@ var User = class extends Base {
3673
3767
  * @returns DM channel instance (cached if already open)
3674
3768
  */
3675
3769
  async createDM() {
3676
- const data = await this.client.rest.post(Routes28.userMeChannels(), {
3770
+ const data = await this.client.rest.post(Routes29.userMeChannels(), {
3677
3771
  body: { recipient_id: this.id },
3678
3772
  auth: true
3679
3773
  });
@@ -3683,7 +3777,7 @@ var User = class extends Base {
3683
3777
  }
3684
3778
  /**
3685
3779
  * Send a DM to this user.
3686
- * @param options - Message content or {@link MessageSendOptions}
3780
+ * @param options - {@link MessagePrepareInput}
3687
3781
  * @returns Sent message
3688
3782
  */
3689
3783
  async send(options) {
@@ -3694,7 +3788,7 @@ var User = class extends Base {
3694
3788
  // src/client/UserManager.ts
3695
3789
  import { Collection as Collection10 } from "@fluxerjs/collection";
3696
3790
  import {
3697
- Routes as Routes29
3791
+ Routes as Routes30
3698
3792
  } from "@fluxerjs/types";
3699
3793
  var soft = (p) => p.catch(() => null);
3700
3794
  var UserManager = class extends Collection10 {
@@ -3726,7 +3820,7 @@ var UserManager = class extends Collection10 {
3726
3820
  }
3727
3821
  /** Fetch a user by ID and update cache. */
3728
3822
  async fetch(userId) {
3729
- const data = await this.client.rest.get(Routes29.user(userId));
3823
+ const data = await this.client.rest.get(Routes30.user(userId));
3730
3824
  return this.client.getOrCreateUser(data);
3731
3825
  }
3732
3826
  /**
@@ -3740,10 +3834,10 @@ var UserManager = class extends Collection10 {
3740
3834
  async fetchWithProfile(userId, options) {
3741
3835
  const guildId = options?.guildId ?? void 0;
3742
3836
  const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
3743
- this.client.rest.get(Routes29.user(userId)),
3744
- soft(this.client.rest.get(Routes29.userProfile(userId))),
3745
- guildId ? soft(this.client.rest.get(Routes29.userProfile(userId, guildId))) : null,
3746
- guildId ? soft(this.client.rest.get(Routes29.guildMember(guildId, userId))) : null
3837
+ this.client.rest.get(Routes30.user(userId)),
3838
+ soft(this.client.rest.get(Routes30.userProfile(userId))),
3839
+ guildId ? soft(this.client.rest.get(Routes30.userProfile(userId, guildId))) : null,
3840
+ guildId ? soft(this.client.rest.get(Routes30.guildMember(guildId, userId))) : null
3747
3841
  ]);
3748
3842
  const user = this.client.getOrCreateUser(userData);
3749
3843
  let member = null;
@@ -3773,7 +3867,7 @@ var UserManager = class extends Collection10 {
3773
3867
 
3774
3868
  // src/client/PackManager.ts
3775
3869
  import {
3776
- Routes as Routes30
3870
+ Routes as Routes31
3777
3871
  } from "@fluxerjs/types";
3778
3872
  function toPackSummaryPayload(data) {
3779
3873
  return {
@@ -3829,7 +3923,7 @@ var PackManager = class {
3829
3923
  }
3830
3924
  /** Fetch the current user's pack dashboard (camelCase summaries). */
3831
3925
  async fetchDashboard() {
3832
- const data = await this.client.rest.get(Routes30.packs());
3926
+ const data = await this.client.rest.get(Routes31.packs());
3833
3927
  return {
3834
3928
  emoji: mapDashboardSection(data.emoji),
3835
3929
  sticker: mapDashboardSection(data.sticker)
@@ -3837,49 +3931,49 @@ var PackManager = class {
3837
3931
  }
3838
3932
  /** Create a pack. */
3839
3933
  async create(packType, body) {
3840
- const data = await this.client.rest.post(Routes30.packsByType(packType), {
3934
+ const data = await this.client.rest.post(Routes31.packsByType(packType), {
3841
3935
  body
3842
3936
  });
3843
3937
  return toPackSummaryPayload(data);
3844
3938
  }
3845
3939
  /** Edit a pack. */
3846
3940
  async edit(packId, body) {
3847
- const data = await this.client.rest.patch(Routes30.pack(packId), { body });
3941
+ const data = await this.client.rest.patch(Routes31.pack(packId), { body });
3848
3942
  return toPackSummaryPayload(data);
3849
3943
  }
3850
3944
  /** Delete a pack. */
3851
3945
  async delete(packId) {
3852
- await this.client.rest.delete(Routes30.pack(packId));
3946
+ await this.client.rest.delete(Routes31.pack(packId));
3853
3947
  }
3854
3948
  /** Install a pack for the current user. */
3855
3949
  async install(packId) {
3856
- await this.client.rest.post(Routes30.packInstall(packId));
3950
+ await this.client.rest.post(Routes31.packInstall(packId));
3857
3951
  }
3858
3952
  /** Uninstall a pack for the current user. */
3859
3953
  async uninstall(packId) {
3860
- await this.client.rest.delete(Routes30.packInstall(packId));
3954
+ await this.client.rest.delete(Routes31.packInstall(packId));
3861
3955
  }
3862
3956
  /** List invites for a pack. */
3863
3957
  async listInvites(packId) {
3864
- const data = await this.client.rest.get(Routes30.packInvites(packId));
3958
+ const data = await this.client.rest.get(Routes31.packInvites(packId));
3865
3959
  return data.map(toInvitePayload);
3866
3960
  }
3867
3961
  /** Create an invite for a pack. */
3868
3962
  async createInvite(packId, options = {}) {
3869
3963
  const body = toPackInviteBody(options);
3870
- const data = await this.client.rest.post(Routes30.packInvites(packId), {
3964
+ const data = await this.client.rest.post(Routes31.packInvites(packId), {
3871
3965
  body: Object.keys(body).length ? body : void 0
3872
3966
  });
3873
3967
  return toInvitePayload(data);
3874
3968
  }
3875
3969
  /** List emojis in a pack. */
3876
3970
  async listEmojis(packId) {
3877
- const data = await this.client.rest.get(Routes30.packEmojis(packId));
3971
+ const data = await this.client.rest.get(Routes31.packEmojis(packId));
3878
3972
  return data.map(toEmojiPayload);
3879
3973
  }
3880
3974
  /** Create an emoji in a pack. */
3881
3975
  async createEmoji(packId, options) {
3882
- const data = await this.client.rest.post(Routes30.packEmojis(packId), {
3976
+ const data = await this.client.rest.post(Routes31.packEmojis(packId), {
3883
3977
  body: toEmojiCreateBody(options)
3884
3978
  });
3885
3979
  return toEmojiPayload(data);
@@ -3887,7 +3981,7 @@ var PackManager = class {
3887
3981
  /** Bulk-create emojis in a pack. */
3888
3982
  async createEmojisBulk(packId, emojis) {
3889
3983
  const data = await this.client.rest.post(
3890
- Routes30.packEmojisBulk(packId),
3984
+ Routes31.packEmojisBulk(packId),
3891
3985
  { body: { emojis: emojis.map(toEmojiCreateBody) } }
3892
3986
  );
3893
3987
  return {
@@ -3897,23 +3991,23 @@ var PackManager = class {
3897
3991
  }
3898
3992
  /** Edit an emoji in a pack. */
3899
3993
  async editEmoji(packId, emojiId, options) {
3900
- const data = await this.client.rest.patch(Routes30.packEmoji(packId, emojiId), {
3994
+ const data = await this.client.rest.patch(Routes31.packEmoji(packId, emojiId), {
3901
3995
  body: toEmojiEditBody(options)
3902
3996
  });
3903
3997
  return toEmojiPayload(data);
3904
3998
  }
3905
3999
  /** Delete an emoji from a pack. */
3906
4000
  async deleteEmoji(packId, emojiId) {
3907
- await this.client.rest.delete(Routes30.packEmoji(packId, emojiId));
4001
+ await this.client.rest.delete(Routes31.packEmoji(packId, emojiId));
3908
4002
  }
3909
4003
  /** List stickers in a pack. */
3910
4004
  async listStickers(packId) {
3911
- const data = await this.client.rest.get(Routes30.packStickers(packId));
4005
+ const data = await this.client.rest.get(Routes31.packStickers(packId));
3912
4006
  return data.map(toStickerPayload);
3913
4007
  }
3914
4008
  /** Create a sticker in a pack. */
3915
4009
  async createSticker(packId, options) {
3916
- const data = await this.client.rest.post(Routes30.packStickers(packId), {
4010
+ const data = await this.client.rest.post(Routes31.packStickers(packId), {
3917
4011
  body: toStickerCreateBody(options)
3918
4012
  });
3919
4013
  return toStickerPayload(data);
@@ -3921,7 +4015,7 @@ var PackManager = class {
3921
4015
  /** Bulk-create stickers in a pack. */
3922
4016
  async createStickersBulk(packId, stickers) {
3923
4017
  const data = await this.client.rest.post(
3924
- Routes30.packStickersBulk(packId),
4018
+ Routes31.packStickersBulk(packId),
3925
4019
  { body: { stickers: stickers.map(toStickerCreateBody) } }
3926
4020
  );
3927
4021
  return {
@@ -3931,14 +4025,14 @@ var PackManager = class {
3931
4025
  }
3932
4026
  /** Edit a sticker in a pack. */
3933
4027
  async editSticker(packId, stickerId, options) {
3934
- const data = await this.client.rest.patch(Routes30.packSticker(packId, stickerId), {
4028
+ const data = await this.client.rest.patch(Routes31.packSticker(packId, stickerId), {
3935
4029
  body: toStickerEditBody(options)
3936
4030
  });
3937
4031
  return toStickerPayload(data);
3938
4032
  }
3939
4033
  /** Delete a sticker from a pack. */
3940
4034
  async deleteSticker(packId, stickerId) {
3941
- await this.client.rest.delete(Routes30.packSticker(packId, stickerId));
4035
+ await this.client.rest.delete(Routes31.packSticker(packId, stickerId));
3942
4036
  }
3943
4037
  };
3944
4038
 
@@ -3957,10 +4051,10 @@ function createEventMethods(client) {
3957
4051
 
3958
4052
  // src/client/clientEmoji.ts
3959
4053
  import { Collection as Collection11 } from "@fluxerjs/collection";
3960
- import { Routes as Routes31 } from "@fluxerjs/types";
4054
+ import { Routes as Routes32 } from "@fluxerjs/types";
3961
4055
  import { formatEmoji, getUnicodeFromShortcode, parseEmoji } from "@fluxerjs/util";
3962
4056
  async function assertEmojiInGuild(client, emojiId, guildId) {
3963
- const emojis = await client.rest.get(Routes31.guildEmojis(guildId));
4057
+ const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
3964
4058
  if (!emojis.some((e) => e.id === emojiId)) {
3965
4059
  throw new FluxerError("Custom emoji is from another server. Use an emoji from this server.", {
3966
4060
  code: ErrorCodes.EmojiNotInGuild
@@ -3986,7 +4080,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
3986
4080
  const unicodeFromShortcode = getUnicodeFromShortcode(parsed.name);
3987
4081
  if (unicodeFromShortcode) return unicodeFromShortcode;
3988
4082
  if (guildId) {
3989
- const emojis = await client.rest.get(Routes31.guildEmojis(guildId));
4083
+ const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
3990
4084
  const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
3991
4085
  if (found) return formatEmoji({ ...parsed, id: found.id, animated: found.animated });
3992
4086
  throw new FluxerError(
@@ -4003,28 +4097,28 @@ async function resolveClientEmoji(client, emoji, guildId) {
4003
4097
  return parsed.name;
4004
4098
  }
4005
4099
  async function fetchInstance(client) {
4006
- const raw = await client.rest.get(Routes31.instanceDiscovery(), { auth: false });
4100
+ const raw = await client.rest.get(Routes32.instanceDiscovery(), { auth: false });
4007
4101
  return parseInstanceDiscovery(raw);
4008
4102
  }
4009
4103
  function fetchGatewayInfo(client) {
4010
- return client.rest.get(Routes31.gatewayBot());
4104
+ return client.rest.get(Routes32.gatewayBot());
4011
4105
  }
4012
4106
  function fetchEmojiMetadata(client, emojiId) {
4013
- return client.rest.get(Routes31.emojiMetadata(emojiId), { auth: true });
4107
+ return client.rest.get(Routes32.emojiMetadata(emojiId), { auth: true });
4014
4108
  }
4015
4109
  function fetchStickerMetadata(client, stickerId) {
4016
- return client.rest.get(Routes31.stickerMetadata(stickerId), { auth: true });
4110
+ return client.rest.get(Routes32.stickerMetadata(stickerId), { auth: true });
4017
4111
  }
4018
4112
  function fetchApplication(client) {
4019
- return client.rest.get(Routes31.applicationsMe(), { auth: true });
4113
+ return client.rest.get(Routes32.applicationsMe(), { auth: true });
4020
4114
  }
4021
4115
  async function fetchOAuthApplications(client) {
4022
- const data = await client.rest.get(Routes31.oauth2ApplicationsMe(), { auth: true });
4116
+ const data = await client.rest.get(Routes32.oauth2ApplicationsMe(), { auth: true });
4023
4117
  return Array.isArray(data) ? data : data.applications ?? [];
4024
4118
  }
4025
4119
  function checkUsernameTag(client, username, discriminator) {
4026
4120
  const params = new URLSearchParams({ username, discriminator });
4027
- return client.rest.get(`${Routes31.checkUsernameTag()}?${params}`, { auth: true });
4121
+ return client.rest.get(`${Routes32.checkUsernameTag()}?${params}`, { auth: true });
4028
4122
  }
4029
4123
  function assertChannelIdBatch(name, channelIds) {
4030
4124
  if (channelIds.length < 1 || channelIds.length > 100) {
@@ -4035,14 +4129,14 @@ function assertChannelIdBatch(name, channelIds) {
4035
4129
  }
4036
4130
  function preloadMessages(client, channelIds) {
4037
4131
  assertChannelIdBatch("preloadMessages", channelIds);
4038
- return client.rest.post(Routes31.preloadMessages(), {
4132
+ return client.rest.post(Routes32.preloadMessages(), {
4039
4133
  body: { channels: channelIds },
4040
4134
  auth: true
4041
4135
  });
4042
4136
  }
4043
4137
  function preloadMessagesAlt(client, channelIds) {
4044
4138
  assertChannelIdBatch("preloadMessagesAlt", channelIds);
4045
- return client.rest.post(Routes31.preloadMessagesAlt(), {
4139
+ return client.rest.post(Routes32.preloadMessagesAlt(), {
4046
4140
  body: { channels: channelIds },
4047
4141
  auth: true
4048
4142
  });
@@ -4050,7 +4144,7 @@ function preloadMessagesAlt(client, channelIds) {
4050
4144
  async function bulkFetchMessages(client, requests, options = {}) {
4051
4145
  validateBulkMessageFetchRequests(requests);
4052
4146
  const wire = toBulkFetchWire(requests);
4053
- const data = await client.rest.post(Routes31.channelsMessagesBulk(), {
4147
+ const data = await client.rest.post(Routes32.channelsMessagesBulk(), {
4054
4148
  body: { requests: wire },
4055
4149
  auth: true
4056
4150
  });
@@ -4137,62 +4231,6 @@ function buildRegistry(...maps) {
4137
4231
  return registry;
4138
4232
  }
4139
4233
 
4140
- // src/structures/MessageReaction.ts
4141
- import { Routes as Routes32 } from "@fluxerjs/types";
4142
- import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
4143
- var MessageReaction = class extends Base {
4144
- client;
4145
- messageId;
4146
- channelId;
4147
- guildId;
4148
- emoji;
4149
- /** Raw gateway payload for low-level access. */
4150
- _data;
4151
- constructor(client, data) {
4152
- super();
4153
- this.client = client;
4154
- this._data = data;
4155
- this.messageId = data.message_id;
4156
- this.channelId = data.channel_id;
4157
- this.guildId = data.guild_id ?? null;
4158
- this.emoji = {
4159
- name: data.emoji.name,
4160
- ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
4161
- ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
4162
- };
4163
- }
4164
- /** Emoji as a string: unicode or "name:id" for custom. */
4165
- get emojiIdentifier() {
4166
- return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
4167
- }
4168
- /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
4169
- get guild() {
4170
- return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
4171
- }
4172
- /**
4173
- * Fetch the message this reaction belongs to.
4174
- * Use when you need to edit, delete, or otherwise interact with the message.
4175
- * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
4176
- */
4177
- async fetchMessage() {
4178
- try {
4179
- const data = await this.client.rest.get(
4180
- Routes32.channelMessage(this.channelId, this.messageId)
4181
- );
4182
- return new Message(this.client, data);
4183
- } catch (err) {
4184
- if (err instanceof RateLimitError4) throw err;
4185
- if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
4186
- throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
4187
- code: ErrorCodes.MessageNotFound,
4188
- cause: err
4189
- });
4190
- }
4191
- throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
4192
- }
4193
- }
4194
- };
4195
-
4196
4234
  // src/client/eventHandlers/helpers.ts
4197
4235
  function unknownUser(id) {
4198
4236
  return { id, username: "Unknown", discriminator: "0" };
@@ -4363,13 +4401,50 @@ function normalizeGuildPayload(raw) {
4363
4401
  }
4364
4402
 
4365
4403
  // src/client/eventHandlers/guilds.ts
4404
+ function markGuildUnavailable(client, id) {
4405
+ const guild = client.guilds.get(id);
4406
+ if (!guild || guild.available === false) return;
4407
+ guild.available = false;
4408
+ client.emit(Events.GuildUnavailable, guild);
4409
+ }
4410
+ function refreshRecoveredGuild(guild, data) {
4411
+ guild._patch(data);
4412
+ if (data.roles !== void 0) {
4413
+ guild.roles.clear();
4414
+ for (const role of data.roles) {
4415
+ guild.roles.set(role.id, new Role(guild.client, role, guild.id));
4416
+ }
4417
+ }
4418
+ if (data.channels !== void 0) {
4419
+ const recoveredChannelIds = new Set(data.channels.map((channel) => channel.id));
4420
+ for (const channel of guild.channels.values()) {
4421
+ guild.client.channels.delete(channel.id);
4422
+ if (!recoveredChannelIds.has(channel.id)) guild.client._clearMessageCache(channel.id);
4423
+ }
4424
+ guild.channels.clear();
4425
+ }
4426
+ }
4366
4427
  var guildHandlers = {
4367
4428
  GUILD_CREATE(client, d) {
4429
+ const raw = d;
4430
+ if (raw.unavailable === true) {
4431
+ if (typeof raw.id === "string") {
4432
+ try {
4433
+ markGuildUnavailable(client, raw.id);
4434
+ } finally {
4435
+ client._onGuildReceived(raw.id);
4436
+ }
4437
+ }
4438
+ return;
4439
+ }
4368
4440
  const guildData = normalizeGuildPayload(d);
4369
4441
  if (!guildData) return;
4370
- const guild = new Guild(client, guildData);
4371
- client.guilds.set(guild.id, guild);
4372
4442
  const g = d;
4443
+ const existing = client.guilds.get(guildData.id);
4444
+ const recovered = existing?.available === false;
4445
+ const guild = recovered && existing ? existing : new Guild(client, guildData);
4446
+ if (recovered) refreshRecoveredGuild(guild, g);
4447
+ client.guilds.set(guild.id, guild);
4373
4448
  for (const ch of g.channels ?? []) {
4374
4449
  const channel = Channel.from(client, ch);
4375
4450
  if (channel) {
@@ -4378,7 +4453,8 @@ var guildHandlers = {
4378
4453
  }
4379
4454
  }
4380
4455
  for (const m of g.members ?? []) cacheMember2(client, guild, m);
4381
- client.emit(Events.GuildCreate, guild);
4456
+ if (recovered) guild.available = true;
4457
+ client.emit(recovered ? Events.GuildAvailable : Events.GuildCreate, guild);
4382
4458
  if (g.voice_states?.length) {
4383
4459
  client.emit(Events.VoiceStatesSync, { guildId: guild.id, voiceStates: g.voice_states });
4384
4460
  }
@@ -4399,11 +4475,19 @@ var guildHandlers = {
4399
4475
  client.emit(Events.GuildUpdate, updated, updated);
4400
4476
  },
4401
4477
  GUILD_DELETE(client, d) {
4402
- const { id } = d;
4403
- const guild = client.guilds.get(id);
4404
- if (!guild) return;
4405
- client.guilds.delete(id);
4406
- client.emit(Events.GuildDelete, guild);
4478
+ const { id, unavailable } = d;
4479
+ try {
4480
+ if (unavailable === true) {
4481
+ markGuildUnavailable(client, id);
4482
+ return;
4483
+ }
4484
+ const guild = client.guilds.get(id);
4485
+ if (!guild) return;
4486
+ client.guilds.delete(id);
4487
+ client.emit(Events.GuildDelete, guild);
4488
+ } finally {
4489
+ client._onGuildReceived(id);
4490
+ }
4407
4491
  }
4408
4492
  };
4409
4493
 
@@ -4825,7 +4909,12 @@ function emitClientError(client, err) {
4825
4909
  function shouldDeferGatewayDispatchUntilReady(client, payload) {
4826
4910
  if (client.options.waitForGuilds !== true || client.readyAt !== null) return false;
4827
4911
  if (payload.op !== 0 || !payload.t) return false;
4828
- return payload.t !== "GUILD_CREATE";
4912
+ if (payload.t === "GUILD_CREATE") return false;
4913
+ if (payload.t === "GUILD_DELETE") {
4914
+ const data = payload.d;
4915
+ if (typeof data?.id === "string" && client._pendingGuildIds?.has(data.id)) return false;
4916
+ }
4917
+ return true;
4829
4918
  }
4830
4919
  function handleGatewayDispatch(client, payload, deferred) {
4831
4920
  if (payload.op !== 0 || !payload.t) return Promise.resolve();