@fluxerjs/core 3.1.0 → 3.3.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/index.js CHANGED
@@ -21,9 +21,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  AllowedMentions: () => AllowedMentions,
24
+ AnnouncementChannel: () => AnnouncementChannel,
24
25
  AttachmentBuilder: () => import_builders5.AttachmentBuilder,
25
26
  AttachmentMeta: () => import_builders5.AttachmentMeta,
26
- AuditLogActionType: () => import_types40.AuditLogActionType,
27
+ AuditLogActionType: () => import_types46.AuditLogActionType,
27
28
  BETA_CLIENT_CLUSTER_WARNING: () => BETA_CLIENT_CLUSTER_WARNING,
28
29
  Base: () => Base,
29
30
  CDN_URL: () => CDN_URL,
@@ -31,12 +32,12 @@ __export(src_exports, {
31
32
  CategoryChannel: () => CategoryChannel,
32
33
  Channel: () => Channel,
33
34
  ChannelManager: () => ChannelManager,
34
- ChannelType: () => import_types40.ChannelType,
35
+ ChannelType: () => import_types46.ChannelType,
35
36
  Client: () => Client,
36
37
  ClientCluster: () => ClientCluster,
37
38
  ClientClusterEvents: () => ClientClusterEvents,
38
39
  ClientUser: () => ClientUser,
39
- ContentWarningLevel: () => import_types40.ContentWarningLevel,
40
+ ContentWarningLevel: () => import_types46.ContentWarningLevel,
40
41
  DEFAULT_CACHE_LIMITS: () => DEFAULT_CACHE_LIMITS,
41
42
  DEFAULT_INSTANCE_ENDPOINTS: () => DEFAULT_INSTANCE_ENDPOINTS,
42
43
  DMChannel: () => DMChannel,
@@ -44,7 +45,11 @@ __export(src_exports, {
44
45
  ErrorCodes: () => import_util3.ErrorCodes,
45
46
  Events: () => Events,
46
47
  FluxerError: () => import_util4.FluxerError,
47
- GatewayOpcodes: () => import_types40.GatewayOpcodes,
48
+ ForumChannel: () => ForumChannel,
49
+ ForumLayout: () => import_types46.ForumLayout,
50
+ ForumSortOrder: () => import_types46.ForumSortOrder,
51
+ ForumTagSetting: () => import_types46.ForumTagSetting,
52
+ GatewayOpcodes: () => import_types46.GatewayOpcodes,
48
53
  Guild: () => Guild,
49
54
  GuildBan: () => GuildBan,
50
55
  GuildChannel: () => GuildChannel,
@@ -52,45 +57,52 @@ __export(src_exports, {
52
57
  GuildManager: () => GuildManager,
53
58
  GuildMember: () => GuildMember,
54
59
  GuildMemberManager: () => GuildMemberManager,
55
- GuildMemberProfileFlags: () => import_types40.GuildMemberProfileFlags,
60
+ GuildMemberProfileFlags: () => import_types46.GuildMemberProfileFlags,
56
61
  GuildMemberRoleManager: () => GuildMemberRoleManager,
57
- GuildNSFWLevel: () => import_types40.GuildNSFWLevel,
58
- GuildOperations: () => import_types40.GuildOperations,
62
+ GuildNSFWLevel: () => import_types46.GuildNSFWLevel,
63
+ GuildOperations: () => import_types46.GuildOperations,
59
64
  GuildRoleManager: () => GuildRoleManager,
60
65
  GuildSticker: () => GuildSticker,
61
66
  INSTANCE_DISCOVERY_PATH: () => INSTANCE_DISCOVERY_PATH,
62
67
  Invite: () => Invite,
63
- InviteType: () => import_types40.InviteType,
68
+ InviteType: () => import_types46.InviteType,
64
69
  LinkChannel: () => LinkChannel,
70
+ MediaChannel: () => MediaChannel,
65
71
  Message: () => Message,
66
- MessageAttachmentFlags: () => import_types40.MessageAttachmentFlags,
72
+ MessageAttachmentFlags: () => import_types46.MessageAttachmentFlags,
67
73
  MessageCollector: () => MessageCollector,
68
- MessageFlags: () => import_types40.MessageFlags,
74
+ MessageFlags: () => import_types46.MessageFlags,
69
75
  MessageFlagsBitField: () => import_util27.MessageFlagsBitField,
70
76
  MessageFlagsBits: () => import_util27.MessageFlagsBits,
71
77
  MessageManager: () => MessageManager,
72
78
  MessagePayload: () => import_builders5.MessagePayload,
73
79
  MessageReaction: () => MessageReaction,
74
80
  MessageReactionManager: () => MessageReactionManager,
75
- MessageReferenceType: () => import_types40.MessageReferenceType,
81
+ MessageReferenceType: () => import_types46.MessageReferenceType,
76
82
  MessageSticker: () => MessageSticker,
77
- MessageType: () => import_types40.MessageType,
78
- OverwriteType: () => import_types40.OverwriteType,
83
+ MessageType: () => import_types46.MessageType,
84
+ OverwriteType: () => import_types46.OverwriteType,
79
85
  PartialGuildMember: () => PartialGuildMember,
80
86
  PartialMessage: () => PartialMessage,
81
87
  PermissionFlags: () => import_util27.PermissionFlags,
82
88
  PermissionOverwrite: () => PermissionOverwrite,
83
89
  PermissionOverwriteManager: () => PermissionOverwriteManager,
84
90
  PermissionsBitField: () => import_util27.PermissionsBitField,
85
- PublicUserFlags: () => import_types40.PublicUserFlags,
91
+ PublicUserFlags: () => import_types46.PublicUserFlags,
86
92
  ReactionCollector: () => ReactionCollector,
87
- RelationshipType: () => import_types40.RelationshipType,
93
+ RelationshipType: () => import_types46.RelationshipType,
88
94
  Role: () => Role,
89
- Routes: () => import_types40.Routes,
95
+ Routes: () => import_types46.Routes,
90
96
  STATIC_CDN_URL: () => STATIC_CDN_URL,
91
- SplashCardAlignment: () => import_types40.SplashCardAlignment,
92
- SystemChannelFlags: () => import_types40.SystemChannelFlags,
97
+ SplashCardAlignment: () => import_types46.SplashCardAlignment,
98
+ SystemChannelFlags: () => import_types46.SystemChannelFlags,
93
99
  TextChannel: () => TextChannel,
100
+ ThreadAutoArchiveDuration: () => import_types46.ThreadAutoArchiveDuration,
101
+ ThreadChannel: () => ThreadChannel,
102
+ ThreadManager: () => ThreadManager,
103
+ ThreadMember: () => ThreadMember,
104
+ ThreadMemberFlags: () => import_types46.ThreadMemberFlags,
105
+ ThreadMemberManager: () => ThreadMemberManager,
94
106
  User: () => User,
95
107
  UserFlagsBitField: () => import_util27.UserFlagsBitField,
96
108
  UserFlagsBits: () => import_util27.UserFlagsBits,
@@ -107,6 +119,7 @@ __export(src_exports, {
107
119
  cdnMemberBannerURL: () => cdnMemberBannerURL,
108
120
  cdnStickerURL: () => cdnStickerURL,
109
121
  createLogger: () => import_util27.createLogger,
122
+ fetchActiveThreads: () => fetchActiveThreads,
110
123
  instanceDiscoveryUrl: () => instanceDiscoveryUrl,
111
124
  inviteUrl: () => inviteUrl,
112
125
  normalizeApiOrigin: () => normalizeApiOrigin,
@@ -122,7 +135,7 @@ __export(src_exports, {
122
135
  });
123
136
  module.exports = __toCommonJS(src_exports);
124
137
  var import_builders5 = require("@fluxerjs/builders");
125
- var import_types40 = require("@fluxerjs/types");
138
+ var import_types46 = require("@fluxerjs/types");
126
139
  var import_util27 = require("@fluxerjs/util");
127
140
 
128
141
  // src/ClientCore/CacheController.ts
@@ -266,20 +279,20 @@ var CacheController = class {
266
279
 
267
280
  // src/ClientCore/ChannelManager.ts
268
281
  var import_collection8 = require("@fluxerjs/collection");
269
- var import_types22 = require("@fluxerjs/types");
282
+ var import_types28 = require("@fluxerjs/types");
270
283
 
271
284
  // src/Domain/Channel/Base.ts
272
- var import_types8 = require("@fluxerjs/types");
285
+ var import_types10 = require("@fluxerjs/types");
273
286
  var import_util8 = require("@fluxerjs/util");
274
287
 
275
288
  // src/ClientCore/MessageManager.ts
276
289
  var import_collection4 = require("@fluxerjs/collection");
277
- var import_types6 = require("@fluxerjs/types");
290
+ var import_types8 = require("@fluxerjs/types");
278
291
 
279
292
  // src/Domain/Message/Message.ts
280
293
  var import_builders3 = require("@fluxerjs/builders");
281
294
  var import_collection3 = require("@fluxerjs/collection");
282
- var import_types5 = require("@fluxerjs/types");
295
+ var import_types7 = require("@fluxerjs/types");
283
296
  var import_util6 = require("@fluxerjs/util");
284
297
 
285
298
  // src/ClientCore/SdkOptions/Attachments.ts
@@ -347,7 +360,130 @@ function toAttachmentUploadPlanResponse(data) {
347
360
  }
348
361
 
349
362
  // src/ClientCore/SdkOptions/Channels.ts
363
+ var import_types2 = require("@fluxerjs/types");
350
364
  var import_util = require("@fluxerjs/util");
365
+
366
+ // src/ClientCore/SdkOptions/Threads.ts
367
+ var import_types = require("@fluxerjs/types");
368
+ function toThreadEditBody(type, options) {
369
+ const body = {};
370
+ if (options.name !== void 0) body.name = options.name;
371
+ if (options.archived !== void 0) body.archived = options.archived;
372
+ if (options.autoArchiveDuration !== void 0) {
373
+ body.auto_archive_duration = options.autoArchiveDuration;
374
+ }
375
+ if (options.locked !== void 0) body.locked = options.locked;
376
+ if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
377
+ if (options.flags !== void 0) body.flags = options.flags;
378
+ if (options.appliedTags !== void 0 && type !== import_types.ChannelType.PrivateThread) {
379
+ body.applied_tags = options.appliedTags;
380
+ }
381
+ if (options.invitable !== void 0 && type === import_types.ChannelType.PrivateThread) {
382
+ body.invitable = options.invitable;
383
+ }
384
+ return body;
385
+ }
386
+ function toThreadParentEditBody(options) {
387
+ const body = {};
388
+ if (options.autoArchiveDuration !== void 0) {
389
+ body.default_auto_archive_duration = options.autoArchiveDuration;
390
+ }
391
+ if (options.rateLimitPerUser !== void 0) {
392
+ body.default_thread_rate_limit_per_user = options.rateLimitPerUser;
393
+ }
394
+ return body;
395
+ }
396
+ function toStartThreadBody(channelType, options) {
397
+ const type = options.type ?? (channelType === import_types.ChannelType.GuildAnnouncement ? import_types.ChannelType.AnnouncementThread : import_types.ChannelType.PublicThread);
398
+ const body = { name: options.name, type };
399
+ if (options.autoArchiveDuration !== void 0) {
400
+ body.auto_archive_duration = options.autoArchiveDuration;
401
+ }
402
+ if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
403
+ if (options.invitable !== void 0) body.invitable = options.invitable;
404
+ return body;
405
+ }
406
+ function toStartThreadFromMessageBody(options) {
407
+ const body = { name: options.name };
408
+ if (options.autoArchiveDuration !== void 0) {
409
+ body.auto_archive_duration = options.autoArchiveDuration;
410
+ }
411
+ if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
412
+ return body;
413
+ }
414
+ function toForumThreadMessage(body) {
415
+ const message = {};
416
+ if (body.content !== void 0) message.content = body.content;
417
+ if (body.embeds !== void 0) message.embeds = body.embeds;
418
+ if (body.attachments !== void 0) message.attachments = body.attachments;
419
+ if (body.allowed_mentions !== void 0) message.allowed_mentions = body.allowed_mentions;
420
+ if (body.flags !== void 0) message.flags = body.flags;
421
+ if (body.sticker_ids !== void 0) message.sticker_ids = body.sticker_ids;
422
+ return message;
423
+ }
424
+ function toForumTagBody(options) {
425
+ const body = { name: options.name };
426
+ if ("id" in options && options.id !== void 0) body.id = options.id;
427
+ if (options.moderated !== void 0) body.moderated = options.moderated;
428
+ if (options.emojiId !== void 0) body.emoji_id = options.emojiId;
429
+ if (options.emojiName !== void 0) body.emoji_name = options.emojiName;
430
+ return body;
431
+ }
432
+ function forumParentWire(options, includeLayout) {
433
+ const body = {};
434
+ if (options.availableTags !== void 0) {
435
+ body.available_tags = options.availableTags.map((tag) => toForumTagBody(tag));
436
+ }
437
+ if (options.defaultReactionEmoji !== void 0) {
438
+ body.default_reaction_emoji = options.defaultReactionEmoji === null ? null : reactionEmojiWire(options.defaultReactionEmoji);
439
+ }
440
+ if (options.defaultSortOrder !== void 0) body.default_sort_order = options.defaultSortOrder;
441
+ if (options.defaultTagSetting !== void 0) body.default_tag_setting = options.defaultTagSetting;
442
+ if (options.flags !== void 0) body.flags = options.flags;
443
+ if (options.defaultAutoArchiveDuration !== void 0) {
444
+ body.default_auto_archive_duration = options.defaultAutoArchiveDuration;
445
+ }
446
+ if (options.defaultThreadRateLimitPerUser !== void 0) {
447
+ body.default_thread_rate_limit_per_user = options.defaultThreadRateLimitPerUser;
448
+ }
449
+ if (includeLayout && options.defaultForumLayout !== void 0) {
450
+ body.default_forum_layout = options.defaultForumLayout;
451
+ }
452
+ return body;
453
+ }
454
+ function reactionEmojiWire(emoji) {
455
+ const body = {};
456
+ if (emoji.emojiId !== void 0) body.emoji_id = emoji.emojiId;
457
+ if (emoji.emojiName !== void 0) body.emoji_name = emoji.emojiName;
458
+ return body;
459
+ }
460
+ function toThreadMemberSettingsBody(options) {
461
+ const body = {};
462
+ if (options.flags !== void 0) body.flags = options.flags;
463
+ if (options.muted !== void 0) body.muted = options.muted;
464
+ if (options.muteConfig !== void 0) {
465
+ body.mute_config = options.muteConfig === null ? null : {
466
+ ...options.muteConfig.endTime !== void 0 ? { end_time: options.muteConfig.endTime } : {},
467
+ selected_time_window: options.muteConfig.selectedTimeWindow
468
+ };
469
+ }
470
+ return body;
471
+ }
472
+ function withQuery(path, params) {
473
+ const query = new URLSearchParams();
474
+ for (const [key, value] of Object.entries(params)) {
475
+ if (value === void 0) continue;
476
+ if (Array.isArray(value)) {
477
+ for (const item of value) query.append(key, item);
478
+ continue;
479
+ }
480
+ query.set(key, String(value));
481
+ }
482
+ const text = query.toString();
483
+ return text ? `${path}?${text}` : path;
484
+ }
485
+
486
+ // src/ClientCore/SdkOptions/Channels.ts
351
487
  function toOverwriteWire(overwrite) {
352
488
  return {
353
489
  id: overwrite.id,
@@ -358,6 +494,7 @@ function toOverwriteWire(overwrite) {
358
494
  }
359
495
  function toChannelEditBody(options) {
360
496
  const body = {};
497
+ if (options.type !== void 0) body.type = options.type;
361
498
  if (options.name !== void 0) body.name = options.name;
362
499
  if (options.topic !== void 0) body.topic = options.topic;
363
500
  if (options.url !== void 0) body.url = options.url;
@@ -407,6 +544,16 @@ function toChannelCreateBody(options) {
407
544
  body.content_warning_text = options.contentWarningText;
408
545
  }
409
546
  if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
547
+ if (options.defaultAutoArchiveDuration !== void 0) {
548
+ body.default_auto_archive_duration = options.defaultAutoArchiveDuration;
549
+ }
550
+ if (options.defaultThreadRateLimitPerUser !== void 0) {
551
+ body.default_thread_rate_limit_per_user = options.defaultThreadRateLimitPerUser;
552
+ }
553
+ const forumParent = options.type === import_types2.ChannelType.GuildForum || options.type === import_types2.ChannelType.GuildMedia;
554
+ if (forumParent) {
555
+ Object.assign(body, forumParentWire(options, options.type === import_types2.ChannelType.GuildForum));
556
+ }
410
557
  return body;
411
558
  }
412
559
  function toChannelInviteBody(options) {
@@ -702,7 +849,7 @@ function auditReasonHeaders(reason) {
702
849
 
703
850
  // src/Helpers/MessageUtils/Body.ts
704
851
  var import_builders = require("@fluxerjs/builders");
705
- var import_types = require("@fluxerjs/types");
852
+ var import_types3 = require("@fluxerjs/types");
706
853
 
707
854
  // src/LibErrors/ErrorCodes.ts
708
855
  var import_util3 = require("@fluxerjs/util");
@@ -785,7 +932,7 @@ function normalizeSendFiles(files) {
785
932
  id: i,
786
933
  filename: file.filename,
787
934
  ...file.description != null ? { description: file.description } : {},
788
- ...file.spoiler ? { flags: import_types.MessageAttachmentFlags.IS_SPOILER } : {}
935
+ ...file.spoiler ? { flags: import_types3.MessageAttachmentFlags.IS_SPOILER } : {}
789
936
  };
790
937
  if (file.description != null || file.spoiler) anyBuilderMeta = true;
791
938
  metaFromBuilders.push(meta);
@@ -835,8 +982,8 @@ function toMessageReference(target, forceForward = false) {
835
982
  message_id: target.messageId
836
983
  };
837
984
  if (target.guildId) ref.guild_id = target.guildId;
838
- const type = forceForward ? import_types.MessageReferenceType.Forward : target.type ?? import_types.MessageReferenceType.Default;
839
- if (type !== import_types.MessageReferenceType.Default) ref.type = type;
985
+ const type = forceForward ? import_types3.MessageReferenceType.Forward : target.type ?? import_types3.MessageReferenceType.Default;
986
+ if (type !== import_types3.MessageReferenceType.Default) ref.type = type;
840
987
  if (target.attachmentIds?.length) ref.attachment_ids = target.attachmentIds;
841
988
  if (target.embedIndices?.length) ref.embed_indices = target.embedIndices;
842
989
  return ref;
@@ -932,7 +1079,7 @@ var import_node_events = require("events");
932
1079
  var import_collection = require("@fluxerjs/collection");
933
1080
 
934
1081
  // src/Domain/Message/MessageReaction.ts
935
- var import_types2 = require("@fluxerjs/types");
1082
+ var import_types4 = require("@fluxerjs/types");
936
1083
 
937
1084
  // src/Helpers/HttpErrors.ts
938
1085
  var import_rest = require("@fluxerjs/rest");
@@ -1049,7 +1196,7 @@ var MessageReaction = class _MessageReaction extends Base {
1049
1196
  if (cached) return cached;
1050
1197
  try {
1051
1198
  const data = await this.client.rest.get(
1052
- import_types2.Routes.channelMessage(this.channelId, this.messageId)
1199
+ import_types4.Routes.channelMessage(this.channelId, this.messageId)
1053
1200
  );
1054
1201
  return new Message(this.client, data);
1055
1202
  } catch (err) {
@@ -1098,6 +1245,14 @@ var Events = {
1098
1245
  ChannelCreate: "channelCreate",
1099
1246
  ChannelUpdate: "channelUpdate",
1100
1247
  ChannelDelete: "channelDelete",
1248
+ ThreadCreate: "threadCreate",
1249
+ ThreadUpdate: "threadUpdate",
1250
+ ThreadDelete: "threadDelete",
1251
+ ThreadListSync: "threadListSync",
1252
+ ThreadMemberUpdate: "threadMemberUpdate",
1253
+ ThreadMembersUpdate: "threadMembersUpdate",
1254
+ ThreadMemberListUpdate: "threadMemberListUpdate",
1255
+ ForumUnreads: "forumUnreads",
1101
1256
  ChannelPinsUpdate: "channelPinsUpdate",
1102
1257
  ChannelRecipientAdd: "channelRecipientAdd",
1103
1258
  ChannelRecipientRemove: "channelRecipientRemove",
@@ -1235,6 +1390,30 @@ var ReactionCollector = class _ReactionCollector extends import_node_events.Even
1235
1390
  }
1236
1391
  };
1237
1392
 
1393
+ // src/Domain/Channel/ThreadCache.ts
1394
+ function cacheThread(client, data) {
1395
+ const existing = client.channels.get(data.id);
1396
+ if (existing?.isThread() && existing.type === data.type) {
1397
+ existing._patch(data);
1398
+ placeThread(client, existing);
1399
+ return existing;
1400
+ }
1401
+ const created = Channel.from(client, data);
1402
+ if (!created.isThread()) {
1403
+ throw new import_util4.FluxerError(`Channel ${data.id} is not a thread`, {
1404
+ code: import_util3.ErrorCodes.InvalidChannelType
1405
+ });
1406
+ }
1407
+ placeThread(client, created);
1408
+ return created;
1409
+ }
1410
+ function placeThread(client, thread) {
1411
+ client.channels.set(thread.id, thread);
1412
+ if (!thread.guildId) return;
1413
+ const guild = client.guilds.get(thread.guildId);
1414
+ if (guild) guild.channels.set(thread.id, thread);
1415
+ }
1416
+
1238
1417
  // src/Domain/Message/Attachment.ts
1239
1418
  function toMessageAttachment(data) {
1240
1419
  return {
@@ -1513,27 +1692,27 @@ var MessageSticker = class extends Base {
1513
1692
  };
1514
1693
 
1515
1694
  // src/Domain/Message/Reactions.ts
1516
- var import_types3 = require("@fluxerjs/types");
1695
+ var import_types5 = require("@fluxerjs/types");
1517
1696
  async function emojiPath(message, emoji) {
1518
1697
  return message.client.resolveEmoji(emoji, message.guildId);
1519
1698
  }
1520
1699
  async function reactToMessage(message, emoji) {
1521
1700
  const wire = await emojiPath(message, emoji);
1522
1701
  await message.client.rest.put(
1523
- import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, wire)
1702
+ import_types5.Routes.channelMessageReactionMe(message.channelId, message.id, wire)
1524
1703
  );
1525
1704
  }
1526
1705
  async function removeMessageReaction(message, emoji, userId) {
1527
1706
  const e = await emojiPath(message, emoji);
1528
- const route = userId ? import_types3.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e);
1707
+ const route = userId ? import_types5.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types5.Routes.channelMessageReactionMe(message.channelId, message.id, e);
1529
1708
  await message.client.rest.delete(route);
1530
1709
  }
1531
1710
  async function removeAllMessageReactions(message) {
1532
- await message.client.rest.delete(import_types3.Routes.channelMessageReactions(message.channelId, message.id));
1711
+ await message.client.rest.delete(import_types5.Routes.channelMessageReactions(message.channelId, message.id));
1533
1712
  }
1534
1713
  async function removeMessageReactionEmoji(message, emoji) {
1535
1714
  const e = await emojiPath(message, emoji);
1536
- await message.client.rest.delete(import_types3.Routes.channelMessageReaction(message.channelId, message.id, e));
1715
+ await message.client.rest.delete(import_types5.Routes.channelMessageReaction(message.channelId, message.id, e));
1537
1716
  }
1538
1717
  async function fetchMessageReactionUsers(message, emoji, options) {
1539
1718
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -1544,7 +1723,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
1544
1723
  if (options?.limit != null) params.set("limit", String(options.limit));
1545
1724
  if (options?.after) params.set("after", options.after);
1546
1725
  const qs2 = params.toString();
1547
- const route = import_types3.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
1726
+ const route = import_types5.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
1548
1727
  const data = await message.client.rest.get(route);
1549
1728
  if (Array.isArray(data)) {
1550
1729
  return {
@@ -1563,7 +1742,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
1563
1742
 
1564
1743
  // src/Domain/Message/Send.ts
1565
1744
  var import_builders2 = require("@fluxerjs/builders");
1566
- var import_types4 = require("@fluxerjs/types");
1745
+ var import_types6 = require("@fluxerjs/types");
1567
1746
  function toReplyTarget(ref) {
1568
1747
  return {
1569
1748
  channelId: ref.channel_id,
@@ -1597,7 +1776,7 @@ function asReplyTarget(value) {
1597
1776
  }
1598
1777
  async function sendPrepared(message, payload) {
1599
1778
  const data = await message.client.rest.post(
1600
- import_types4.Routes.channelMessages(message.channelId),
1779
+ import_types6.Routes.channelMessages(message.channelId),
1601
1780
  payload
1602
1781
  );
1603
1782
  message.client._addMessageToCache(message.channelId, data);
@@ -1706,6 +1885,8 @@ var Message = class _Message extends Base {
1706
1885
  nonce;
1707
1886
  /** IDs of custom emojis in the message classified as explicit. */
1708
1887
  nsfwEmojis;
1888
+ /** Thread started from this message, when the payload included one. */
1889
+ thread;
1709
1890
  /**
1710
1891
  * Cached text-capable channel (guild text, guild voice, or DM), or null if uncached / not text-based.
1711
1892
  * Narrowed type has {@link Channel.send} and {@link Channel.delete}.
@@ -1759,7 +1940,7 @@ var Message = class _Message extends Base {
1759
1940
  this.pinned = data.pinned;
1760
1941
  this.attachments = new import_collection3.Collection();
1761
1942
  for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
1762
- this.type = data.type ?? import_types5.MessageType.Default;
1943
+ this.type = data.type ?? import_types7.MessageType.Default;
1763
1944
  this.flags = new import_util6.MessageFlagsBitField(BigInt(data.flags ?? 0));
1764
1945
  this.mentionEveryone = data.mention_everyone ?? false;
1765
1946
  this.tts = data.tts ?? false;
@@ -1781,6 +1962,7 @@ var Message = class _Message extends Base {
1781
1962
  this.mentionRoles = data.mention_roles ?? [];
1782
1963
  this.nonce = data.nonce ?? null;
1783
1964
  this.nsfwEmojis = data.nsfw_emojis ?? [];
1965
+ this.thread = data.thread ? cacheThread(client, data.thread) : null;
1784
1966
  }
1785
1967
  /**
1786
1968
  * Apply an API message payload in place (cache identity / MESSAGE_UPDATE).
@@ -1814,6 +1996,7 @@ var Message = class _Message extends Base {
1814
1996
  this.mentionRoles = data.mention_roles ?? [];
1815
1997
  this.nonce = data.nonce ?? null;
1816
1998
  this.nsfwEmojis = data.nsfw_emojis ?? [];
1999
+ if (data.thread) this.thread = cacheThread(this.client, data.thread);
1817
2000
  }
1818
2001
  /**
1819
2002
  * Send a standalone message in this channel (not a reply).
@@ -1874,7 +2057,7 @@ var Message = class _Message extends Base {
1874
2057
  if (options.attachments !== void 0) {
1875
2058
  body.attachments = toMessageAttachmentEditWire(options.attachments);
1876
2059
  }
1877
- const data = await this.client.rest.patch(import_types5.Routes.channelMessage(this.channelId, this.id), {
2060
+ const data = await this.client.rest.patch(import_types7.Routes.channelMessage(this.channelId, this.id), {
1878
2061
  body
1879
2062
  });
1880
2063
  const updated = new _Message(this.client, data);
@@ -1892,13 +2075,30 @@ var Message = class _Message extends Base {
1892
2075
  awaitReactions(options) {
1893
2076
  return ReactionCollector.awaitReactions(this.client, this.id, this.channelId, options);
1894
2077
  }
2078
+ /**
2079
+ * Start a thread from this message.
2080
+ * Fluxer chooses a public or announcement thread from the parent channel.
2081
+ */
2082
+ async startThread(options) {
2083
+ const data = await this.client.rest.post(
2084
+ import_types7.Routes.channelMessageThreads(this.channelId, this.id),
2085
+ {
2086
+ body: toStartThreadFromMessageBody(options),
2087
+ auth: true,
2088
+ ...auditReasonHeaders(options.reason)
2089
+ }
2090
+ );
2091
+ const thread = cacheThread(this.client, data);
2092
+ this.thread = thread;
2093
+ return thread;
2094
+ }
1895
2095
  /** Fetch the latest version of this message from the API. */
1896
2096
  async fetch() {
1897
2097
  return this.client.channels.fetchMessage(this.channelId, this.id);
1898
2098
  }
1899
2099
  /** Delete this message. */
1900
2100
  async delete(reason) {
1901
- await this.client.rest.delete(import_types5.Routes.channelMessage(this.channelId, this.id), {
2101
+ await this.client.rest.delete(import_types7.Routes.channelMessage(this.channelId, this.id), {
1902
2102
  ...auditReasonHeaders(reason)
1903
2103
  });
1904
2104
  this.client._removeMessageFromCache(this.channelId, this.id);
@@ -1906,19 +2106,19 @@ var Message = class _Message extends Base {
1906
2106
  /** Delete a specific attachment from this message. */
1907
2107
  async deleteAttachment(attachmentId) {
1908
2108
  await this.client.rest.delete(
1909
- import_types5.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
2109
+ import_types7.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
1910
2110
  { auth: true }
1911
2111
  );
1912
2112
  this.attachments.delete(attachmentId);
1913
2113
  }
1914
2114
  /** Pin this message in the channel. */
1915
2115
  async pin() {
1916
- await this.client.rest.put(import_types5.Routes.channelPinMessage(this.channelId, this.id));
2116
+ await this.client.rest.put(import_types7.Routes.channelPinMessage(this.channelId, this.id));
1917
2117
  this.pinned = true;
1918
2118
  }
1919
2119
  /** Unpin this message from the channel. */
1920
2120
  async unpin() {
1921
- await this.client.rest.delete(import_types5.Routes.channelPinMessage(this.channelId, this.id));
2121
+ await this.client.rest.delete(import_types7.Routes.channelPinMessage(this.channelId, this.id));
1922
2122
  this.pinned = false;
1923
2123
  }
1924
2124
  /** React to this message with an emoji. */
@@ -2071,7 +2271,7 @@ var MessageManager = class {
2071
2271
  async fetchOne(messageId) {
2072
2272
  try {
2073
2273
  const data = await this.client.rest.get(
2074
- import_types6.Routes.channelMessage(this.channelId, messageId)
2274
+ import_types8.Routes.channelMessage(this.channelId, messageId)
2075
2275
  );
2076
2276
  return this.wrap(data);
2077
2277
  } catch (err) {
@@ -2096,7 +2296,7 @@ var MessageManager = class {
2096
2296
  const value = options[key];
2097
2297
  if (value != null && value !== "") qs2.set(key, String(value));
2098
2298
  }
2099
- const base = import_types6.Routes.channelMessages(this.channelId);
2299
+ const base = import_types8.Routes.channelMessages(this.channelId);
2100
2300
  const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
2101
2301
  const collection = new import_collection4.Collection();
2102
2302
  for (const msg of data) collection.set(msg.id, this.wrap(msg));
@@ -2203,7 +2403,7 @@ var MessageCollector = class _MessageCollector extends import_node_events2.Event
2203
2403
  };
2204
2404
 
2205
2405
  // src/Domain/Channel/Attachments.ts
2206
- var import_types7 = require("@fluxerjs/types");
2406
+ var import_types9 = require("@fluxerjs/types");
2207
2407
  var BOT_ATTACHMENT_MAX_BYTES = 50 * 1024 * 1024;
2208
2408
  var ATTACHMENT_MULTIPART_THRESHOLD_BYTES = 10 * 1024 * 1024;
2209
2409
  function instanceLimitOverridesSnapshot(client) {
@@ -2248,7 +2448,7 @@ async function putBlob(url, body, contentType) {
2248
2448
  async function uploadAttachmentsForSend(client, channelId, files) {
2249
2449
  assertBotAttachmentLimits(client, files);
2250
2450
  const plan = await client.rest.post(
2251
- import_types7.Routes.channelAttachments(channelId),
2451
+ import_types9.Routes.channelAttachments(channelId),
2252
2452
  {
2253
2453
  body: {
2254
2454
  attachments: files.map((f) => ({
@@ -2294,7 +2494,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
2294
2494
  });
2295
2495
  }
2296
2496
  if (multipart.length) {
2297
- await client.rest.post(import_types7.Routes.channelAttachmentsComplete(channelId), {
2497
+ await client.rest.post(import_types9.Routes.channelAttachmentsComplete(channelId), {
2298
2498
  body: { uploads: multipart },
2299
2499
  auth: true
2300
2500
  });
@@ -2359,39 +2559,56 @@ var Channel = class extends Base {
2359
2559
  throw new Error("Channel.createDM not initialized");
2360
2560
  }
2361
2561
  /**
2362
- * Whether this channel type can carry messages (text, voice, DM, group DM, notes).
2562
+ * Whether this channel type can carry messages (text, announcement, voice, threads, DM, group DM, notes).
2563
+ * Forum and media channels contain threads and do not accept `send`.
2363
2564
  * Checks {@link ChannelType}, not whether `send` exists on the instance.
2364
2565
  */
2365
2566
  isTextBased() {
2366
- return this.type === import_types8.ChannelType.GuildText || this.type === import_types8.ChannelType.GuildVoice || this.type === import_types8.ChannelType.DM || this.type === import_types8.ChannelType.GroupDM || this.type === import_types8.ChannelType.DMPersonalNotes;
2567
+ return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread;
2367
2568
  }
2368
- /** Check if this is a guild channel (text, voice, category, or link). */
2569
+ /** Check if this is a guild channel, including threads, forums, and media channels. */
2369
2570
  isGuild() {
2370
- return this.type === import_types8.ChannelType.GuildText || this.type === import_types8.ChannelType.GuildVoice || this.type === import_types8.ChannelType.GuildCategory || this.type === import_types8.ChannelType.GuildLink;
2571
+ return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.GuildCategory || this.type === import_types10.ChannelType.GuildLink || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread || this.type === import_types10.ChannelType.GuildForum || this.type === import_types10.ChannelType.GuildMedia;
2572
+ }
2573
+ /** Check if this is a thread (public, private, or announcement). */
2574
+ isThread() {
2575
+ return this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread;
2576
+ }
2577
+ /** Check if this is a forum channel. */
2578
+ isForum() {
2579
+ return this.type === import_types10.ChannelType.GuildForum;
2580
+ }
2581
+ /** Check if this is a media channel. */
2582
+ isMedia() {
2583
+ return this.type === import_types10.ChannelType.GuildMedia;
2371
2584
  }
2372
2585
  /** Check if this is a guild text channel. */
2373
2586
  isText() {
2374
- return this.type === import_types8.ChannelType.GuildText;
2587
+ return this.type === import_types10.ChannelType.GuildText;
2588
+ }
2589
+ /** Check if this is a guild announcement channel. */
2590
+ isAnnouncement() {
2591
+ return this.type === import_types10.ChannelType.GuildAnnouncement;
2375
2592
  }
2376
2593
  /** Check if this is a category channel. */
2377
2594
  isCategory() {
2378
- return this.type === import_types8.ChannelType.GuildCategory;
2595
+ return this.type === import_types10.ChannelType.GuildCategory;
2379
2596
  }
2380
2597
  /** Check if this is a DM, group DM, or personal notes channel. */
2381
2598
  isDM() {
2382
- return this.type === import_types8.ChannelType.DM || this.type === import_types8.ChannelType.GroupDM || this.type === import_types8.ChannelType.DMPersonalNotes;
2599
+ return this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes;
2383
2600
  }
2384
2601
  /** Check if this is a personal notes channel. */
2385
2602
  isPersonalNotes() {
2386
- return this.type === import_types8.ChannelType.DMPersonalNotes;
2603
+ return this.type === import_types10.ChannelType.DMPersonalNotes;
2387
2604
  }
2388
2605
  /** Check if this is a voice channel. */
2389
2606
  isVoice() {
2390
- return this.type === import_types8.ChannelType.GuildVoice;
2607
+ return this.type === import_types10.ChannelType.GuildVoice;
2391
2608
  }
2392
2609
  /** Check if this is a link channel. */
2393
2610
  isLink() {
2394
- return this.type === import_types8.ChannelType.GuildLink;
2611
+ return this.type === import_types10.ChannelType.GuildLink;
2395
2612
  }
2396
2613
  /**
2397
2614
  * Delete recent messages or an explicit ID list.
@@ -2414,7 +2631,7 @@ var Channel = class extends Base {
2414
2631
  }
2415
2632
  if (ids.length === 0) return [];
2416
2633
  if (ids.length === 1) {
2417
- await this.client.rest.delete(import_types8.Routes.channelMessage(this.id, ids[0]), { auth: true });
2634
+ await this.client.rest.delete(import_types10.Routes.channelMessage(this.id, ids[0]), { auth: true });
2418
2635
  this.client._removeMessageFromCache(this.id, ids[0]);
2419
2636
  return ids;
2420
2637
  }
@@ -2423,7 +2640,7 @@ var Channel = class extends Base {
2423
2640
  code: import_util3.ErrorCodes.InvalidBulkDelete
2424
2641
  });
2425
2642
  }
2426
- await this.client.rest.post(import_types8.Routes.channelBulkDelete(this.id), {
2643
+ await this.client.rest.post(import_types10.Routes.channelBulkDelete(this.id), {
2427
2644
  body: { message_ids: ids },
2428
2645
  auth: true
2429
2646
  });
@@ -2433,7 +2650,7 @@ var Channel = class extends Base {
2433
2650
  /** Delete all messages sent by the bot in this channel. Sudo auto-passes for bots. */
2434
2651
  async bulkDeleteMyMessages(options) {
2435
2652
  const body = options ? toSudoBody(options) : void 0;
2436
- await this.client.rest.post(import_types8.Routes.channelBulkDeleteMine(this.id), {
2653
+ await this.client.rest.post(import_types10.Routes.channelBulkDeleteMine(this.id), {
2437
2654
  body: body && Object.keys(body).length ? body : void 0,
2438
2655
  auth: true
2439
2656
  });
@@ -2443,19 +2660,19 @@ var Channel = class extends Base {
2443
2660
  * Session-token helper; bots usually skip this.
2444
2661
  */
2445
2662
  async acknowledgePins() {
2446
- await this.client.rest.post(import_types8.Routes.channelPinsAck(this.id), { auth: true });
2663
+ await this.client.rest.post(import_types10.Routes.channelPinsAck(this.id), { auth: true });
2447
2664
  }
2448
2665
  /**
2449
2666
  * Clear the read state for this channel.
2450
2667
  * Session-token helper; bots usually skip this.
2451
2668
  */
2452
2669
  async clearReadState() {
2453
- await this.client.rest.delete(import_types8.Routes.channelMessagesAck(this.id), { auth: true });
2670
+ await this.client.rest.delete(import_types10.Routes.channelMessagesAck(this.id), { auth: true });
2454
2671
  }
2455
2672
  /** Request upload URLs for attachments before sending a message. */
2456
2673
  async requestAttachmentUploads(attachments) {
2457
2674
  const data = await this.client.rest.post(
2458
- import_types8.Routes.channelAttachments(this.id),
2675
+ import_types10.Routes.channelAttachments(this.id),
2459
2676
  {
2460
2677
  body: toAttachmentUploadPlanBody(attachments),
2461
2678
  auth: true
@@ -2466,7 +2683,7 @@ var Channel = class extends Base {
2466
2683
  /** Complete the attachment upload flow after uploading to the CDN. */
2467
2684
  async completeAttachmentUploads(uploads) {
2468
2685
  const data = await this.client.rest.post(
2469
- import_types8.Routes.channelAttachmentsComplete(this.id),
2686
+ import_types10.Routes.channelAttachmentsComplete(this.id),
2470
2687
  {
2471
2688
  body: toAttachmentUploadCompleteBody(uploads),
2472
2689
  auth: true
@@ -2482,7 +2699,7 @@ var Channel = class extends Base {
2482
2699
  }
2483
2700
  /** Trigger the typing indicator in this channel. */
2484
2701
  async sendTyping() {
2485
- await this.client.rest.post(import_types8.Routes.channelTyping(this.id), { auth: true });
2702
+ await this.client.rest.post(import_types10.Routes.channelTyping(this.id), { auth: true });
2486
2703
  }
2487
2704
  /**
2488
2705
  * Fetch available RTC regions for voice channels.
@@ -2490,7 +2707,7 @@ var Channel = class extends Base {
2490
2707
  * Bots should skip this and join voice with `@fluxerjs/voice` instead.
2491
2708
  */
2492
2709
  async fetchRtcRegions() {
2493
- const data = await this.client.rest.get(import_types8.Routes.channelRtcRegions(this.id), {
2710
+ const data = await this.client.rest.get(import_types10.Routes.channelRtcRegions(this.id), {
2494
2711
  auth: true
2495
2712
  });
2496
2713
  return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
@@ -2498,7 +2715,7 @@ var Channel = class extends Base {
2498
2715
  /** Fetch slowmode state for this channel. */
2499
2716
  async fetchSlowmode() {
2500
2717
  const data = await this.client.rest.get(
2501
- import_types8.Routes.channelSlowmode(this.id),
2718
+ import_types10.Routes.channelSlowmode(this.id),
2502
2719
  { auth: true }
2503
2720
  );
2504
2721
  return {
@@ -2545,7 +2762,7 @@ var Channel = class extends Base {
2545
2762
  const qs2 = params.toString();
2546
2763
  const { silent: _s, deleteMessages: _d, reason: _reason, ...sudo } = options ?? {};
2547
2764
  const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
2548
- await this.client.rest.delete(import_types8.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
2765
+ await this.client.rest.delete(import_types10.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
2549
2766
  body,
2550
2767
  auth: true,
2551
2768
  ...auditReasonHeaders(_reason)
@@ -2563,17 +2780,17 @@ var Channel = class extends Base {
2563
2780
  };
2564
2781
 
2565
2782
  // src/Domain/Channel/Dm.ts
2566
- var import_types10 = require("@fluxerjs/types");
2783
+ var import_types12 = require("@fluxerjs/types");
2567
2784
 
2568
2785
  // src/Domain/Channel/TextCapable.ts
2569
- var import_types9 = require("@fluxerjs/types");
2786
+ var import_types11 = require("@fluxerjs/types");
2570
2787
  async function fetchPinnedMessagesPageFor(client, channelId, options) {
2571
2788
  const params = new URLSearchParams();
2572
2789
  if (options?.limit != null) params.set("limit", String(options.limit));
2573
2790
  if (options?.before) params.set("before", options.before);
2574
2791
  const qs2 = params.toString();
2575
2792
  const data = await client.rest.get(
2576
- import_types9.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
2793
+ import_types11.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
2577
2794
  );
2578
2795
  const items = data.items ?? [];
2579
2796
  return {
@@ -2643,7 +2860,7 @@ var DMChannel = class extends TextCapable(Channel) {
2643
2860
  * Transferring ownership to a bot fails (`CannotTransferOwnershipToBotError`).
2644
2861
  */
2645
2862
  async edit(options) {
2646
- const data = await this.client.rest.patch(import_types10.Routes.channel(this.id), {
2863
+ const data = await this.client.rest.patch(import_types12.Routes.channel(this.id), {
2647
2864
  body: toGroupDmEditBody(options),
2648
2865
  auth: true
2649
2866
  });
@@ -2655,13 +2872,13 @@ var DMChannel = class extends TextCapable(Channel) {
2655
2872
  * Notes-only; bots usually skip this.
2656
2873
  */
2657
2874
  async purgeMessages() {
2658
- if (this.type !== import_types10.ChannelType.DMPersonalNotes) {
2875
+ if (this.type !== import_types12.ChannelType.DMPersonalNotes) {
2659
2876
  throw new import_util4.FluxerError("purgeMessages is only available on personal notes channels", {
2660
2877
  code: import_util3.ErrorCodes.InvalidChannelType
2661
2878
  });
2662
2879
  }
2663
2880
  const data = await this.client.rest.post(
2664
- import_types10.Routes.channelMessagesPurge(this.id),
2881
+ import_types12.Routes.channelMessagesPurge(this.id),
2665
2882
  { auth: true }
2666
2883
  );
2667
2884
  return data.deleted_count;
@@ -2671,39 +2888,42 @@ var DMChannel = class extends TextCapable(Channel) {
2671
2888
  * Session-token helper; bots usually skip this.
2672
2889
  */
2673
2890
  async pinInList() {
2674
- await this.client.rest.put(import_types10.Routes.userMeChannelPin(this.id), { auth: true });
2891
+ await this.client.rest.put(import_types12.Routes.userMeChannelPin(this.id), { auth: true });
2675
2892
  }
2676
2893
  /**
2677
2894
  * Unpin this DM channel from the DM list.
2678
2895
  * Session-token helper; bots usually skip this.
2679
2896
  */
2680
2897
  async unpinFromList() {
2681
- await this.client.rest.delete(import_types10.Routes.userMeChannelPin(this.id), { auth: true });
2898
+ await this.client.rest.delete(import_types12.Routes.userMeChannelPin(this.id), { auth: true });
2682
2899
  }
2683
2900
  /**
2684
2901
  * Add a user to this group DM.
2685
2902
  * Captcha-gated when captcha is enabled; bots are not exempt (`CaptchaRequiredError`).
2686
2903
  */
2687
2904
  async addRecipient(userId) {
2688
- await this.client.rest.put(import_types10.Routes.channelRecipient(this.id, userId), { auth: true });
2905
+ await this.client.rest.put(import_types12.Routes.channelRecipient(this.id, userId), { auth: true });
2689
2906
  const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
2690
2907
  if (user) this.recipients.push(user);
2691
2908
  }
2692
2909
  /** Remove a user from this group DM. */
2693
2910
  async removeRecipient(userId, options) {
2694
- const url = import_types10.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2911
+ const url = import_types12.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
2695
2912
  await this.client.rest.delete(url, { auth: true });
2696
2913
  const idx = this.recipients.findIndex((u) => u.id === userId);
2697
2914
  if (idx >= 0) this.recipients.splice(idx, 1);
2698
2915
  }
2699
2916
  };
2700
2917
 
2918
+ // src/Domain/Channel/Forum.ts
2919
+ var import_types19 = require("@fluxerjs/types");
2920
+
2701
2921
  // src/Domain/Channel/Guild.ts
2702
- var import_types14 = require("@fluxerjs/types");
2922
+ var import_types16 = require("@fluxerjs/types");
2703
2923
  var import_util13 = require("@fluxerjs/util");
2704
2924
 
2705
2925
  // src/Domain/Invite.ts
2706
- var import_types11 = require("@fluxerjs/types");
2926
+ var import_types13 = require("@fluxerjs/types");
2707
2927
 
2708
2928
  // src/Helpers/Instance.ts
2709
2929
  var import_util9 = require("@fluxerjs/util");
@@ -2952,11 +3172,11 @@ var Invite = class _Invite extends Base {
2952
3172
  this.client = client;
2953
3173
  this.code = data.code;
2954
3174
  this.type = data.type;
2955
- this.guildSnapshot = (0, import_types11.isGuildInvite)(data) ? toInviteGuild(data.guild) : null;
2956
- this.channelSnapshot = (0, import_types11.isGuildInvite)(data) || (0, import_types11.isGroupDmInvite)(data) ? toInviteChannel(data.channel) : null;
3175
+ this.guildSnapshot = (0, import_types13.isGuildInvite)(data) ? toInviteGuild(data.guild) : null;
3176
+ this.channelSnapshot = (0, import_types13.isGuildInvite)(data) || (0, import_types13.isGroupDmInvite)(data) ? toInviteChannel(data.channel) : null;
2957
3177
  this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
2958
3178
  this.memberCount = data.member_count ?? null;
2959
- this.presenceCount = (0, import_types11.isGuildInvite)(data) ? data.presence_count ?? null : null;
3179
+ this.presenceCount = (0, import_types13.isGuildInvite)(data) ? data.presence_count ?? null : null;
2960
3180
  this.expiresAt = parseOptionalDate(data.expires_at);
2961
3181
  this.temporary = data.temporary ?? null;
2962
3182
  this.createdAt = parseOptionalDate(data.created_at);
@@ -2965,10 +3185,10 @@ var Invite = class _Invite extends Base {
2965
3185
  this.maxAge = data.max_age ?? null;
2966
3186
  }
2967
3187
  isGuild() {
2968
- return this.type === import_types11.InviteType.Guild;
3188
+ return this.type === import_types13.InviteType.Guild;
2969
3189
  }
2970
3190
  isGroupDM() {
2971
- return this.type === import_types11.InviteType.GroupDM;
3191
+ return this.type === import_types13.InviteType.GroupDM;
2972
3192
  }
2973
3193
  /** Full invite URL (uses this client's instance invite base). */
2974
3194
  get url() {
@@ -2992,18 +3212,18 @@ var Invite = class _Invite extends Base {
2992
3212
  }
2993
3213
  /** Fetch invite metadata by code or URL (does not join). */
2994
3214
  static async fetch(client, codeOrUrl) {
2995
- const data = await client.rest.get(import_types11.Routes.invite(parseInviteCode(codeOrUrl)));
3215
+ const data = await client.rest.get(import_types13.Routes.invite(parseInviteCode(codeOrUrl)));
2996
3216
  return new _Invite(client, data);
2997
3217
  }
2998
3218
  /** Delete this invite. Requires Manage Guild or Create Instant Invite. */
2999
3219
  async delete() {
3000
- await this.client.rest.delete(import_types11.Routes.invite(this.code), { auth: true });
3220
+ await this.client.rest.delete(import_types13.Routes.invite(this.code), { auth: true });
3001
3221
  }
3002
3222
  };
3003
3223
 
3004
3224
  // src/Domain/Webhook.ts
3005
3225
  var import_builders4 = require("@fluxerjs/builders");
3006
- var import_types12 = require("@fluxerjs/types");
3226
+ var import_types14 = require("@fluxerjs/types");
3007
3227
  var import_util10 = require("@fluxerjs/util");
3008
3228
  var Webhook = class _Webhook extends Base {
3009
3229
  /** Parent client instance. */
@@ -3022,6 +3242,8 @@ var Webhook = class _Webhook extends Base {
3022
3242
  token;
3023
3243
  /** The user that created this webhook. */
3024
3244
  user;
3245
+ /** Incoming or channel-follower webhook. */
3246
+ type;
3025
3247
  constructor(client, data) {
3026
3248
  super();
3027
3249
  this.client = client;
@@ -3032,6 +3254,7 @@ var Webhook = class _Webhook extends Base {
3032
3254
  this.avatar = data.avatar ?? null;
3033
3255
  this.token = data.token ?? null;
3034
3256
  this.user = client.getOrCreateUser(data.user);
3257
+ this.type = data.type ?? import_types14.WebhookType.Incoming;
3035
3258
  }
3036
3259
  avatarURL(options) {
3037
3260
  return cdnAvatarURL(this.id, this.avatar, {
@@ -3050,10 +3273,10 @@ var Webhook = class _Webhook extends Base {
3050
3273
  /** Delete this webhook (token auth when available, otherwise bot auth). */
3051
3274
  async delete() {
3052
3275
  if (this.token) {
3053
- await this.client.rest.delete(import_types12.Routes.webhookExecute(this.id, this.token), { auth: false });
3276
+ await this.client.rest.delete(import_types14.Routes.webhookExecute(this.id, this.token), { auth: false });
3054
3277
  return;
3055
3278
  }
3056
- await this.client.rest.delete(import_types12.Routes.webhook(this.id), { auth: true });
3279
+ await this.client.rest.delete(import_types14.Routes.webhook(this.id), { auth: true });
3057
3280
  }
3058
3281
  /**
3059
3282
  * Edit name/avatar. With bot auth (no token), `channelId` may also be set.
@@ -3065,10 +3288,10 @@ var Webhook = class _Webhook extends Base {
3065
3288
  if (!this.token && options.channelId !== void 0) {
3066
3289
  body.channel_id = options.channelId;
3067
3290
  }
3068
- const data = this.token ? await this.client.rest.patch(import_types12.Routes.webhookExecute(this.id, this.token), {
3291
+ const data = this.token ? await this.client.rest.patch(import_types14.Routes.webhookExecute(this.id, this.token), {
3069
3292
  body,
3070
3293
  auth: false
3071
- }) : await this.client.rest.patch(import_types12.Routes.webhook(this.id), { body, auth: true });
3294
+ }) : await this.client.rest.patch(import_types14.Routes.webhook(this.id), { body, auth: true });
3072
3295
  this.name = data.name ?? this.name;
3073
3296
  this.avatar = data.avatar ?? null;
3074
3297
  if (!this.token) this.channelId = data.channel_id ?? this.channelId;
@@ -3089,7 +3312,7 @@ var Webhook = class _Webhook extends Base {
3089
3312
  if (overrides.avatarUrl !== void 0) {
3090
3313
  body.avatar_url = overrides.avatarUrl;
3091
3314
  }
3092
- const route = `${import_types12.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
3315
+ const route = `${import_types14.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
3093
3316
  const data = await this.client.rest.post(route, {
3094
3317
  body,
3095
3318
  ...files?.length ? { files } : {},
@@ -3130,7 +3353,7 @@ var Webhook = class _Webhook extends Base {
3130
3353
  }
3131
3354
  /** Fetch a webhook by ID (bot auth; no token). */
3132
3355
  static async fetch(client, webhookId) {
3133
- const data = await client.rest.get(import_types12.Routes.webhook(webhookId));
3356
+ const data = await client.rest.get(import_types14.Routes.webhook(webhookId));
3134
3357
  return new _Webhook(client, data);
3135
3358
  }
3136
3359
  /** Build a webhook from a stored id + token (e.g. webhook URL). */
@@ -3142,6 +3365,7 @@ var Webhook = class _Webhook extends Base {
3142
3365
  name: options?.name ?? "Webhook",
3143
3366
  avatar: null,
3144
3367
  token,
3368
+ type: import_types14.WebhookType.Incoming,
3145
3369
  user: {
3146
3370
  id: "",
3147
3371
  username: "webhook",
@@ -3163,13 +3387,13 @@ var Webhook = class _Webhook extends Base {
3163
3387
  return this.token;
3164
3388
  }
3165
3389
  messageRoute(messageId) {
3166
- return import_types12.Routes.webhookMessage(this.id, this.requireToken(), messageId);
3390
+ return import_types14.Routes.webhookMessage(this.id, this.requireToken(), messageId);
3167
3391
  }
3168
3392
  };
3169
3393
 
3170
3394
  // src/Domain/Channel/PermissionOverwriteManager.ts
3171
3395
  var import_collection6 = require("@fluxerjs/collection");
3172
- var import_types13 = require("@fluxerjs/types");
3396
+ var import_types15 = require("@fluxerjs/types");
3173
3397
  var import_util12 = require("@fluxerjs/util");
3174
3398
 
3175
3399
  // src/Domain/Channel/PermissionOverwrite.ts
@@ -3231,7 +3455,7 @@ var PermissionOverwriteManager = class {
3231
3455
  async edit(overwriteId, options) {
3232
3456
  const allow = options.allow !== void 0 ? (0, import_util12.resolvePermissionsToBitfield)(options.allow) : "0";
3233
3457
  const deny = options.deny !== void 0 ? (0, import_util12.resolvePermissionsToBitfield)(options.deny) : "0";
3234
- await this.channel.client.rest.put(import_types13.Routes.channelPermission(this.channel.id, overwriteId), {
3458
+ await this.channel.client.rest.put(import_types15.Routes.channelPermission(this.channel.id, overwriteId), {
3235
3459
  body: { type: options.type, allow, deny },
3236
3460
  auth: true
3237
3461
  });
@@ -3247,7 +3471,7 @@ var PermissionOverwriteManager = class {
3247
3471
  }
3248
3472
  /** Delete a permission overwrite. */
3249
3473
  async delete(overwriteId) {
3250
- await this.channel.client.rest.delete(import_types13.Routes.channelPermission(this.channel.id, overwriteId), {
3474
+ await this.channel.client.rest.delete(import_types15.Routes.channelPermission(this.channel.id, overwriteId), {
3251
3475
  auth: true
3252
3476
  });
3253
3477
  this._cache.delete(overwriteId);
@@ -3261,6 +3485,23 @@ var PermissionOverwriteManager = class {
3261
3485
  }
3262
3486
  };
3263
3487
 
3488
+ // src/Domain/Channel/ThreadBind.ts
3489
+ var factory;
3490
+ var managers = /* @__PURE__ */ new WeakMap();
3491
+ function bindThreadManager(next) {
3492
+ factory = next;
3493
+ }
3494
+ function threadManagerFor(channel) {
3495
+ const existing = managers.get(channel);
3496
+ if (existing) return existing;
3497
+ if (!factory) {
3498
+ throw new Error("ThreadManager is not initialized");
3499
+ }
3500
+ const created = factory(channel);
3501
+ managers.set(channel, created);
3502
+ return created;
3503
+ }
3504
+
3264
3505
  // src/Domain/Channel/Guild.ts
3265
3506
  var GuildChannel = class extends Channel {
3266
3507
  /** Guild ID this channel belongs to, or null if missing from the payload. */
@@ -3298,7 +3539,7 @@ var GuildChannel = class extends Channel {
3298
3539
  }
3299
3540
  /** Create a webhook for this channel. Requires Manage Webhooks. */
3300
3541
  async createWebhook(options) {
3301
- const data = await this.client.rest.post(import_types14.Routes.channelWebhooks(this.id), {
3542
+ const data = await this.client.rest.post(import_types16.Routes.channelWebhooks(this.id), {
3302
3543
  body: options,
3303
3544
  auth: true
3304
3545
  });
@@ -3306,13 +3547,13 @@ var GuildChannel = class extends Channel {
3306
3547
  }
3307
3548
  /** Fetch all webhooks in this channel. Requires Manage Webhooks. */
3308
3549
  async fetchWebhooks() {
3309
- const data = await this.client.rest.get(import_types14.Routes.channelWebhooks(this.id));
3550
+ const data = await this.client.rest.get(import_types16.Routes.channelWebhooks(this.id));
3310
3551
  return data.map((w) => new Webhook(this.client, w));
3311
3552
  }
3312
3553
  /** Create an invite for this channel. Requires Create Instant Invite. */
3313
3554
  async createInvite(options) {
3314
3555
  const body = options ? toChannelInviteBody(options) : {};
3315
- const data = await this.client.rest.post(import_types14.Routes.channelInvites(this.id), {
3556
+ const data = await this.client.rest.post(import_types16.Routes.channelInvites(this.id), {
3316
3557
  body: Object.keys(body).length ? body : void 0,
3317
3558
  auth: true
3318
3559
  });
@@ -3320,7 +3561,7 @@ var GuildChannel = class extends Channel {
3320
3561
  }
3321
3562
  /** Fetch all invites for this channel. Requires Manage Channels. */
3322
3563
  async fetchInvites() {
3323
- const data = await this.client.rest.get(import_types14.Routes.channelInvites(this.id));
3564
+ const data = await this.client.rest.get(import_types16.Routes.channelInvites(this.id));
3324
3565
  return data.map((i) => new Invite(this.client, i));
3325
3566
  }
3326
3567
  /** Check if the bot can send messages in this channel (cache-only; needs `members.me`). */
@@ -3350,7 +3591,7 @@ var GuildChannel = class extends Channel {
3350
3591
  }
3351
3592
  /** Edit this channel's settings. Requires Manage Channels. */
3352
3593
  async edit(options) {
3353
- const data = await this.client.rest.patch(import_types14.Routes.channel(this.id), {
3594
+ const data = await this.client.rest.patch(import_types16.Routes.channel(this.id), {
3354
3595
  body: toChannelEditBody(options),
3355
3596
  auth: true,
3356
3597
  ...auditReasonHeaders(options.reason)
@@ -3381,6 +3622,10 @@ var TextChannel = class extends TextCapable(GuildChannel) {
3381
3622
  contentWarningLevel;
3382
3623
  /** Custom content warning text. */
3383
3624
  contentWarningText;
3625
+ /** Default auto-archive duration in minutes for new threads. */
3626
+ defaultAutoArchiveDuration;
3627
+ /** Slowmode in seconds copied onto new threads. */
3628
+ defaultThreadRateLimitPerUser;
3384
3629
  constructor(client, data) {
3385
3630
  super(client, data);
3386
3631
  this.topic = data.topic ?? null;
@@ -3390,6 +3635,12 @@ var TextChannel = class extends TextCapable(GuildChannel) {
3390
3635
  this.lastMessageId = data.last_message_id ?? null;
3391
3636
  this.contentWarningLevel = data.content_warning_level ?? null;
3392
3637
  this.contentWarningText = data.content_warning_text ?? null;
3638
+ this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
3639
+ this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
3640
+ }
3641
+ /** Create, list, and search threads in this channel. */
3642
+ get threads() {
3643
+ return threadManagerFor(this);
3393
3644
  }
3394
3645
  /**
3395
3646
  * Set slowmode (seconds between messages). Pass `0` to disable.
@@ -3410,8 +3661,29 @@ var TextChannel = class extends TextCapable(GuildChannel) {
3410
3661
  if ("content_warning_text" in data) {
3411
3662
  this.contentWarningText = data.content_warning_text ?? null;
3412
3663
  }
3664
+ if ("default_auto_archive_duration" in data) {
3665
+ this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
3666
+ }
3667
+ if ("default_thread_rate_limit_per_user" in data) {
3668
+ this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
3669
+ }
3670
+ }
3671
+ /**
3672
+ * Set the auto-archive and slowmode defaults copied onto new threads.
3673
+ * Sends only those fields. The thread-parent update body does not accept a channel rename.
3674
+ */
3675
+ async editThreadDefaults(options) {
3676
+ const data = await this.client.rest.patch(import_types16.Routes.channel(this.id), {
3677
+ body: toThreadParentEditBody(options),
3678
+ auth: true,
3679
+ ...auditReasonHeaders(options.reason)
3680
+ });
3681
+ this._patch(data);
3682
+ return this;
3413
3683
  }
3414
3684
  };
3685
+ var AnnouncementChannel = class extends TextChannel {
3686
+ };
3415
3687
  var CategoryChannel = class extends GuildChannel {
3416
3688
  };
3417
3689
  var VoiceChannel = class extends TextCapable(GuildChannel) {
@@ -3490,25 +3762,522 @@ var LinkChannel = class extends GuildChannel {
3490
3762
  }
3491
3763
  };
3492
3764
 
3765
+ // src/Domain/Channel/ThreadManager.ts
3766
+ var import_types18 = require("@fluxerjs/types");
3767
+
3768
+ // src/Domain/Channel/ThreadChannel.ts
3769
+ var import_types17 = require("@fluxerjs/types");
3770
+ var ThreadMember = class {
3771
+ /** Thread ID. */
3772
+ id;
3773
+ /** User ID. */
3774
+ userId;
3775
+ /** When the user last joined the thread. */
3776
+ joinedAt;
3777
+ /** Thread member flags bitfield. */
3778
+ flags;
3779
+ /** Whether the current user has muted the thread. */
3780
+ muted;
3781
+ /** ISO-8601 timestamp when the mute expires, if set. */
3782
+ muteEndTime;
3783
+ /** Selected mute duration in seconds, if set. */
3784
+ muteWindow;
3785
+ constructor(data) {
3786
+ this.id = data.id ?? null;
3787
+ this.userId = data.user_id ?? data.member?.user?.id ?? null;
3788
+ this.joinedAt = new Date(data.join_timestamp);
3789
+ this.flags = data.flags;
3790
+ this.muted = data.muted ?? null;
3791
+ this.muteEndTime = data.mute_config?.end_time ?? null;
3792
+ this.muteWindow = data.mute_config?.selected_time_window ?? null;
3793
+ }
3794
+ };
3795
+ function threadEditFields(options) {
3796
+ const source = options;
3797
+ return {
3798
+ name: typeof source.name === "string" ? source.name : void 0,
3799
+ archived: source.archived,
3800
+ autoArchiveDuration: source.autoArchiveDuration,
3801
+ locked: source.locked,
3802
+ rateLimitPerUser: source.rateLimitPerUser,
3803
+ flags: source.flags,
3804
+ appliedTags: source.appliedTags,
3805
+ invitable: source.invitable,
3806
+ reason: source.reason
3807
+ };
3808
+ }
3809
+ function readMetadata(data) {
3810
+ return {
3811
+ archived: data?.archived ?? false,
3812
+ autoArchiveDuration: data?.auto_archive_duration ?? 0,
3813
+ archiveTimestamp: data?.archive_timestamp ?? null,
3814
+ locked: data?.locked ?? false,
3815
+ invitable: data?.invitable ?? null
3816
+ };
3817
+ }
3818
+ var ThreadChannel = class extends TextCapable(GuildChannel) {
3819
+ /** User who created the thread. */
3820
+ ownerId;
3821
+ /** Whether the thread is archived. */
3822
+ archived;
3823
+ /** Minutes of inactivity before the thread archives. */
3824
+ autoArchiveDuration;
3825
+ /** ISO-8601 timestamp when the archive status last changed. */
3826
+ archiveTimestamp;
3827
+ /** Whether only moderators can unarchive the thread. */
3828
+ locked;
3829
+ /** Whether non-moderators can add other non-moderators. Private threads only. */
3830
+ invitable;
3831
+ /** Slowmode in seconds. */
3832
+ rateLimitPerUser;
3833
+ /** ID of the last message sent in this thread. */
3834
+ lastMessageId;
3835
+ /** Messages in the thread, excluding the starter and deleted messages. */
3836
+ messageCount;
3837
+ /** Messages ever sent in the thread. This count is never decremented. */
3838
+ totalMessageSent;
3839
+ /** Approximate member count, capped at 50. */
3840
+ memberCount;
3841
+ /** Tag IDs applied to a forum or media post. */
3842
+ appliedTags;
3843
+ /** Channel flags bitfield. */
3844
+ flags;
3845
+ /** The current user's membership, when the payload included it. */
3846
+ member;
3847
+ /** Add, remove, and list members of this thread. */
3848
+ members;
3849
+ constructor(client, data) {
3850
+ super(client, data);
3851
+ const metadata = readMetadata(data.thread_metadata);
3852
+ this.ownerId = data.owner_id ?? null;
3853
+ this.archived = metadata.archived;
3854
+ this.autoArchiveDuration = metadata.autoArchiveDuration;
3855
+ this.archiveTimestamp = metadata.archiveTimestamp;
3856
+ this.locked = metadata.locked;
3857
+ this.invitable = metadata.invitable;
3858
+ this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
3859
+ this.lastMessageId = data.last_message_id ?? null;
3860
+ this.messageCount = data.message_count ?? 0;
3861
+ this.totalMessageSent = data.total_message_sent ?? 0;
3862
+ this.memberCount = data.member_count ?? 0;
3863
+ this.appliedTags = data.applied_tags ?? [];
3864
+ this.flags = data.flags ?? 0;
3865
+ this.member = data.member ? new ThreadMember(data.member) : null;
3866
+ this.members = new ThreadMemberManager(this);
3867
+ }
3868
+ /** @internal */
3869
+ _patch(data) {
3870
+ super._patch(data);
3871
+ if (data.owner_id !== void 0) this.ownerId = data.owner_id ?? null;
3872
+ if (data.thread_metadata) {
3873
+ const metadata = readMetadata(data.thread_metadata);
3874
+ this.archived = metadata.archived;
3875
+ this.autoArchiveDuration = metadata.autoArchiveDuration;
3876
+ this.archiveTimestamp = metadata.archiveTimestamp;
3877
+ this.locked = metadata.locked;
3878
+ this.invitable = metadata.invitable;
3879
+ }
3880
+ if ("rate_limit_per_user" in data && data.rate_limit_per_user !== void 0) {
3881
+ this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
3882
+ }
3883
+ if ("last_message_id" in data) this.lastMessageId = data.last_message_id ?? null;
3884
+ if (data.message_count !== void 0) this.messageCount = data.message_count;
3885
+ if (data.total_message_sent !== void 0) this.totalMessageSent = data.total_message_sent;
3886
+ if (data.member_count !== void 0) this.memberCount = data.member_count;
3887
+ if (data.applied_tags !== void 0) this.appliedTags = data.applied_tags ?? [];
3888
+ if (data.flags !== void 0) this.flags = data.flags;
3889
+ if (data.member !== void 0) this.member = data.member ? new ThreadMember(data.member) : null;
3890
+ }
3891
+ /**
3892
+ * Edit this thread. Requires Manage Threads on public threads, or ownership on private ones.
3893
+ * `appliedTags` is sent for public and announcement threads. `invitable` is sent for private threads.
3894
+ */
3895
+ async edit(options) {
3896
+ const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
3897
+ body: toThreadEditBody(this.type, threadEditFields(options)),
3898
+ auth: true,
3899
+ ...auditReasonHeaders(options.reason)
3900
+ });
3901
+ this._patch(data);
3902
+ return this;
3903
+ }
3904
+ /** Archive or unarchive this thread. */
3905
+ async setArchived(archived, reason) {
3906
+ return this.edit({ archived, reason });
3907
+ }
3908
+ /** Lock or unlock this thread. Locked threads can only be unarchived by moderators. */
3909
+ async setLocked(locked, reason) {
3910
+ return this.edit({ locked, reason });
3911
+ }
3912
+ /** Join this thread. */
3913
+ async join() {
3914
+ await this.client.rest.put(import_types17.Routes.channelThreadMemberMe(this.id), { auth: true });
3915
+ }
3916
+ /** Leave this thread. */
3917
+ async leave() {
3918
+ await this.client.rest.delete(import_types17.Routes.channelThreadMemberMe(this.id), { auth: true });
3919
+ }
3920
+ /** Update the current user's notification settings for this thread. */
3921
+ async editSelf(options) {
3922
+ const data = await this.client.rest.patch(
3923
+ import_types17.Routes.channelThreadMemberMeSettings(this.id),
3924
+ { body: toThreadMemberSettingsBody(options), auth: true }
3925
+ );
3926
+ this.member = data ? new ThreadMember(data) : null;
3927
+ return this.member;
3928
+ }
3929
+ };
3930
+ var ThreadMemberManager = class {
3931
+ constructor(thread) {
3932
+ this.thread = thread;
3933
+ }
3934
+ /** List members of this thread. */
3935
+ async fetch(options) {
3936
+ const data = await this.thread.client.rest.get(
3937
+ withQuery(import_types17.Routes.channelThreadMembers(this.thread.id), {
3938
+ with_member: options?.withMember === void 0 ? void 0 : String(options.withMember),
3939
+ after: options?.after,
3940
+ limit: options?.limit
3941
+ })
3942
+ );
3943
+ return data.map((member) => new ThreadMember(member));
3944
+ }
3945
+ /** Fetch one member of this thread. */
3946
+ async fetchOne(userId, options) {
3947
+ const data = await this.thread.client.rest.get(
3948
+ withQuery(import_types17.Routes.channelThreadMember(this.thread.id, userId), {
3949
+ with_member: options?.withMember === void 0 ? void 0 : String(options.withMember)
3950
+ })
3951
+ );
3952
+ return new ThreadMember(data);
3953
+ }
3954
+ /** Add a user to this thread. Private threads only, unless the caller can manage the parent. */
3955
+ async add(userId) {
3956
+ await this.thread.client.rest.put(import_types17.Routes.channelThreadMember(this.thread.id, userId), {
3957
+ auth: true
3958
+ });
3959
+ }
3960
+ /** Remove a user from this thread. */
3961
+ async remove(userId) {
3962
+ await this.thread.client.rest.delete(import_types17.Routes.channelThreadMember(this.thread.id, userId), {
3963
+ auth: true
3964
+ });
3965
+ }
3966
+ };
3967
+ function isThreadType(type) {
3968
+ return type === import_types17.ChannelType.AnnouncementThread || type === import_types17.ChannelType.PublicThread || type === import_types17.ChannelType.PrivateThread;
3969
+ }
3970
+
3971
+ // src/Domain/Channel/ThreadManager.ts
3972
+ var ThreadManager = class {
3973
+ constructor(channel) {
3974
+ this.channel = channel;
3975
+ }
3976
+ /**
3977
+ * Start a thread in a text or announcement channel.
3978
+ * Forum and media channels must use {@link createPost}.
3979
+ */
3980
+ async create(options) {
3981
+ if (this.channel.type === import_types18.ChannelType.GuildForum || this.channel.type === import_types18.ChannelType.GuildMedia) {
3982
+ throw new import_util4.FluxerError("Forum and media channels start posts with createPost", {
3983
+ code: import_util3.ErrorCodes.InvalidChannelType
3984
+ });
3985
+ }
3986
+ const data = await this.channel.client.rest.post(
3987
+ import_types18.Routes.channelThreads(this.channel.id),
3988
+ {
3989
+ body: toStartThreadBody(this.channel.type, options),
3990
+ auth: true,
3991
+ ...auditReasonHeaders(options.reason)
3992
+ }
3993
+ );
3994
+ return cacheThread(this.channel.client, data);
3995
+ }
3996
+ /**
3997
+ * Start a post in a forum or media channel.
3998
+ * The post is a public thread. `message` is its first message.
3999
+ */
4000
+ async createPost(options) {
4001
+ if (this.channel.type !== import_types18.ChannelType.GuildForum && this.channel.type !== import_types18.ChannelType.GuildMedia) {
4002
+ throw new import_util4.FluxerError("createPost is for forum and media channels", {
4003
+ code: import_util3.ErrorCodes.InvalidChannelType
4004
+ });
4005
+ }
4006
+ const prepared = await prepareMessagePostPayload(options.message, {
4007
+ defaultAllowedMentions: this.channel.client.options.defaultAllowedMentions
4008
+ });
4009
+ const body = {
4010
+ name: options.name,
4011
+ type: import_types18.ChannelType.PublicThread,
4012
+ message: toForumThreadMessage(prepared.body)
4013
+ };
4014
+ if (options.autoArchiveDuration !== void 0) {
4015
+ body.auto_archive_duration = options.autoArchiveDuration;
4016
+ }
4017
+ if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
4018
+ if (options.appliedTags !== void 0) body.applied_tags = options.appliedTags;
4019
+ const data = await this.channel.client.rest.post(
4020
+ import_types18.Routes.channelThreads(this.channel.id),
4021
+ {
4022
+ body,
4023
+ files: prepared.files,
4024
+ auth: true,
4025
+ ...auditReasonHeaders(options.reason)
4026
+ }
4027
+ );
4028
+ const thread = cacheThread(this.channel.client, data);
4029
+ if (data.message) {
4030
+ this.channel.client._addMessageToCache(data.message.channel_id, data.message);
4031
+ }
4032
+ return thread;
4033
+ }
4034
+ /**
4035
+ * List archived threads in this channel.
4036
+ * `before` is an ISO-8601 archive timestamp.
4037
+ */
4038
+ async fetchArchived(options) {
4039
+ const path = options.type === "private" ? import_types18.Routes.channelThreadsArchivedPrivate(this.channel.id) : import_types18.Routes.channelThreadsArchivedPublic(this.channel.id);
4040
+ const data = await this.channel.client.rest.get(
4041
+ withQuery(path, { before: options.before, limit: options.limit })
4042
+ );
4043
+ return fetchedThreadsFrom(this.channel.client, data);
4044
+ }
4045
+ /**
4046
+ * List private archived threads in this channel that the current user has joined.
4047
+ * `before` is a thread snowflake.
4048
+ */
4049
+ async fetchJoinedPrivateArchived(options) {
4050
+ const data = await this.channel.client.rest.get(
4051
+ withQuery(import_types18.Routes.channelJoinedArchivedPrivateThreads(this.channel.id), {
4052
+ before: options?.before,
4053
+ limit: options?.limit
4054
+ })
4055
+ );
4056
+ return fetchedThreadsFrom(this.channel.client, data);
4057
+ }
4058
+ /**
4059
+ * Search threads in this channel.
4060
+ * Returns `{ indexing: true }` while the search index is still building.
4061
+ */
4062
+ async search(options) {
4063
+ const data = await this.channel.client.rest.get(
4064
+ withQuery(import_types18.Routes.channelThreadSearch(this.channel.id), {
4065
+ name: options?.name,
4066
+ tag: options?.tag,
4067
+ tag_setting: options?.tagSetting,
4068
+ archived: options?.archived === void 0 ? void 0 : String(options.archived),
4069
+ sort_by: options?.sortBy,
4070
+ sort_order: options?.sortOrder,
4071
+ limit: options?.limit,
4072
+ offset: options?.offset,
4073
+ max_id: options?.maxId,
4074
+ min_id: options?.minId
4075
+ })
4076
+ );
4077
+ if (isSearchNotReady(data)) {
4078
+ return { indexing: true, retryAfter: data.retry_after, message: data.message };
4079
+ }
4080
+ const page = fetchedThreadsFrom(this.channel.client, data);
4081
+ return {
4082
+ ...page,
4083
+ hasMore: data.has_more,
4084
+ totalResults: data.total_results,
4085
+ firstMessages: (data.first_messages ?? []).map(
4086
+ (message) => new Message(this.channel.client, message)
4087
+ )
4088
+ };
4089
+ }
4090
+ /** Set the auto-archive and slowmode defaults copied onto new threads. */
4091
+ async editDefaults(options) {
4092
+ return this.channel.client.rest.patch(import_types18.Routes.channel(this.channel.id), {
4093
+ body: toThreadParentEditBody(options),
4094
+ auth: true,
4095
+ ...auditReasonHeaders(options.reason)
4096
+ });
4097
+ }
4098
+ };
4099
+ function fetchedThreadsFrom(client, data) {
4100
+ return {
4101
+ threads: (data.threads ?? []).map((thread) => cacheThread(client, thread)),
4102
+ members: (data.members ?? []).map((member) => new ThreadMember(member)),
4103
+ hasMore: data.has_more ?? false
4104
+ };
4105
+ }
4106
+ function isSearchNotReady(data) {
4107
+ return "code" in data && data.code === "SEARCH_INDEX_NOT_READY";
4108
+ }
4109
+ async function fetchActiveThreads(client, guildId) {
4110
+ const data = await client.rest.get(import_types18.Routes.guildActiveThreads(guildId));
4111
+ return fetchedThreadsFrom(client, data);
4112
+ }
4113
+
4114
+ // src/Domain/Channel/Forum.ts
4115
+ function tagsFrom(data) {
4116
+ return data ?? [];
4117
+ }
4118
+ var ThreadOnlyChannel = class extends GuildChannel {
4119
+ /** Tags that can be applied to posts. */
4120
+ availableTags;
4121
+ /** Default reaction for new posts. */
4122
+ defaultReactionEmoji;
4123
+ /** Default sort order for posts. */
4124
+ defaultSortOrder;
4125
+ /** How posts are filtered when searching by several tags. */
4126
+ defaultTagSetting;
4127
+ /** Default auto-archive duration in minutes for new posts. */
4128
+ defaultAutoArchiveDuration;
4129
+ /** Slowmode in seconds copied onto new posts. */
4130
+ defaultThreadRateLimitPerUser;
4131
+ /** Channel flags bitfield. */
4132
+ flags;
4133
+ /** Create, list, and search posts in this channel. */
4134
+ threads;
4135
+ constructor(client, data) {
4136
+ super(client, data);
4137
+ this.availableTags = tagsFrom(data.available_tags);
4138
+ this.defaultReactionEmoji = data.default_reaction_emoji ?? null;
4139
+ this.defaultSortOrder = data.default_sort_order ?? null;
4140
+ this.defaultTagSetting = data.default_tag_setting ?? null;
4141
+ this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
4142
+ this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
4143
+ this.flags = data.flags ?? 0;
4144
+ this.threads = new ThreadManager(this);
4145
+ }
4146
+ /** @internal */
4147
+ _patch(data) {
4148
+ super._patch(data);
4149
+ if (data.available_tags !== void 0) this.availableTags = tagsFrom(data.available_tags);
4150
+ if ("default_reaction_emoji" in data) {
4151
+ this.defaultReactionEmoji = data.default_reaction_emoji ?? null;
4152
+ }
4153
+ if ("default_sort_order" in data) this.defaultSortOrder = data.default_sort_order ?? null;
4154
+ if ("default_tag_setting" in data) this.defaultTagSetting = data.default_tag_setting ?? null;
4155
+ if ("default_auto_archive_duration" in data) {
4156
+ this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
4157
+ }
4158
+ if ("default_thread_rate_limit_per_user" in data) {
4159
+ this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
4160
+ }
4161
+ if (data.flags !== void 0) this.flags = data.flags;
4162
+ }
4163
+ /**
4164
+ * Edit this channel.
4165
+ * Tag, sort, reaction, and thread-default fields are sent with the usual channel fields.
4166
+ * `defaultForumLayout` is sent only for forum channels.
4167
+ */
4168
+ async edit(options) {
4169
+ const data = await this.client.rest.patch(import_types19.Routes.channel(this.id), {
4170
+ body: {
4171
+ ...toChannelEditBody(options),
4172
+ ...forumParentWire(options, this.type === import_types19.ChannelType.GuildForum)
4173
+ },
4174
+ auth: true,
4175
+ ...auditReasonHeaders(options.reason)
4176
+ });
4177
+ this._patch(data);
4178
+ return this;
4179
+ }
4180
+ /** Replace the tags that can be applied to posts (max 20). */
4181
+ async setAvailableTags(tags, reason) {
4182
+ return this.edit({ availableTags: tags, reason });
4183
+ }
4184
+ /** Set or clear the default reaction on new posts. */
4185
+ async setDefaultReactionEmoji(emoji, reason) {
4186
+ return this.edit({ defaultReactionEmoji: emoji, reason });
4187
+ }
4188
+ /** Set or clear the default post sort order. */
4189
+ async setDefaultSortOrder(order, reason) {
4190
+ return this.edit({ defaultSortOrder: order, reason });
4191
+ }
4192
+ /** Set or clear how posts match when several tags are selected. */
4193
+ async setDefaultTagSetting(setting, reason) {
4194
+ return this.edit({ defaultTagSetting: setting, reason });
4195
+ }
4196
+ /** Set the auto-archive and slowmode defaults copied onto new posts. */
4197
+ async editThreadDefaults(options) {
4198
+ const data = await this.client.rest.patch(import_types19.Routes.channel(this.id), {
4199
+ body: toThreadParentEditBody(options),
4200
+ auth: true,
4201
+ ...auditReasonHeaders(options.reason)
4202
+ });
4203
+ this._patch(data);
4204
+ return this;
4205
+ }
4206
+ /** Create a tag. The response replaces {@link availableTags}. */
4207
+ async createTag(options) {
4208
+ const data = await this.client.rest.post(import_types19.Routes.channelTags(this.id), {
4209
+ body: toForumTagBody(options),
4210
+ auth: true,
4211
+ ...auditReasonHeaders(options.reason)
4212
+ });
4213
+ this._patch(data);
4214
+ return this;
4215
+ }
4216
+ /** Replace a tag. The response replaces {@link availableTags}. */
4217
+ async editTag(tagId, options) {
4218
+ const data = await this.client.rest.put(import_types19.Routes.channelTag(this.id, tagId), {
4219
+ body: toForumTagBody(options),
4220
+ auth: true,
4221
+ ...auditReasonHeaders(options.reason)
4222
+ });
4223
+ this._patch(data);
4224
+ return this;
4225
+ }
4226
+ /** Delete a tag. The response replaces {@link availableTags}. */
4227
+ async deleteTag(tagId, reason) {
4228
+ const data = await this.client.rest.delete(import_types19.Routes.channelTag(this.id, tagId), {
4229
+ auth: true,
4230
+ ...auditReasonHeaders(reason)
4231
+ });
4232
+ this._patch(data);
4233
+ return this;
4234
+ }
4235
+ };
4236
+ var ForumChannel = class extends ThreadOnlyChannel {
4237
+ /** Default layout for posts. */
4238
+ defaultForumLayout;
4239
+ /** Set or clear the default post layout. */
4240
+ async setDefaultForumLayout(layout, reason) {
4241
+ return this.edit({ defaultForumLayout: layout, reason });
4242
+ }
4243
+ constructor(client, data) {
4244
+ super(client, data);
4245
+ this.defaultForumLayout = data.default_forum_layout ?? null;
4246
+ }
4247
+ /** @internal */
4248
+ _patch(data) {
4249
+ super._patch(data);
4250
+ if ("default_forum_layout" in data) this.defaultForumLayout = data.default_forum_layout ?? null;
4251
+ }
4252
+ };
4253
+ var MediaChannel = class extends ThreadOnlyChannel {
4254
+ };
4255
+
3493
4256
  // src/Domain/Channel/Factory.ts
3494
- var import_types15 = require("@fluxerjs/types");
4257
+ var import_types20 = require("@fluxerjs/types");
3495
4258
  var GUILD_FACTORIES = {
3496
- [import_types15.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
3497
- [import_types15.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
3498
- [import_types15.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
3499
- [import_types15.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d)
4259
+ [import_types20.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
4260
+ [import_types20.ChannelType.GuildAnnouncement]: (c, d) => new AnnouncementChannel(c, d),
4261
+ [import_types20.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
4262
+ [import_types20.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
4263
+ [import_types20.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d),
4264
+ [import_types20.ChannelType.AnnouncementThread]: (c, d) => new ThreadChannel(c, d),
4265
+ [import_types20.ChannelType.PublicThread]: (c, d) => new ThreadChannel(c, d),
4266
+ [import_types20.ChannelType.PrivateThread]: (c, d) => new ThreadChannel(c, d),
4267
+ [import_types20.ChannelType.GuildForum]: (c, d) => new ForumChannel(c, d),
4268
+ [import_types20.ChannelType.GuildMedia]: (c, d) => new MediaChannel(c, d)
3500
4269
  };
3501
4270
  var DM_TYPES = /* @__PURE__ */ new Set([
3502
- import_types15.ChannelType.DM,
3503
- import_types15.ChannelType.GroupDM,
3504
- import_types15.ChannelType.DMPersonalNotes
4271
+ import_types20.ChannelType.DM,
4272
+ import_types20.ChannelType.GroupDM,
4273
+ import_types20.ChannelType.DMPersonalNotes
3505
4274
  ]);
3506
4275
  function createDM(client, data) {
3507
4276
  return new DMChannel(client, data);
3508
4277
  }
3509
4278
  function channelFrom(client, data) {
3510
- const factory = GUILD_FACTORIES[data.type ?? 0];
3511
- return factory ? factory(client, data) : new GuildChannel(client, data);
4279
+ const factory2 = GUILD_FACTORIES[data.type ?? 0];
4280
+ return factory2 ? factory2(client, data) : new GuildChannel(client, data);
3512
4281
  }
3513
4282
  function channelFromOrCreate(client, data) {
3514
4283
  return DM_TYPES.has(data.type ?? 0) ? createDM(client, data) : channelFrom(client, data);
@@ -3518,9 +4287,13 @@ function channelFromOrCreate(client, data) {
3518
4287
  Channel.from = channelFrom;
3519
4288
  Channel.fromOrCreate = channelFromOrCreate;
3520
4289
  Channel.createDM = createDM;
4290
+ bindThreadManager((channel) => new ThreadManager(channel));
4291
+
4292
+ // src/Domain/Guild/Cache.ts
4293
+ var import_types27 = require("@fluxerjs/types");
3521
4294
 
3522
4295
  // src/Domain/Guild/GuildEmoji.ts
3523
- var import_types16 = require("@fluxerjs/types");
4296
+ var import_types21 = require("@fluxerjs/types");
3524
4297
  var import_util14 = require("@fluxerjs/util");
3525
4298
  var GuildEmoji = class extends Base {
3526
4299
  client;
@@ -3569,7 +4342,7 @@ var GuildEmoji = class extends Base {
3569
4342
  }
3570
4343
  /** Delete this emoji. Requires Manage Emojis and Stickers permission. */
3571
4344
  async delete(reason) {
3572
- await this.client.rest.delete(import_types16.Routes.guildEmoji(this.guildId, this.id), {
4345
+ await this.client.rest.delete(import_types21.Routes.guildEmoji(this.guildId, this.id), {
3573
4346
  auth: true,
3574
4347
  ...auditReasonHeaders(reason)
3575
4348
  });
@@ -3582,7 +4355,7 @@ var GuildEmoji = class extends Base {
3582
4355
  */
3583
4356
  async edit(options) {
3584
4357
  const { reason, name } = options;
3585
- const data = await this.client.rest.patch(import_types16.Routes.guildEmoji(this.guildId, this.id), {
4358
+ const data = await this.client.rest.patch(import_types21.Routes.guildEmoji(this.guildId, this.id), {
3586
4359
  body: { name },
3587
4360
  auth: true,
3588
4361
  ...auditReasonHeaders(reason)
@@ -3593,11 +4366,11 @@ var GuildEmoji = class extends Base {
3593
4366
  };
3594
4367
 
3595
4368
  // src/Domain/Guild/GuildMember.ts
3596
- var import_types19 = require("@fluxerjs/types");
4369
+ var import_types24 = require("@fluxerjs/types");
3597
4370
  var import_util16 = require("@fluxerjs/util");
3598
4371
 
3599
4372
  // src/Helpers/Permissions.ts
3600
- var import_types17 = require("@fluxerjs/types");
4373
+ var import_types22 = require("@fluxerjs/types");
3601
4374
  var import_util15 = require("@fluxerjs/util");
3602
4375
  function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
3603
4376
  if (isOwner) return import_util15.ALL_PERMISSIONS_BIGINT;
@@ -3606,7 +4379,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
3606
4379
  }
3607
4380
  let perms = basePermissions;
3608
4381
  for (const overwrite of overwrites ?? []) {
3609
- const applies = overwrite.type === import_types17.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types17.OverwriteType.Member && overwrite.id === memberId;
4382
+ const applies = overwrite.type === import_types22.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types22.OverwriteType.Member && overwrite.id === memberId;
3610
4383
  if (!applies) continue;
3611
4384
  const allow = BigInt(overwrite.allow || "0");
3612
4385
  const deny = BigInt(overwrite.deny || "0");
@@ -3617,7 +4390,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
3617
4390
 
3618
4391
  // src/Domain/Guild/GuildMemberRoleManager.ts
3619
4392
  var import_collection7 = require("@fluxerjs/collection");
3620
- var import_types18 = require("@fluxerjs/types");
4393
+ var import_types23 = require("@fluxerjs/types");
3621
4394
  function roleId(roleOrId) {
3622
4395
  return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
3623
4396
  }
@@ -3646,7 +4419,7 @@ var GuildMemberRoleManager = class {
3646
4419
  const id = roleId(roleOrId);
3647
4420
  if (this.ids.includes(id)) return;
3648
4421
  await this.member.client.rest.put(
3649
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
4422
+ import_types23.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
3650
4423
  );
3651
4424
  this.ids.push(id);
3652
4425
  }
@@ -3655,13 +4428,13 @@ var GuildMemberRoleManager = class {
3655
4428
  const idx = this.ids.indexOf(id);
3656
4429
  if (idx === -1) return;
3657
4430
  await this.member.client.rest.delete(
3658
- import_types18.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
4431
+ import_types23.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
3659
4432
  );
3660
4433
  this.ids.splice(idx, 1);
3661
4434
  }
3662
4435
  async set(roleIds) {
3663
4436
  const data = await this.member.client.rest.patch(
3664
- import_types18.Routes.guildMember(this.member.guild.id, this.member.id),
4437
+ import_types23.Routes.guildMember(this.member.guild.id, this.member.id),
3665
4438
  { body: { roles: roleIds }, auth: true }
3666
4439
  );
3667
4440
  this.ids = data.roles ? [...data.roles] : [];
@@ -3815,7 +4588,7 @@ var GuildMember = class _GuildMember extends Base {
3815
4588
  */
3816
4589
  async edit(options) {
3817
4590
  const isMe = this.client.user?.id === this.id;
3818
- const route = isMe ? import_types19.Routes.guildMemberMe(this.guild.id) : import_types19.Routes.guildMember(this.guild.id, this.id);
4591
+ const route = isMe ? import_types24.Routes.guildMemberMe(this.guild.id) : import_types24.Routes.guildMember(this.guild.id, this.id);
3819
4592
  const data = await this.client.rest.patch(route, {
3820
4593
  body: toMemberEditBody(options),
3821
4594
  auth: true,
@@ -3928,7 +4701,7 @@ var GuildMember = class _GuildMember extends Base {
3928
4701
  };
3929
4702
 
3930
4703
  // src/Domain/Guild/GuildSticker.ts
3931
- var import_types20 = require("@fluxerjs/types");
4704
+ var import_types25 = require("@fluxerjs/types");
3932
4705
  var import_util17 = require("@fluxerjs/util");
3933
4706
  var GuildSticker = class extends Base {
3934
4707
  client;
@@ -3979,7 +4752,7 @@ var GuildSticker = class extends Base {
3979
4752
  }
3980
4753
  /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
3981
4754
  async delete(reason) {
3982
- await this.client.rest.delete(import_types20.Routes.guildSticker(this.guildId, this.id), {
4755
+ await this.client.rest.delete(import_types25.Routes.guildSticker(this.guildId, this.id), {
3983
4756
  auth: true,
3984
4757
  ...auditReasonHeaders(reason)
3985
4758
  });
@@ -3992,7 +4765,7 @@ var GuildSticker = class extends Base {
3992
4765
  */
3993
4766
  async edit(options) {
3994
4767
  const { reason, ...body } = options;
3995
- const data = await this.client.rest.patch(import_types20.Routes.guildSticker(this.guildId, this.id), {
4768
+ const data = await this.client.rest.patch(import_types25.Routes.guildSticker(this.guildId, this.id), {
3996
4769
  body,
3997
4770
  auth: true,
3998
4771
  ...auditReasonHeaders(reason)
@@ -4005,7 +4778,7 @@ var GuildSticker = class extends Base {
4005
4778
  };
4006
4779
 
4007
4780
  // src/Domain/Guild/Role.ts
4008
- var import_types21 = require("@fluxerjs/types");
4781
+ var import_types26 = require("@fluxerjs/types");
4009
4782
  var import_util18 = require("@fluxerjs/util");
4010
4783
  var Role = class _Role extends Base {
4011
4784
  /** Parent client instance. */
@@ -4115,7 +4888,7 @@ var Role = class _Role extends Base {
4115
4888
  */
4116
4889
  async edit(options) {
4117
4890
  const body = toRoleEditBody(options);
4118
- const data = await this.client.rest.patch(import_types21.Routes.guildRole(this.guildId, this.id), {
4891
+ const data = await this.client.rest.patch(import_types26.Routes.guildRole(this.guildId, this.id), {
4119
4892
  body: Object.keys(body).length ? body : void 0,
4120
4893
  auth: true,
4121
4894
  ...auditReasonHeaders(options.reason)
@@ -4128,7 +4901,7 @@ var Role = class _Role extends Base {
4128
4901
  * @param reason - Audit log reason (`X-Audit-Log-Reason`)
4129
4902
  */
4130
4903
  async delete(reason) {
4131
- await this.client.rest.delete(import_types21.Routes.guildRole(this.guildId, this.id), {
4904
+ await this.client.rest.delete(import_types26.Routes.guildRole(this.guildId, this.id), {
4132
4905
  auth: true,
4133
4906
  ...auditReasonHeaders(reason)
4134
4907
  });
@@ -4223,11 +4996,30 @@ function syncChannels(guild, channels) {
4223
4996
  const keep = new Set(channels.map((c) => c.id));
4224
4997
  for (const data of channels) cacheChannel(guild, data);
4225
4998
  for (const [id, channel] of [...guild.channels.entries()]) {
4226
- if (keep.has(id)) continue;
4999
+ if (keep.has(id) || channel.isThread()) continue;
4227
5000
  Map.prototype.delete.call(guild.channels, id);
4228
5001
  guild.client.cache.cascadeChannel(channel, "guild");
4229
5002
  }
4230
5003
  }
5004
+ function isThreadChannelType(type) {
5005
+ return type === import_types27.ChannelType.AnnouncementThread || type === import_types27.ChannelType.PublicThread || type === import_types27.ChannelType.PrivateThread;
5006
+ }
5007
+ function syncThreads(guild, threads, alsoKeep = /* @__PURE__ */ new Set()) {
5008
+ const keep = new Set(alsoKeep);
5009
+ for (const data of threads) {
5010
+ if (!isThreadChannelType(data.type)) continue;
5011
+ const withGuild = data.guild_id ? data : { ...data, guild_id: guild.id };
5012
+ cacheThread(guild.client, withGuild);
5013
+ keep.add(data.id);
5014
+ }
5015
+ const seen = /* @__PURE__ */ new Set();
5016
+ for (const channel of [...guild.channels.values(), ...guild.client.channels.values()]) {
5017
+ if (seen.has(channel.id)) continue;
5018
+ seen.add(channel.id);
5019
+ if (!channel.isThread() || channel.guildId !== guild.id || keep.has(channel.id)) continue;
5020
+ guild.client.cache.cascadeChannel(channel);
5021
+ }
5022
+ }
4231
5023
  function mergeMembers(guild, members) {
4232
5024
  for (const m of members) {
4233
5025
  if (!m.user?.id) continue;
@@ -4291,7 +5083,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
4291
5083
  const cached = this.get(channelId);
4292
5084
  if (cached && !options?.force) return cached;
4293
5085
  try {
4294
- const data = await this.client.rest.get(import_types22.Routes.channel(channelId));
5086
+ const data = await this.client.rest.get(import_types28.Routes.channel(channelId));
4295
5087
  const guildId = "guild_id" in data ? data.guild_id : void 0;
4296
5088
  if (guildId) {
4297
5089
  const guild = this.client.guilds.get(guildId);
@@ -4336,7 +5128,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
4336
5128
  defaultAllowedMentions: this.client.options.defaultAllowedMentions
4337
5129
  });
4338
5130
  const data = await this.client.rest.post(
4339
- import_types22.Routes.channelMessages(channelId),
5131
+ import_types28.Routes.channelMessages(channelId),
4340
5132
  postPayload
4341
5133
  );
4342
5134
  this.client._addMessageToCache(channelId, data);
@@ -4347,11 +5139,11 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
4347
5139
  // src/ClientCore/Client.ts
4348
5140
  var import_node_events3 = require("events");
4349
5141
  var import_rest3 = require("@fluxerjs/rest");
4350
- var import_types39 = require("@fluxerjs/types");
5142
+ var import_types45 = require("@fluxerjs/types");
4351
5143
  var import_util26 = require("@fluxerjs/util");
4352
5144
 
4353
5145
  // src/Domain/User.ts
4354
- var import_types23 = require("@fluxerjs/types");
5146
+ var import_types29 = require("@fluxerjs/types");
4355
5147
  var import_util19 = require("@fluxerjs/util");
4356
5148
  var User = class extends Base {
4357
5149
  /** Parent client instance. */
@@ -4450,7 +5242,7 @@ var User = class extends Base {
4450
5242
  * @returns DM channel instance (cached if already open)
4451
5243
  */
4452
5244
  async createDM() {
4453
- const data = await this.client.rest.post(import_types23.Routes.userMeChannels(), {
5245
+ const data = await this.client.rest.post(import_types29.Routes.userMeChannels(), {
4454
5246
  body: { recipient_id: this.id },
4455
5247
  auth: true
4456
5248
  });
@@ -4528,7 +5320,7 @@ function resolveCacheLimits(input) {
4528
5320
 
4529
5321
  // src/ClientCore/ClientEmoji.ts
4530
5322
  var import_collection9 = require("@fluxerjs/collection");
4531
- var import_types24 = require("@fluxerjs/types");
5323
+ var import_types30 = require("@fluxerjs/types");
4532
5324
  var import_util20 = require("@fluxerjs/util");
4533
5325
  async function resolveClientEmoji(client, emoji, guildId) {
4534
5326
  if (typeof emoji === "object" && emoji.id) {
@@ -4547,7 +5339,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
4547
5339
  const unicodeFromShortcode = (0, import_util20.getUnicodeFromShortcode)(parsed.name);
4548
5340
  if (unicodeFromShortcode) return unicodeFromShortcode;
4549
5341
  if (guildId) {
4550
- const emojis = await client.rest.get(import_types24.Routes.guildEmojis(guildId));
5342
+ const emojis = await client.rest.get(import_types30.Routes.guildEmojis(guildId));
4551
5343
  const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
4552
5344
  if (found) return (0, import_util20.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
4553
5345
  throw new import_util4.FluxerError(
@@ -4564,26 +5356,26 @@ async function resolveClientEmoji(client, emoji, guildId) {
4564
5356
  return parsed.name;
4565
5357
  }
4566
5358
  async function fetchInstance(client) {
4567
- const raw = await client.rest.get(import_types24.Routes.instanceDiscovery(), {
5359
+ const raw = await client.rest.get(import_types30.Routes.instanceDiscovery(), {
4568
5360
  auth: false,
4569
5361
  unversioned: true
4570
5362
  });
4571
5363
  return parseInstanceDiscovery(raw);
4572
5364
  }
4573
5365
  function fetchGatewayInfo(client) {
4574
- return client.rest.get(import_types24.Routes.gatewayBot());
5366
+ return client.rest.get(import_types30.Routes.gatewayBot());
4575
5367
  }
4576
5368
  function fetchEmojiMetadata(client, emojiId) {
4577
- return client.rest.get(import_types24.Routes.emojiMetadata(emojiId), { auth: true });
5369
+ return client.rest.get(import_types30.Routes.emojiMetadata(emojiId), { auth: true });
4578
5370
  }
4579
5371
  function fetchStickerMetadata(client, stickerId) {
4580
- return client.rest.get(import_types24.Routes.stickerMetadata(stickerId), { auth: true });
5372
+ return client.rest.get(import_types30.Routes.stickerMetadata(stickerId), { auth: true });
4581
5373
  }
4582
5374
  function fetchApplication(client) {
4583
- return client.rest.get(import_types24.Routes.applicationsMe(), { auth: true });
5375
+ return client.rest.get(import_types30.Routes.applicationsMe(), { auth: true });
4584
5376
  }
4585
5377
  async function fetchOAuthApplications(client) {
4586
- const data = await client.rest.get(import_types24.Routes.oauth2ApplicationsMe(), { auth: true });
5378
+ const data = await client.rest.get(import_types30.Routes.oauth2ApplicationsMe(), { auth: true });
4587
5379
  if (Array.isArray(data)) return data;
4588
5380
  if (data && typeof data === "object" && "applications" in data && Array.isArray(data.applications)) {
4589
5381
  return data.applications;
@@ -4602,14 +5394,14 @@ function assertChannelIdBatch(name, channelIds) {
4602
5394
  }
4603
5395
  function preloadMessages(client, channelIds) {
4604
5396
  assertChannelIdBatch("preloadMessages", channelIds);
4605
- return client.rest.post(import_types24.Routes.preloadMessages(), {
5397
+ return client.rest.post(import_types30.Routes.preloadMessages(), {
4606
5398
  body: { channels: channelIds },
4607
5399
  auth: true
4608
5400
  });
4609
5401
  }
4610
5402
  function preloadMessagesAlt(client, channelIds) {
4611
5403
  assertChannelIdBatch("preloadMessagesAlt", channelIds);
4612
- return client.rest.post(import_types24.Routes.preloadMessagesAlt(), {
5404
+ return client.rest.post(import_types30.Routes.preloadMessagesAlt(), {
4613
5405
  body: { channels: channelIds },
4614
5406
  auth: true
4615
5407
  });
@@ -4617,7 +5409,7 @@ function preloadMessagesAlt(client, channelIds) {
4617
5409
  async function bulkFetchMessages(client, requests, options = {}) {
4618
5410
  validateBulkMessageFetchRequests(requests);
4619
5411
  const wire = toBulkFetchWire(requests);
4620
- const data = await client.rest.post(import_types24.Routes.channelsMessagesBulk(), {
5412
+ const data = await client.rest.post(import_types30.Routes.channelsMessagesBulk(), {
4621
5413
  body: { requests: wire },
4622
5414
  auth: true
4623
5415
  });
@@ -4634,7 +5426,7 @@ async function bulkFetchMessages(client, requests, options = {}) {
4634
5426
  };
4635
5427
  }
4636
5428
  async function searchMessages(client, options = {}) {
4637
- const data = await client.rest.post(import_types24.Routes.searchMessages(), {
5429
+ const data = await client.rest.post(import_types30.Routes.searchMessages(), {
4638
5430
  body: toMessageSearchBody(options),
4639
5431
  auth: true
4640
5432
  });
@@ -4659,12 +5451,12 @@ var import_ws = require("@fluxerjs/ws");
4659
5451
 
4660
5452
  // src/Domain/Guild/Guild.ts
4661
5453
  var import_collection12 = require("@fluxerjs/collection");
4662
- var import_types34 = require("@fluxerjs/types");
5454
+ var import_types40 = require("@fluxerjs/types");
4663
5455
  var import_util22 = require("@fluxerjs/util");
4664
5456
 
4665
5457
  // src/ClientCore/GuildMemberManager.ts
4666
5458
  var import_collection10 = require("@fluxerjs/collection");
4667
- var import_types25 = require("@fluxerjs/types");
5459
+ var import_types31 = require("@fluxerjs/types");
4668
5460
  var GuildMemberManager = class extends import_collection10.LimitedCollection {
4669
5461
  constructor(guild) {
4670
5462
  super({ maxSize: guild.client.cache.limits.members });
@@ -4721,7 +5513,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
4721
5513
  if (options?.limit != null) params.set("limit", String(options.limit));
4722
5514
  if (options?.after) params.set("after", options.after);
4723
5515
  const qs2 = params.toString();
4724
- const url = import_types25.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
5516
+ const url = import_types31.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
4725
5517
  const data = await this.guild.client.rest.get(url, { auth: true });
4726
5518
  const members = [];
4727
5519
  for (const m of data) {
@@ -4744,7 +5536,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
4744
5536
  */
4745
5537
  async search(options = {}) {
4746
5538
  const data = await this.guild.client.rest.post(
4747
- import_types25.Routes.guildMembersSearch(this.guild.id),
5539
+ import_types31.Routes.guildMembersSearch(this.guild.id),
4748
5540
  { body: toMemberSearchBody(options), auth: true }
4749
5541
  );
4750
5542
  const offset = options.offset ?? 0;
@@ -4770,7 +5562,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
4770
5562
  };
4771
5563
 
4772
5564
  // src/Domain/Guild/Admin.ts
4773
- var import_types26 = require("@fluxerjs/types");
5565
+ var import_types32 = require("@fluxerjs/types");
4774
5566
  function toAuditLogEntryPayload(entry, guildId) {
4775
5567
  return {
4776
5568
  id: entry.id,
@@ -4791,7 +5583,7 @@ function toVanityPayload(data) {
4791
5583
  return { code: data.code ?? null, uses: data.uses };
4792
5584
  }
4793
5585
  async function fetchAuditLogs(guild, options) {
4794
- const url = import_types26.Routes.guildAuditLogs(guild.id) + qs({
5586
+ const url = import_types32.Routes.guildAuditLogs(guild.id) + qs({
4795
5587
  limit: options?.limit,
4796
5588
  before: options?.before,
4797
5589
  after: options?.after,
@@ -4815,7 +5607,7 @@ async function fetchAuditLogs(guild, options) {
4815
5607
  };
4816
5608
  }
4817
5609
  async function editGuild(guild, options) {
4818
- const data = await guild.client.rest.patch(import_types26.Routes.guild(guild.id), {
5610
+ const data = await guild.client.rest.patch(import_types32.Routes.guild(guild.id), {
4819
5611
  body: toGuildEditBody(options),
4820
5612
  auth: true
4821
5613
  });
@@ -4823,13 +5615,13 @@ async function editGuild(guild, options) {
4823
5615
  return guild;
4824
5616
  }
4825
5617
  async function fetchVanityURL(guild) {
4826
- const data = await guild.client.rest.get(import_types26.Routes.guildVanityUrl(guild.id), {
5618
+ const data = await guild.client.rest.get(import_types32.Routes.guildVanityUrl(guild.id), {
4827
5619
  auth: true
4828
5620
  });
4829
5621
  return toVanityPayload(data);
4830
5622
  }
4831
5623
  async function editVanityURL(guild, code) {
4832
- const data = await guild.client.rest.patch(import_types26.Routes.guildVanityUrl(guild.id), {
5624
+ const data = await guild.client.rest.patch(import_types32.Routes.guildVanityUrl(guild.id), {
4833
5625
  body: { code },
4834
5626
  auth: true
4835
5627
  });
@@ -4837,14 +5629,14 @@ async function editVanityURL(guild, code) {
4837
5629
  return toVanityPayload(data);
4838
5630
  }
4839
5631
  async function fetchDiscoveryStatus(guild) {
4840
- const data = await guild.client.rest.get(import_types26.Routes.guildDiscovery(guild.id), {
5632
+ const data = await guild.client.rest.get(import_types32.Routes.guildDiscovery(guild.id), {
4841
5633
  auth: true
4842
5634
  });
4843
5635
  return toDiscoveryStatusPayload(data);
4844
5636
  }
4845
5637
  async function applyForDiscovery(guild, options) {
4846
5638
  const data = await guild.client.rest.post(
4847
- import_types26.Routes.guildDiscovery(guild.id),
5639
+ import_types32.Routes.guildDiscovery(guild.id),
4848
5640
  {
4849
5641
  body: toDiscoveryBody(options),
4850
5642
  auth: true
@@ -4854,7 +5646,7 @@ async function applyForDiscovery(guild, options) {
4854
5646
  }
4855
5647
  async function editDiscoveryApplication(guild, options) {
4856
5648
  const data = await guild.client.rest.patch(
4857
- import_types26.Routes.guildDiscovery(guild.id),
5649
+ import_types32.Routes.guildDiscovery(guild.id),
4858
5650
  {
4859
5651
  body: toDiscoveryBody(options),
4860
5652
  auth: true
@@ -4863,34 +5655,34 @@ async function editDiscoveryApplication(guild, options) {
4863
5655
  return toDiscoveryApplicationPayload(data);
4864
5656
  }
4865
5657
  async function withdrawDiscoveryApplication(guild) {
4866
- await guild.client.rest.delete(import_types26.Routes.guildDiscovery(guild.id), { auth: true });
5658
+ await guild.client.rest.delete(import_types32.Routes.guildDiscovery(guild.id), { auth: true });
4867
5659
  }
4868
5660
  async function deleteGuild(guild, options) {
4869
5661
  const body = options ? toSudoBody(options) : {};
4870
- await guild.client.rest.post(import_types26.Routes.guildDelete(guild.id), {
5662
+ await guild.client.rest.post(import_types32.Routes.guildDelete(guild.id), {
4871
5663
  body,
4872
5664
  auth: true
4873
5665
  });
4874
5666
  guild.client.guilds.delete(guild.id);
4875
5667
  }
4876
5668
  async function transferOwnership(guild, newOwnerId, password) {
4877
- await guild.client.rest.post(import_types26.Routes.guildTransferOwnership(guild.id), {
5669
+ await guild.client.rest.post(import_types32.Routes.guildTransferOwnership(guild.id), {
4878
5670
  body: { new_owner_id: newOwnerId, ...password != null && { password } },
4879
5671
  auth: true
4880
5672
  });
4881
5673
  }
4882
5674
 
4883
5675
  // src/Domain/Guild/Channels.ts
4884
- var import_types27 = require("@fluxerjs/types");
5676
+ var import_types33 = require("@fluxerjs/types");
4885
5677
  async function createChannel(guild, options) {
4886
- const created = await guild.client.rest.post(import_types27.Routes.guildChannels(guild.id), {
5678
+ const created = await guild.client.rest.post(import_types33.Routes.guildChannels(guild.id), {
4887
5679
  body: toChannelCreateBody(options),
4888
5680
  auth: true
4889
5681
  });
4890
5682
  return cacheChannel(guild, created);
4891
5683
  }
4892
5684
  async function fetchChannels(guild) {
4893
- const data = await guild.client.rest.get(import_types27.Routes.guildChannels(guild.id));
5685
+ const data = await guild.client.rest.get(import_types33.Routes.guildChannels(guild.id));
4894
5686
  const channels = [];
4895
5687
  for (const ch of data) {
4896
5688
  const channel = cacheChannel(guild, ch);
@@ -4899,17 +5691,17 @@ async function fetchChannels(guild) {
4899
5691
  return channels;
4900
5692
  }
4901
5693
  async function setChannelPositions(guild, updates) {
4902
- await guild.client.rest.patch(import_types27.Routes.guildChannels(guild.id), {
5694
+ await guild.client.rest.patch(import_types33.Routes.guildChannels(guild.id), {
4903
5695
  body: toChannelPositionBody(updates),
4904
5696
  auth: true
4905
5697
  });
4906
5698
  }
4907
5699
  async function fetchWebhooks(guild) {
4908
- const data = await guild.client.rest.get(import_types27.Routes.guildWebhooks(guild.id));
5700
+ const data = await guild.client.rest.get(import_types33.Routes.guildWebhooks(guild.id));
4909
5701
  return data.map((w) => new Webhook(guild.client, w));
4910
5702
  }
4911
5703
  async function fetchInvites(guild) {
4912
- const data = await guild.client.rest.get(import_types27.Routes.guildInvites(guild.id));
5704
+ const data = await guild.client.rest.get(import_types33.Routes.guildInvites(guild.id));
4913
5705
  return data.map((invite) => new Invite(guild.client, invite));
4914
5706
  }
4915
5707
  async function fetchInvite(guild, codeOrUrl) {
@@ -4929,14 +5721,14 @@ function resolveGuildOnlineCount(data) {
4929
5721
  }
4930
5722
 
4931
5723
  // src/Domain/Guild/Emojis.ts
4932
- var import_types28 = require("@fluxerjs/types");
5724
+ var import_types34 = require("@fluxerjs/types");
4933
5725
  async function fetchEmojis(guild) {
4934
- const data = await guild.client.rest.get(import_types28.Routes.guildEmojis(guild.id));
5726
+ const data = await guild.client.rest.get(import_types34.Routes.guildEmojis(guild.id));
4935
5727
  return data.map((e) => cacheEmoji(guild, e));
4936
5728
  }
4937
5729
  async function fetchEmoji(guild, emojiId) {
4938
5730
  try {
4939
- const data = await guild.client.rest.get(import_types28.Routes.guildEmoji(guild.id, emojiId));
5731
+ const data = await guild.client.rest.get(import_types34.Routes.guildEmoji(guild.id, emojiId));
4940
5732
  return cacheEmoji(guild, data);
4941
5733
  } catch (err) {
4942
5734
  rethrowMapped(err, {
@@ -4947,7 +5739,7 @@ async function fetchEmoji(guild, emojiId) {
4947
5739
  }
4948
5740
  async function createEmoji(guild, options) {
4949
5741
  const { reason, ...body } = options;
4950
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojis(guild.id), {
5742
+ const data = await guild.client.rest.post(import_types34.Routes.guildEmojis(guild.id), {
4951
5743
  body,
4952
5744
  auth: true,
4953
5745
  ...auditReasonHeaders(reason)
@@ -4955,7 +5747,7 @@ async function createEmoji(guild, options) {
4955
5747
  return cacheEmoji(guild, data);
4956
5748
  }
4957
5749
  async function cloneEmoji(guild, sourceEmojiId) {
4958
- const data = await guild.client.rest.post(import_types28.Routes.guildEmojisClone(guild.id), {
5750
+ const data = await guild.client.rest.post(import_types34.Routes.guildEmojisClone(guild.id), {
4959
5751
  body: { source_emoji_id: sourceEmojiId },
4960
5752
  auth: true
4961
5753
  });
@@ -4963,7 +5755,7 @@ async function cloneEmoji(guild, sourceEmojiId) {
4963
5755
  }
4964
5756
  async function createEmojisBulk(guild, emojis) {
4965
5757
  const data = await guild.client.rest.post(
4966
- import_types28.Routes.guildEmojisBulk(guild.id),
5758
+ import_types34.Routes.guildEmojisBulk(guild.id),
4967
5759
  { body: { emojis }, auth: true }
4968
5760
  );
4969
5761
  return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
@@ -4983,11 +5775,11 @@ var GuildRoleManager = class extends import_collection11.LimitedCollection {
4983
5775
  };
4984
5776
 
4985
5777
  // src/Domain/Guild/MemberHttp.ts
4986
- var import_types29 = require("@fluxerjs/types");
5778
+ var import_types35 = require("@fluxerjs/types");
4987
5779
  async function fetchMember(guild, userId) {
4988
5780
  try {
4989
5781
  const data = await guild.client.rest.get(
4990
- import_types29.Routes.guildMember(guild.id, userId)
5782
+ import_types35.Routes.guildMember(guild.id, userId)
4991
5783
  );
4992
5784
  return cacheMember(guild, data);
4993
5785
  } catch (err) {
@@ -5002,17 +5794,17 @@ async function fetchMember(guild, userId) {
5002
5794
  }
5003
5795
  async function fetchMe(guild) {
5004
5796
  const data = await guild.client.rest.get(
5005
- import_types29.Routes.guildMemberMe(guild.id),
5797
+ import_types35.Routes.guildMemberMe(guild.id),
5006
5798
  { auth: true }
5007
5799
  );
5008
5800
  return cacheMember(guild, data);
5009
5801
  }
5010
5802
 
5011
5803
  // src/Domain/Guild/Moderation.ts
5012
- var import_types31 = require("@fluxerjs/types");
5804
+ var import_types37 = require("@fluxerjs/types");
5013
5805
 
5014
5806
  // src/Domain/Guild/GuildBan.ts
5015
- var import_types30 = require("@fluxerjs/types");
5807
+ var import_types36 = require("@fluxerjs/types");
5016
5808
  function parseOptionalDate2(value) {
5017
5809
  if (value == null || value === "") return null;
5018
5810
  const date = new Date(value);
@@ -5039,7 +5831,7 @@ var GuildBan = class extends Base {
5039
5831
  * Requires Ban Members permission.
5040
5832
  */
5041
5833
  async unban(reason) {
5042
- await this.client.rest.delete(import_types30.Routes.guildBan(this.guildId, this.user.id), {
5834
+ await this.client.rest.delete(import_types36.Routes.guildBan(this.guildId, this.user.id), {
5043
5835
  auth: true,
5044
5836
  ...auditReasonHeaders(reason)
5045
5837
  });
@@ -5049,35 +5841,35 @@ var GuildBan = class extends Base {
5049
5841
  // src/Domain/Guild/Moderation.ts
5050
5842
  async function ban(guild, userId, options) {
5051
5843
  const body = options ? toGuildBanBody(options) : {};
5052
- await guild.client.rest.put(import_types31.Routes.guildBan(guild.id, userId), {
5844
+ await guild.client.rest.put(import_types37.Routes.guildBan(guild.id, userId), {
5053
5845
  body: Object.keys(body).length ? body : void 0,
5054
5846
  auth: true,
5055
5847
  ...auditReasonHeaders(options?.reason)
5056
5848
  });
5057
5849
  }
5058
5850
  async function fetchBans(guild) {
5059
- const data = await guild.client.rest.get(import_types31.Routes.guildBans(guild.id));
5851
+ const data = await guild.client.rest.get(import_types37.Routes.guildBans(guild.id));
5060
5852
  return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
5061
5853
  }
5062
5854
  async function unban(guild, userId, reason) {
5063
- await guild.client.rest.delete(import_types31.Routes.guildBan(guild.id, userId), {
5855
+ await guild.client.rest.delete(import_types37.Routes.guildBan(guild.id, userId), {
5064
5856
  auth: true,
5065
5857
  ...auditReasonHeaders(reason)
5066
5858
  });
5067
5859
  }
5068
5860
  async function kick(guild, userId, reason) {
5069
- await guild.client.rest.delete(import_types31.Routes.guildMember(guild.id, userId), {
5861
+ await guild.client.rest.delete(import_types37.Routes.guildMember(guild.id, userId), {
5070
5862
  auth: true,
5071
5863
  ...auditReasonHeaders(reason)
5072
5864
  });
5073
5865
  }
5074
5866
 
5075
5867
  // src/Domain/Guild/Roles.ts
5076
- var import_types32 = require("@fluxerjs/types");
5868
+ var import_types38 = require("@fluxerjs/types");
5077
5869
  var import_util21 = require("@fluxerjs/util");
5078
5870
  async function createRole(guild, options = {}) {
5079
5871
  const body = toRoleCreateBody(options);
5080
- const data = await guild.client.rest.post(import_types32.Routes.guildRoles(guild.id), {
5872
+ const data = await guild.client.rest.post(import_types38.Routes.guildRoles(guild.id), {
5081
5873
  body: Object.keys(body).length ? body : void 0,
5082
5874
  auth: true,
5083
5875
  ...auditReasonHeaders(options.reason)
@@ -5085,12 +5877,12 @@ async function createRole(guild, options = {}) {
5085
5877
  return cacheRole(guild, data);
5086
5878
  }
5087
5879
  async function fetchRoles(guild) {
5088
- const data = await guild.client.rest.get(import_types32.Routes.guildRoles(guild.id));
5880
+ const data = await guild.client.rest.get(import_types38.Routes.guildRoles(guild.id));
5089
5881
  return data.map((r) => cacheRole(guild, r));
5090
5882
  }
5091
5883
  async function fetchRole(guild, roleId2) {
5092
5884
  try {
5093
- const data = await guild.client.rest.get(import_types32.Routes.guildRole(guild.id, roleId2));
5885
+ const data = await guild.client.rest.get(import_types38.Routes.guildRole(guild.id, roleId2));
5094
5886
  return cacheRole(guild, data);
5095
5887
  } catch (err) {
5096
5888
  rethrowMapped(err, {
@@ -5107,7 +5899,7 @@ async function resolveRoleId(guild, arg) {
5107
5899
  const needle = trimmed.toLowerCase();
5108
5900
  const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
5109
5901
  if (cached) return cached.id;
5110
- const roles = await guild.client.rest.get(import_types32.Routes.guildRoles(guild.id));
5902
+ const roles = await guild.client.rest.get(import_types38.Routes.guildRoles(guild.id));
5111
5903
  const role = roles.find((r) => r.name?.toLowerCase() === needle);
5112
5904
  if (!role) return null;
5113
5905
  cacheRole(guild, role);
@@ -5116,7 +5908,7 @@ async function resolveRoleId(guild, arg) {
5116
5908
  async function setRolePositions(guild, updates) {
5117
5909
  return replaceRoles(
5118
5910
  guild,
5119
- await guild.client.rest.patch(import_types32.Routes.guildRoles(guild.id), {
5911
+ await guild.client.rest.patch(import_types38.Routes.guildRoles(guild.id), {
5120
5912
  body: updates,
5121
5913
  auth: true
5122
5914
  })
@@ -5125,7 +5917,7 @@ async function setRolePositions(guild, updates) {
5125
5917
  async function setRoleHoistPositions(guild, updates) {
5126
5918
  return replaceRoles(
5127
5919
  guild,
5128
- await guild.client.rest.patch(import_types32.Routes.guildRolesHoistPositions(guild.id), {
5920
+ await guild.client.rest.patch(import_types38.Routes.guildRolesHoistPositions(guild.id), {
5129
5921
  body: updates.map((u) => ({
5130
5922
  id: u.id,
5131
5923
  ...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
@@ -5137,17 +5929,17 @@ async function setRoleHoistPositions(guild, updates) {
5137
5929
  async function resetRoleHoistPositions(guild) {
5138
5930
  return replaceRoles(
5139
5931
  guild,
5140
- await guild.client.rest.delete(import_types32.Routes.guildRolesHoistPositions(guild.id), {
5932
+ await guild.client.rest.delete(import_types38.Routes.guildRolesHoistPositions(guild.id), {
5141
5933
  auth: true
5142
5934
  })
5143
5935
  );
5144
5936
  }
5145
5937
 
5146
5938
  // src/Domain/Guild/Stickers.ts
5147
- var import_types33 = require("@fluxerjs/types");
5939
+ var import_types39 = require("@fluxerjs/types");
5148
5940
  async function createSticker(guild, options) {
5149
5941
  const { reason, ...body } = options;
5150
- const data = await guild.client.rest.post(import_types33.Routes.guildStickers(guild.id), {
5942
+ const data = await guild.client.rest.post(import_types39.Routes.guildStickers(guild.id), {
5151
5943
  body,
5152
5944
  auth: true,
5153
5945
  ...auditReasonHeaders(reason)
@@ -5155,7 +5947,7 @@ async function createSticker(guild, options) {
5155
5947
  return cacheSticker(guild, data);
5156
5948
  }
5157
5949
  async function cloneSticker(guild, sourceStickerId) {
5158
- const data = await guild.client.rest.post(import_types33.Routes.guildStickersClone(guild.id), {
5950
+ const data = await guild.client.rest.post(import_types39.Routes.guildStickersClone(guild.id), {
5159
5951
  body: { source_sticker_id: sourceStickerId },
5160
5952
  auth: true
5161
5953
  });
@@ -5163,17 +5955,17 @@ async function cloneSticker(guild, sourceStickerId) {
5163
5955
  }
5164
5956
  async function createStickersBulk(guild, stickers) {
5165
5957
  const data = await guild.client.rest.post(
5166
- import_types33.Routes.guildStickersBulk(guild.id),
5958
+ import_types39.Routes.guildStickersBulk(guild.id),
5167
5959
  { body: { stickers }, auth: true }
5168
5960
  );
5169
5961
  return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
5170
5962
  }
5171
5963
  async function fetchStickers(guild) {
5172
- const data = await guild.client.rest.get(import_types33.Routes.guildStickers(guild.id));
5964
+ const data = await guild.client.rest.get(import_types39.Routes.guildStickers(guild.id));
5173
5965
  return data.map((s) => cacheSticker(guild, s));
5174
5966
  }
5175
5967
  async function fetchSticker(guild, stickerId) {
5176
- const data = await guild.client.rest.get(import_types33.Routes.guildSticker(guild.id, stickerId));
5968
+ const data = await guild.client.rest.get(import_types39.Routes.guildSticker(guild.id, stickerId));
5177
5969
  return cacheSticker(guild, data);
5178
5970
  }
5179
5971
 
@@ -5290,7 +6082,7 @@ var Guild = class extends Base {
5290
6082
  this.systemChannelFlags = data.system_channel_flags ?? 0;
5291
6083
  this.splashCardAlignment = data.splash_card_alignment ?? 0;
5292
6084
  this.embedSplash = data.embed_splash ?? null;
5293
- this.nsfwLevel = data.nsfw_level ?? import_types34.GuildNSFWLevel.Safe;
6085
+ this.nsfwLevel = data.nsfw_level ?? import_types40.GuildNSFWLevel.Safe;
5294
6086
  this.nsfw = data.nsfw ?? false;
5295
6087
  this.contentWarningLevel = data.content_warning_level ?? 0;
5296
6088
  this.contentWarningText = data.content_warning_text ?? null;
@@ -5338,7 +6130,7 @@ var Guild = class extends Base {
5338
6130
  this.splashCardAlignment = data.splash_card_alignment ?? 0;
5339
6131
  }
5340
6132
  if (data.embed_splash !== void 0) this.embedSplash = data.embed_splash ?? null;
5341
- if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types34.GuildNSFWLevel.Safe;
6133
+ if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types40.GuildNSFWLevel.Safe;
5342
6134
  if (data.nsfw !== void 0) this.nsfw = data.nsfw ?? false;
5343
6135
  if (data.content_warning_level !== void 0) {
5344
6136
  this.contentWarningLevel = data.content_warning_level ?? 0;
@@ -5405,7 +6197,7 @@ var Guild = class extends Base {
5405
6197
  });
5406
6198
  }
5407
6199
  /**
5408
- * Create a channel. `type`: 0=text, 2=voice, 4=category, 998=link (set `url`).
6200
+ * Create a channel. `type`: 0=text, 2=voice, 4=category, 5=announcement, 15=forum, 16=media, 998=link (set `url`).
5409
6201
  * Requires Manage Channels.
5410
6202
  */
5411
6203
  createChannel(options) {
@@ -5415,6 +6207,10 @@ var Guild = class extends Base {
5415
6207
  fetchChannels() {
5416
6208
  return fetchChannels(this);
5417
6209
  }
6210
+ /** Fetch active threads in this guild. */
6211
+ fetchActiveThreads() {
6212
+ return fetchActiveThreads(this.client, this.id);
6213
+ }
5418
6214
  /** Update channel positions (reordering). */
5419
6215
  setChannelPositions(updates) {
5420
6216
  return setChannelPositions(this, updates);
@@ -5645,6 +6441,13 @@ function upsertGuildFromSnapshot(client, guildData, resources = {}) {
5645
6441
  client.guilds.set(guild.id, guild);
5646
6442
  if (resources.roles !== void 0) syncRoles(guild, resources.roles);
5647
6443
  if (resources.channels !== void 0) syncChannels(guild, resources.channels);
6444
+ if (resources.threads !== void 0) {
6445
+ syncThreads(
6446
+ guild,
6447
+ resources.threads,
6448
+ new Set((resources.channels ?? []).map((channel) => channel.id))
6449
+ );
6450
+ }
5648
6451
  if (resources.members !== void 0) mergeMembers(guild, resources.members);
5649
6452
  if (resources.emojis !== void 0) syncEmojis(guild, resources.emojis);
5650
6453
  if (resources.stickers !== void 0) syncStickers(guild, resources.stickers);
@@ -5659,7 +6462,9 @@ function applyGuildSnapshotFromGateway(client, raw) {
5659
6462
  channels: g.channels,
5660
6463
  members: g.members,
5661
6464
  emojis: g.emojis,
5662
- stickers: g.stickers
6465
+ stickers: g.stickers,
6466
+ // A channel list without `threads` means this session has no viewable threads.
6467
+ threads: g.channels !== void 0 ? g.threads ?? [] : g.threads
5663
6468
  });
5664
6469
  if (g.voice_states?.length) {
5665
6470
  client.emit(Events.VoiceStatesSync, {
@@ -5671,23 +6476,23 @@ function applyGuildSnapshotFromGateway(client, raw) {
5671
6476
  }
5672
6477
 
5673
6478
  // src/ClientCore/ClientUser.ts
5674
- var import_types35 = require("@fluxerjs/types");
6479
+ var import_types41 = require("@fluxerjs/types");
5675
6480
  var ClientUser = class extends User {
5676
6481
  /** Broadcast presence (gateway opcode 3) on all shards. */
5677
6482
  setPresence(presence) {
5678
6483
  this.client.options.presence = presence;
5679
6484
  const wire = toPresenceWire(presence);
5680
- this.client._sendToAllShards({ op: import_types35.GatewayOpcodes.PresenceUpdate, d: wire });
6485
+ this.client._sendToAllShards({ op: import_types41.GatewayOpcodes.PresenceUpdate, d: wire });
5681
6486
  }
5682
6487
  /** GET /users/@me — refresh the logged-in user from REST and patch this instance. */
5683
6488
  async fetch() {
5684
- const data = await this.client.rest.get(import_types35.Routes.currentUser(), { auth: true });
6489
+ const data = await this.client.rest.get(import_types41.Routes.currentUser(), { auth: true });
5685
6490
  this._patch(data);
5686
6491
  return this;
5687
6492
  }
5688
6493
  /** GET /users/@me/guilds — returns camelCase partial guilds. */
5689
6494
  async fetchGuilds(options) {
5690
- const path = import_types35.Routes.currentUserGuilds() + (options?.withCounts ? "?with_counts=true" : "");
6495
+ const path = import_types41.Routes.currentUserGuilds() + (options?.withCounts ? "?with_counts=true" : "");
5691
6496
  const data = await this.client.rest.get(path, { auth: true });
5692
6497
  return data.map((g) => ({
5693
6498
  id: g.id,
@@ -5711,7 +6516,7 @@ var ClientUser = class extends User {
5711
6516
  */
5712
6517
  async leaveGuild(guildId, options) {
5713
6518
  const body = options ? toSudoBody(options) : void 0;
5714
- await this.client.rest.delete(import_types35.Routes.leaveGuild(guildId), {
6519
+ await this.client.rest.delete(import_types41.Routes.leaveGuild(guildId), {
5715
6520
  body: body && Object.keys(body).length ? body : void 0,
5716
6521
  auth: true
5717
6522
  });
@@ -5719,7 +6524,7 @@ var ClientUser = class extends User {
5719
6524
  /** Delete every message authored by the caller across a guild (sudo). */
5720
6525
  async bulkDeleteMyMessagesInGuild(guildId, options) {
5721
6526
  const body = options ? toSudoBody(options) : void 0;
5722
- await this.client.rest.post(import_types35.Routes.guildBulkDeleteMine(guildId), {
6527
+ await this.client.rest.post(import_types41.Routes.guildBulkDeleteMine(guildId), {
5723
6528
  body: body && Object.keys(body).length ? body : void 0,
5724
6529
  auth: true
5725
6530
  });
@@ -5754,6 +6559,7 @@ var channelHandlers = {
5754
6559
  if (!ch) return;
5755
6560
  indexChannel(client, ch);
5756
6561
  client.emit(Events.ChannelCreate, ch);
6562
+ if (ch.isThread()) client.emit(Events.ThreadCreate, ch);
5757
6563
  },
5758
6564
  CHANNEL_UPDATE(client, d) {
5759
6565
  const data = d;
@@ -5766,12 +6572,14 @@ var channelHandlers = {
5766
6572
  existing._patch(data);
5767
6573
  indexChannel(client, existing);
5768
6574
  client.emit(Events.ChannelUpdate, oldCh, existing);
6575
+ if (existing.isThread()) client.emit(Events.ThreadUpdate, oldCh, existing);
5769
6576
  return;
5770
6577
  }
5771
6578
  const newCh = Channel.from(client, data);
5772
6579
  if (!newCh) return;
5773
6580
  indexChannel(client, newCh);
5774
6581
  client.emit(Events.ChannelUpdate, existing ?? newCh, newCh);
6582
+ if (newCh.isThread()) client.emit(Events.ThreadUpdate, existing ?? newCh, newCh);
5775
6583
  },
5776
6584
  CHANNEL_UPDATE_BULK(client, d) {
5777
6585
  const data = d;
@@ -5793,7 +6601,11 @@ var channelHandlers = {
5793
6601
  }
5794
6602
  if (!channel) return;
5795
6603
  client.channels.delete(id);
6604
+ if (channel.isGuild() && channel.guildId) {
6605
+ client.guilds.get(channel.guildId)?.channels.delete(id);
6606
+ }
5796
6607
  client.emit(Events.ChannelDelete, channel);
6608
+ if (channel.isThread()) client.emit(Events.ThreadDelete, channel);
5797
6609
  },
5798
6610
  CHANNEL_PINS_UPDATE(client, d) {
5799
6611
  const data = d;
@@ -5983,6 +6795,10 @@ var guildHandlers = {
5983
6795
  }
5984
6796
  client._onGuildReceived(guild.id);
5985
6797
  },
6798
+ /** Same snapshot as Guild Create, including `threads`. Cache only: this is not a join. */
6799
+ GUILD_SYNC(client, d) {
6800
+ applyGuildSnapshotFromGateway(client, d);
6801
+ },
5986
6802
  GUILD_UPDATE(client, d) {
5987
6803
  const guildData = normalizeGuildUpdatePayload(d);
5988
6804
  if (!guildData) return;
@@ -6031,13 +6847,13 @@ var guildHandlers = {
6031
6847
  };
6032
6848
 
6033
6849
  // src/ClientCore/EventHandlers/Invites.ts
6034
- var import_types36 = require("@fluxerjs/types");
6850
+ var import_types42 = require("@fluxerjs/types");
6035
6851
  function normalizeInviteCreate(client, payload) {
6036
6852
  const raw = (0, import_util24.asRecord)(payload);
6037
6853
  const code = (0, import_util24.str)(raw?.code);
6038
6854
  if (!raw || !code) return null;
6039
6855
  const typeNum = (0, import_util24.num)(raw.type);
6040
- const type = typeNum === import_types36.InviteType.GroupDM ? import_types36.InviteType.GroupDM : import_types36.InviteType.Guild;
6856
+ const type = typeNum === import_types42.InviteType.GroupDM ? import_types42.InviteType.GroupDM : import_types42.InviteType.Guild;
6041
6857
  const shared = {
6042
6858
  code,
6043
6859
  inviter: raw.inviter ?? null,
@@ -6054,17 +6870,17 @@ function normalizeInviteCreate(client, payload) {
6054
6870
  const guildId = (0, import_util24.str)(guildObj?.id) ?? (0, import_util24.str)(raw.guild_id) ?? "0";
6055
6871
  const channelId = (0, import_util24.str)(channelObj?.id) ?? (0, import_util24.str)(raw.channel_id) ?? "0";
6056
6872
  const cachedGuild = guildId !== "0" ? client.guilds.get(guildId) : null;
6057
- const cachedChannel = channelId !== "0" ? client.channels.get(channelId) : null;
6873
+ const cachedChannel2 = channelId !== "0" ? client.channels.get(channelId) : null;
6058
6874
  const channel = {
6059
6875
  id: channelId,
6060
- type: (0, import_util24.num)(channelObj?.type) ?? cachedChannel?.type ?? import_types36.ChannelType.GuildText,
6061
- name: (0, import_util24.str)(channelObj?.name) ?? cachedChannel?.name ?? null,
6876
+ type: (0, import_util24.num)(channelObj?.type) ?? cachedChannel2?.type ?? import_types42.ChannelType.GuildText,
6877
+ name: (0, import_util24.str)(channelObj?.name) ?? cachedChannel2?.name ?? null,
6062
6878
  icon: channelObj?.icon ?? null
6063
6879
  };
6064
- if (type === import_types36.InviteType.GroupDM) return { ...shared, type, channel };
6880
+ if (type === import_types42.InviteType.GroupDM) return { ...shared, type, channel };
6065
6881
  return {
6066
6882
  ...shared,
6067
- type: import_types36.InviteType.Guild,
6883
+ type: import_types42.InviteType.Guild,
6068
6884
  guild: {
6069
6885
  id: guildId,
6070
6886
  name: (0, import_util24.str)(guildObj?.name) ?? cachedGuild?.name ?? "Unknown Guild",
@@ -6462,6 +7278,107 @@ var passthroughHandlers = {
6462
7278
  WEBAUTHN_CREDENTIALS_UPDATE: pass(Events.WebAuthnCredentialsUpdate)
6463
7279
  };
6464
7280
 
7281
+ // src/ClientCore/EventHandlers/Threads.ts
7282
+ function cachedChannel(client, id) {
7283
+ const direct = client.channels.get(id);
7284
+ if (direct) return direct;
7285
+ for (const guild of client.guilds.values()) {
7286
+ const nested = guild.channels.get(id);
7287
+ if (nested) return nested;
7288
+ }
7289
+ return null;
7290
+ }
7291
+ var threadHandlers = {
7292
+ THREAD_CREATE(client, d) {
7293
+ channelHandlers.CHANNEL_CREATE(client, d);
7294
+ },
7295
+ THREAD_UPDATE(client, d) {
7296
+ channelHandlers.CHANNEL_UPDATE(client, d);
7297
+ },
7298
+ THREAD_DELETE(client, d) {
7299
+ const data = d;
7300
+ const existing = data.id ? cachedChannel(client, data.id) : null;
7301
+ if (existing?.isThread()) {
7302
+ channelHandlers.CHANNEL_DELETE(client, data);
7303
+ return;
7304
+ }
7305
+ if (!data.id || !isThreadType(data.type)) return;
7306
+ const thread = Channel.from(client, {
7307
+ id: data.id,
7308
+ type: data.type,
7309
+ guild_id: data.guild_id,
7310
+ parent_id: data.parent_id
7311
+ });
7312
+ if (!thread.isThread()) return;
7313
+ client.emit(Events.ChannelDelete, thread);
7314
+ client.emit(Events.ThreadDelete, thread);
7315
+ },
7316
+ THREAD_LIST_SYNC(client, d) {
7317
+ const data = d;
7318
+ const { threads } = fetchedThreadsFrom(client, {
7319
+ threads: data.threads ?? [],
7320
+ members: data.members ?? []
7321
+ });
7322
+ const payload = {
7323
+ guildId: data.guild_id,
7324
+ channelIds: data.channel_ids ?? [],
7325
+ threads
7326
+ };
7327
+ client.emit(Events.ThreadListSync, payload);
7328
+ },
7329
+ THREAD_MEMBER_UPDATE(client, d) {
7330
+ const data = d;
7331
+ const member = new ThreadMember(data);
7332
+ const thread = member.id ? client.channels.get(member.id) : void 0;
7333
+ if (thread?.isThread() && member.userId && member.userId === client.user?.id) {
7334
+ thread.member = member;
7335
+ }
7336
+ client.emit(Events.ThreadMemberUpdate, member);
7337
+ },
7338
+ THREAD_MEMBERS_UPDATE(client, d) {
7339
+ const data = d;
7340
+ const thread = client.channels.get(data.id);
7341
+ if (thread?.isThread()) thread.memberCount = data.member_count;
7342
+ const payload = {
7343
+ id: data.id,
7344
+ guildId: data.guild_id,
7345
+ memberCount: data.member_count,
7346
+ addedMembers: (data.added_members ?? []).map((member) => new ThreadMember(member)),
7347
+ removedMemberIds: data.removed_member_ids ?? []
7348
+ };
7349
+ client.emit(Events.ThreadMembersUpdate, payload);
7350
+ },
7351
+ THREAD_MEMBER_LIST_UPDATE(client, d) {
7352
+ const data = d;
7353
+ const guild = data.guild_id ? client.guilds.get(data.guild_id) : void 0;
7354
+ const payload = {
7355
+ guildId: data.guild_id,
7356
+ threadId: data.thread_id,
7357
+ members: (data.members ?? []).map((entry) => ({
7358
+ userId: entry.user_id,
7359
+ joinTimestamp: entry.join_timestamp,
7360
+ flags: entry.flags,
7361
+ member: guild && entry.member?.user?.id ? cacheMember(guild, entry.member) : null,
7362
+ presence: entry.presence ? { status: entry.presence.status ?? null } : null
7363
+ }))
7364
+ };
7365
+ client.emit(Events.ThreadMemberListUpdate, payload);
7366
+ },
7367
+ FORUM_UNREADS(client, d) {
7368
+ const data = d;
7369
+ const payload = {
7370
+ guildId: data.guild_id,
7371
+ channelId: data.channel_id,
7372
+ threads: (data.threads ?? []).map((entry) => ({
7373
+ threadId: entry.thread_id,
7374
+ count: entry.count ?? null,
7375
+ missing: entry.missing === true
7376
+ }))
7377
+ };
7378
+ client.emit(Events.ForumUnreads, payload);
7379
+ }
7380
+ };
7381
+
6465
7382
  // src/ClientCore/EventHandlers/index.ts
6466
7383
  var eventHandlers = buildRegistry(
6467
7384
  messageHandlers,
@@ -6470,7 +7387,8 @@ var eventHandlers = buildRegistry(
6470
7387
  memberHandlers,
6471
7388
  inviteHandlers,
6472
7389
  guildResourceHandlers,
6473
- passthroughHandlers
7390
+ passthroughHandlers,
7391
+ threadHandlers
6474
7392
  );
6475
7393
 
6476
7394
  // src/ClientCore/GatewayDispatch.ts
@@ -6696,7 +7614,7 @@ async function connectClientGateway(client, token, signal) {
6696
7614
 
6697
7615
  // src/ClientCore/GuildManager.ts
6698
7616
  var import_collection13 = require("@fluxerjs/collection");
6699
- var import_types37 = require("@fluxerjs/types");
7617
+ var import_types43 = require("@fluxerjs/types");
6700
7618
  var GuildManager = class extends import_collection13.LimitedCollection {
6701
7619
  constructor(client) {
6702
7620
  super({
@@ -6735,7 +7653,7 @@ var GuildManager = class extends import_collection13.LimitedCollection {
6735
7653
  const cached = this.get(guildId);
6736
7654
  if (cached && !options?.force) return cached;
6737
7655
  try {
6738
- const data = await this.client.rest.get(import_types37.Routes.guild(guildId));
7656
+ const data = await this.client.rest.get(import_types43.Routes.guild(guildId));
6739
7657
  if (cached) {
6740
7658
  cached._patch(data);
6741
7659
  return cached;
@@ -6822,7 +7740,7 @@ var MessageCache = class {
6822
7740
 
6823
7741
  // src/ClientCore/UserManager.ts
6824
7742
  var import_collection14 = require("@fluxerjs/collection");
6825
- var import_types38 = require("@fluxerjs/types");
7743
+ var import_types44 = require("@fluxerjs/types");
6826
7744
  var soft = (p) => p.catch(() => null);
6827
7745
  var UserManager = class extends import_collection14.LimitedCollection {
6828
7746
  constructor(client) {
@@ -6846,7 +7764,7 @@ var UserManager = class extends import_collection14.LimitedCollection {
6846
7764
  async fetch(userId, options) {
6847
7765
  const cached = this.get(userId);
6848
7766
  if (cached && !options?.force) return cached;
6849
- const data = await this.client.rest.get(import_types38.Routes.user(userId));
7767
+ const data = await this.client.rest.get(import_types44.Routes.user(userId));
6850
7768
  return this.client.getOrCreateUser(data);
6851
7769
  }
6852
7770
  /** Return a cached user, otherwise {@link fetch}. */
@@ -6864,10 +7782,10 @@ var UserManager = class extends import_collection14.LimitedCollection {
6864
7782
  async fetchWithProfile(userId, options) {
6865
7783
  const guildId = options?.guildId ?? void 0;
6866
7784
  const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
6867
- this.client.rest.get(import_types38.Routes.user(userId)),
6868
- soft(this.client.rest.get(import_types38.Routes.userProfile(userId))),
6869
- guildId ? soft(this.client.rest.get(import_types38.Routes.userProfile(userId, guildId))) : null,
6870
- guildId ? soft(this.client.rest.get(import_types38.Routes.guildMember(guildId, userId))) : null
7785
+ this.client.rest.get(import_types44.Routes.user(userId)),
7786
+ soft(this.client.rest.get(import_types44.Routes.userProfile(userId))),
7787
+ guildId ? soft(this.client.rest.get(import_types44.Routes.userProfile(userId, guildId))) : null,
7788
+ guildId ? soft(this.client.rest.get(import_types44.Routes.guildMember(guildId, userId))) : null
6871
7789
  ]);
6872
7790
  const user = this.client.getOrCreateUser(userData);
6873
7791
  let member = null;
@@ -7213,7 +8131,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
7213
8131
  if (options.userIds !== void 0) data.user_ids = [...new Set(options.userIds)];
7214
8132
  if (options.presences !== void 0) data.presences = options.presences;
7215
8133
  if (options.nonce !== void 0) data.nonce = options.nonce;
7216
- this._sendToAllShards({ op: import_types39.GatewayOpcodes.RequestGuildMembers, d: data });
8134
+ this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestGuildMembers, d: data });
7217
8135
  }
7218
8136
  /**
7219
8137
  * Request guild member/online counts via gateway opcode 15.
@@ -7228,7 +8146,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
7228
8146
  }
7229
8147
  const data = { guild_ids: guildIds };
7230
8148
  if (options.nonce !== void 0) data.nonce = options.nonce;
7231
- this._sendToAllShards({ op: import_types39.GatewayOpcodes.RequestGuildCounts, d: data });
8149
+ this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestGuildCounts, d: data });
7232
8150
  }
7233
8151
  /**
7234
8152
  * Request per-channel member counts via gateway opcode 16.
@@ -7244,7 +8162,73 @@ var Client = class _Client extends import_node_events3.EventEmitter {
7244
8162
  if (options.channelId !== void 0) data.channel_id = options.channelId;
7245
8163
  if (options.channelIds !== void 0) data.channel_ids = [...new Set(options.channelIds)];
7246
8164
  if (options.nonce !== void 0) data.nonce = options.nonce;
7247
- this._sendToAllShards({ op: import_types39.GatewayOpcodes.RequestChannelMemberCounts, d: data });
8165
+ this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestChannelMemberCounts, d: data });
8166
+ }
8167
+ /**
8168
+ * Request unread counts for posts in one forum or media channel (opcode 28).
8169
+ * Listen for `forumUnreads`. The gateway keeps at most 40 posts and ignores a channel the session cannot view.
8170
+ */
8171
+ requestForumUnreads(options) {
8172
+ if (!options.guildId || !options.channelId) {
8173
+ throw new import_util4.FluxerError("requestForumUnreads requires guildId and channelId", {
8174
+ code: import_util3.ErrorCodes.InvalidGatewayRequest
8175
+ });
8176
+ }
8177
+ const threads = [];
8178
+ const seen = /* @__PURE__ */ new Set();
8179
+ for (const thread of options.threads) {
8180
+ if (!thread.threadId || seen.has(thread.threadId)) continue;
8181
+ seen.add(thread.threadId);
8182
+ const entry = { thread_id: thread.threadId };
8183
+ if (thread.ackMessageId !== void 0) entry.ack_message_id = thread.ackMessageId;
8184
+ threads.push(entry);
8185
+ }
8186
+ if (!threads.length) {
8187
+ throw new import_util4.FluxerError("requestForumUnreads requires at least one thread", {
8188
+ code: import_util3.ErrorCodes.InvalidGatewayRequest
8189
+ });
8190
+ }
8191
+ if (threads.length > 40) {
8192
+ throw new import_util4.FluxerError("requestForumUnreads accepts at most 40 threads", {
8193
+ code: import_util3.ErrorCodes.InvalidGatewayRequest
8194
+ });
8195
+ }
8196
+ const data = {
8197
+ guild_id: options.guildId,
8198
+ channel_id: options.channelId,
8199
+ threads
8200
+ };
8201
+ this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestForumUnreads, d: data });
8202
+ }
8203
+ /**
8204
+ * Subscribe to thread traffic in a guild (opcode 14).
8205
+ * `threads: true` receives every thread event in the guild.
8206
+ * `threadIds` (at most 10) subscribes to those member lists. Each one arrives as `threadMemberListUpdate`.
8207
+ */
8208
+ subscribeThreads(options) {
8209
+ if (!options.guildId) {
8210
+ throw new import_util4.FluxerError("subscribeThreads requires guildId", {
8211
+ code: import_util3.ErrorCodes.InvalidGatewayRequest
8212
+ });
8213
+ }
8214
+ if (options.threads === void 0 && options.threadIds === void 0) {
8215
+ throw new import_util4.FluxerError("subscribeThreads requires threads or threadIds", {
8216
+ code: import_util3.ErrorCodes.InvalidGatewayRequest
8217
+ });
8218
+ }
8219
+ const subscription = {};
8220
+ if (options.threads !== void 0) subscription.threads = options.threads;
8221
+ if (options.threadIds !== void 0) {
8222
+ const threadIds = [...new Set(options.threadIds.filter(Boolean))];
8223
+ if (threadIds.length > 10) {
8224
+ throw new import_util4.FluxerError("subscribeThreads accepts at most 10 threadIds", {
8225
+ code: import_util3.ErrorCodes.InvalidGatewayRequest
8226
+ });
8227
+ }
8228
+ subscription.thread_member_lists = threadIds;
8229
+ }
8230
+ const data = { subscriptions: { [options.guildId]: subscription } };
8231
+ this._sendToAllShards({ op: import_types45.GatewayOpcodes.LazyRequest, d: data });
7248
8232
  }
7249
8233
  /**
7250
8234
  * Broadcast a gateway payload to all shards.
@@ -7349,7 +8333,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
7349
8333
  * @see {@link Routes}
7350
8334
  */
7351
8335
  static get Routes() {
7352
- return import_types39.Routes;
8336
+ return import_types45.Routes;
7353
8337
  }
7354
8338
  };
7355
8339
 
@@ -7692,6 +8676,7 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
7692
8676
  // Annotate the CommonJS export names for ESM import in node:
7693
8677
  0 && (module.exports = {
7694
8678
  AllowedMentions,
8679
+ AnnouncementChannel,
7695
8680
  AttachmentBuilder,
7696
8681
  AttachmentMeta,
7697
8682
  AuditLogActionType,
@@ -7715,6 +8700,10 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
7715
8700
  ErrorCodes,
7716
8701
  Events,
7717
8702
  FluxerError,
8703
+ ForumChannel,
8704
+ ForumLayout,
8705
+ ForumSortOrder,
8706
+ ForumTagSetting,
7718
8707
  GatewayOpcodes,
7719
8708
  Guild,
7720
8709
  GuildBan,
@@ -7733,6 +8722,7 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
7733
8722
  Invite,
7734
8723
  InviteType,
7735
8724
  LinkChannel,
8725
+ MediaChannel,
7736
8726
  Message,
7737
8727
  MessageAttachmentFlags,
7738
8728
  MessageCollector,
@@ -7762,6 +8752,12 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
7762
8752
  SplashCardAlignment,
7763
8753
  SystemChannelFlags,
7764
8754
  TextChannel,
8755
+ ThreadAutoArchiveDuration,
8756
+ ThreadChannel,
8757
+ ThreadManager,
8758
+ ThreadMember,
8759
+ ThreadMemberFlags,
8760
+ ThreadMemberManager,
7765
8761
  User,
7766
8762
  UserFlagsBitField,
7767
8763
  UserFlagsBits,
@@ -7778,6 +8774,7 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
7778
8774
  cdnMemberBannerURL,
7779
8775
  cdnStickerURL,
7780
8776
  createLogger,
8777
+ fetchActiveThreads,
7781
8778
  instanceDiscoveryUrl,
7782
8779
  inviteUrl,
7783
8780
  normalizeApiOrigin,