@fluxerjs/core 3.3.0 → 3.4.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.
@@ -1,4 +1,4 @@
1
- export { a8 as Message, a9 as MessageAttachment, af as MessageEditOptions, ag as MessageEmbed, ah as MessageEmbedAuthor, ai as MessageEmbedField, aj as MessageEmbedFooter, ak as MessageEmbedMedia, at as MessageReference, ax as PartialMessage, aK as ReplyOptions } from './SubpathMessage-CNJlnR6y.mjs';
1
+ export { a8 as Message, a9 as MessageAttachment, af as MessageEditOptions, ag as MessageEmbed, ah as MessageEmbedAuthor, ai as MessageEmbedField, aj as MessageEmbedFooter, ak as MessageEmbedMedia, at as MessageReference, ax as PartialMessage, aK as ReplyOptions } from './SubpathMessage-BAwFSagN.mjs';
2
2
  export { $ as MessageSendOptions } from './Sudo-mzPLv6YU.mjs';
3
3
  import '@fluxerjs/types';
4
4
  import '@fluxerjs/collection';
package/dist/message.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { a8 as Message, a9 as MessageAttachment, af as MessageEditOptions, ag as MessageEmbed, ah as MessageEmbedAuthor, ai as MessageEmbedField, aj as MessageEmbedFooter, ak as MessageEmbedMedia, at as MessageReference, ax as PartialMessage, aK as ReplyOptions } from './SubpathMessage-DjLo6il5.js';
1
+ export { a8 as Message, a9 as MessageAttachment, af as MessageEditOptions, ag as MessageEmbed, ah as MessageEmbedAuthor, ai as MessageEmbedField, aj as MessageEmbedFooter, ak as MessageEmbedMedia, at as MessageReference, ax as PartialMessage, aK as ReplyOptions } from './SubpathMessage-Dq-1tI7E.js';
2
2
  export { $ as MessageSendOptions } from './Sudo-mzPLv6YU.js';
3
3
  import '@fluxerjs/types';
4
4
  import '@fluxerjs/collection';
package/dist/message.js CHANGED
@@ -496,6 +496,7 @@ var Events = {
496
496
  GuildEmojisUpdate: "guildEmojisUpdate",
497
497
  GuildStickersUpdate: "guildStickersUpdate",
498
498
  GuildCountsUpdate: "guildCountsUpdate",
499
+ GuildHealthUpdate: "guildHealthUpdate",
499
500
  ChannelMemberCountsUpdate: "channelMemberCountsUpdate",
500
501
  GuildMemberAdd: "guildMemberAdd",
501
502
  GuildMemberUpdate: "guildMemberUpdate",
@@ -530,6 +531,8 @@ var Events = {
530
531
  VoiceStateAck: "voiceStateAck",
531
532
  VoiceServerUpdate: "voiceServerUpdate",
532
533
  EntranceSoundPlay: "entranceSoundPlay",
534
+ VoiceSignal: "voiceSignal",
535
+ OperatorPassUpdate: "operatorPassUpdate",
533
536
  VoiceStatesSync: "voiceStatesSync",
534
537
  WebhooksUpdate: "webhooksUpdate",
535
538
  Resumed: "resumed",
@@ -659,6 +662,45 @@ var import_util3 = require("@fluxerjs/util");
659
662
  // src/ClientCore/MessageManager.ts
660
663
  var import_collection2 = require("@fluxerjs/collection");
661
664
  var import_types4 = require("@fluxerjs/types");
665
+
666
+ // src/ClientCore/Resolve.ts
667
+ function normalizeSnowflakeId(value, label) {
668
+ if (typeof value === "number" && !Number.isSafeInteger(value)) {
669
+ throw new TypeError(
670
+ `${label} received an unsafe numeric ID; pass snowflakes as strings to avoid precision loss`
671
+ );
672
+ }
673
+ const id = typeof value === "bigint" ? value.toString() : String(value ?? "").trim();
674
+ if (!id || id === "undefined" || id === "null" || id === "[object Object]") {
675
+ throw new TypeError(`${label} requires a non-empty ID`);
676
+ }
677
+ return id;
678
+ }
679
+ function assertApiObjectWithId(data, label) {
680
+ if (!data || typeof data !== "object" || typeof data.id !== "string" || data.id.length === 0) {
681
+ throw new TypeError(`${label} received an invalid API payload (missing string id)`);
682
+ }
683
+ return data;
684
+ }
685
+ function assertApiArray(data, label) {
686
+ if (!Array.isArray(data)) {
687
+ throw new TypeError(`${label} received an invalid API payload (expected an array)`);
688
+ }
689
+ return data;
690
+ }
691
+ async function dedupeFetch(pending, key, fn) {
692
+ const existing = pending.get(key);
693
+ if (existing) return existing;
694
+ const request = fn();
695
+ pending.set(key, request);
696
+ try {
697
+ return await request;
698
+ } finally {
699
+ if (pending.get(key) === request) pending.delete(key);
700
+ }
701
+ }
702
+
703
+ // src/ClientCore/MessageManager.ts
662
704
  var MessageManager = class {
663
705
  constructor(client, channelId) {
664
706
  this.client = client;
@@ -666,25 +708,32 @@ var MessageManager = class {
666
708
  }
667
709
  /** Structure cache keyed by message id (identity for {@link get}). */
668
710
  _structures = new import_collection2.Collection();
711
+ pendingFetches = /* @__PURE__ */ new Map();
669
712
  /** Retrieve a cached message by ID, or `undefined` if missing / caching disabled. */
670
713
  get(messageId) {
671
- const data = this.client._getMessageCache(this.channelId)?.get(messageId);
714
+ const id = String(messageId ?? "").trim();
715
+ if (!id) return void 0;
716
+ const data = this.client._getMessageCache(this.channelId)?.get(id);
672
717
  if (!data) {
673
- this._structures.delete(messageId);
718
+ this._structures.delete(id);
674
719
  return void 0;
675
720
  }
676
- const existing = this._structures.get(messageId);
677
- if (existing) return existing;
721
+ const existing = this._structures.get(id);
722
+ if (existing) {
723
+ existing._patch(data);
724
+ return existing;
725
+ }
678
726
  const message = new Message(this.client, data);
679
- this._structures.set(messageId, message);
727
+ this._structures.set(id, message);
680
728
  return message;
681
729
  }
682
730
  /** Retrieve from cache, otherwise {@link fetch}. */
683
731
  async resolve(messageId) {
684
- return this.get(messageId) ?? this.fetch(messageId);
732
+ const id = normalizeSnowflakeId(messageId, "messages.resolve()");
733
+ return this.get(id) ?? this.fetch(id);
685
734
  }
686
735
  async fetch(idOrOptions) {
687
- return typeof idOrOptions === "string" ? this.fetchOne(idOrOptions) : this.fetchMany(idOrOptions);
736
+ return typeof idOrOptions === "string" || typeof idOrOptions === "number" ? this.fetchOne(normalizeSnowflakeId(idOrOptions, "messages.fetch()")) : this.fetchMany(idOrOptions);
688
737
  }
689
738
  /** Cache API data and return a {@link Message} (reusing identity when present). */
690
739
  wrap(data) {
@@ -701,9 +750,13 @@ var MessageManager = class {
701
750
  }
702
751
  /** Fetch a single message from the API. */
703
752
  async fetchOne(messageId) {
753
+ return dedupeFetch(this.pendingFetches, messageId, async () => this.fetchOneFresh(messageId));
754
+ }
755
+ async fetchOneFresh(messageId) {
704
756
  try {
705
- const data = await this.client.rest.get(
706
- import_types4.Routes.channelMessage(this.channelId, messageId)
757
+ const data = assertApiObjectWithId(
758
+ await this.client.rest.get(import_types4.Routes.channelMessage(this.channelId, messageId)),
759
+ "messages.fetch()"
707
760
  );
708
761
  return this.wrap(data);
709
762
  } catch (err) {
@@ -729,9 +782,15 @@ var MessageManager = class {
729
782
  if (value != null && value !== "") qs.set(key, String(value));
730
783
  }
731
784
  const base = import_types4.Routes.channelMessages(this.channelId);
732
- const data = await this.client.rest.get(qs.size > 0 ? `${base}?${qs}` : base);
785
+ const data = assertApiArray(
786
+ await this.client.rest.get(qs.size > 0 ? `${base}?${qs}` : base),
787
+ "messages.fetch()"
788
+ );
733
789
  const collection = new import_collection2.Collection();
734
- for (const msg of data) collection.set(msg.id, this.wrap(msg));
790
+ for (const msg of data) {
791
+ if (!msg?.id) continue;
792
+ collection.set(msg.id, this.wrap(msg));
793
+ }
735
794
  return collection;
736
795
  }
737
796
  };
@@ -935,6 +994,9 @@ async function uploadAttachmentsForSend(client, channelId, files) {
935
994
  }
936
995
 
937
996
  // src/Domain/Channel/Base.ts
997
+ function isFullChannelData(data) {
998
+ return "guild_id" in data || "permission_overwrites" in data || "position" in data || "last_message_id" in data || "topic" in data || "thread_metadata" in data || "available_tags" in data;
999
+ }
938
1000
  var Channel = class extends Base {
939
1001
  #messages;
940
1002
  /** The {@link Client} that instantiated this channel. */
@@ -949,6 +1011,11 @@ var Channel = class extends Base {
949
1011
  icon;
950
1012
  /** ISO8601 timestamp of the last pinned message update. */
951
1013
  lastPinTimestamp;
1014
+ /**
1015
+ * True when built from a partial payload (e.g. a DM stub) and not yet hydrated
1016
+ * with a full channel object. `channels.resolve()` refetches partial channels.
1017
+ */
1018
+ partial;
952
1019
  constructor(client, data) {
953
1020
  super();
954
1021
  this.client = client;
@@ -957,6 +1024,7 @@ var Channel = class extends Base {
957
1024
  this.name = data.name ?? null;
958
1025
  this.icon = data.icon ?? null;
959
1026
  this.lastPinTimestamp = data.last_pin_timestamp ?? null;
1027
+ this.partial = !isFullChannelData(data);
960
1028
  }
961
1029
  /** Unix timestamp (ms) when this channel was created, derived from its snowflake ID. */
962
1030
  get createdTimestamp() {
@@ -977,6 +1045,7 @@ var Channel = class extends Base {
977
1045
  if ("last_pin_timestamp" in data && data.last_pin_timestamp !== void 0) {
978
1046
  this.lastPinTimestamp = data.last_pin_timestamp ?? null;
979
1047
  }
1048
+ if (isFullChannelData(data)) this.partial = false;
980
1049
  }
981
1050
  /** @internal Factory wired after subclasses load. */
982
1051
  static from(_c, _d) {
@@ -1704,10 +1773,10 @@ var Message = class _Message extends Base {
1704
1773
  this.channelId = data.channel_id;
1705
1774
  this.guildId = data.guild_id ?? null;
1706
1775
  this.author = client.getOrCreateUser(data.author);
1707
- this.content = data.content;
1708
- this.createdAt = new Date(data.timestamp);
1776
+ this.content = data.content ?? "";
1777
+ this.createdAt = data.timestamp ? new Date(data.timestamp) : /* @__PURE__ */ new Date(0);
1709
1778
  this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
1710
- this.pinned = data.pinned;
1779
+ this.pinned = data.pinned ?? false;
1711
1780
  this.attachments = new import_collection5.Collection();
1712
1781
  for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
1713
1782
  this.type = data.type ?? import_types9.MessageType.Default;
@@ -1739,33 +1808,47 @@ var Message = class _Message extends Base {
1739
1808
  * @internal
1740
1809
  */
1741
1810
  _patch(data) {
1742
- this.content = data.content;
1743
- this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
1744
- this.pinned = data.pinned;
1745
- this.attachments.clear();
1746
- for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
1747
- this.flags = new import_util5.MessageFlagsBitField(BigInt(data.flags ?? 0));
1748
- this.mentionEveryone = data.mention_everyone ?? false;
1749
- this.tts = data.tts ?? false;
1750
- this.embeds = (data.embeds ?? []).map(toMessageEmbed);
1751
- this.stickers = (data.stickers ?? []).map((s) => new MessageSticker(this.client, s));
1752
- this.reactions._patch(data.reactions);
1753
- this.messageReference = data.message_reference ? {
1754
- channelId: data.message_reference.channel_id,
1755
- messageId: data.message_reference.message_id,
1756
- guildId: data.message_reference.guild_id ?? null,
1757
- ...data.message_reference.type !== void 0 ? { type: data.message_reference.type } : {}
1758
- } : null;
1759
- this.messageSnapshots = (data.message_snapshots ?? []).map(
1760
- (s) => toMessageSnapshot(this.client, s)
1761
- );
1762
- this.call = data.call ? toMessageCall(data.call) : null;
1763
- this.referencedMessage = data.referenced_message ? new _Message(this.client, data.referenced_message) : null;
1764
- this.webhookId = data.webhook_id ?? null;
1765
- this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
1766
- this.mentionRoles = data.mention_roles ?? [];
1767
- this.nonce = data.nonce ?? null;
1768
- this.nsfwEmojis = data.nsfw_emojis ?? [];
1811
+ if (data.content !== void 0) this.content = data.content ?? "";
1812
+ if (data.edited_timestamp !== void 0) {
1813
+ this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
1814
+ }
1815
+ if (data.pinned !== void 0) this.pinned = data.pinned;
1816
+ if (data.attachments !== void 0) {
1817
+ this.attachments.clear();
1818
+ for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
1819
+ }
1820
+ if (data.flags !== void 0) this.flags = new import_util5.MessageFlagsBitField(BigInt(data.flags ?? 0));
1821
+ if (data.mention_everyone !== void 0) this.mentionEveryone = data.mention_everyone;
1822
+ if (data.tts !== void 0) this.tts = data.tts;
1823
+ if (data.embeds !== void 0) this.embeds = (data.embeds ?? []).map(toMessageEmbed);
1824
+ if (data.stickers !== void 0) {
1825
+ this.stickers = (data.stickers ?? []).map((s) => new MessageSticker(this.client, s));
1826
+ }
1827
+ if (data.reactions !== void 0) this.reactions._patch(data.reactions);
1828
+ if (data.message_reference !== void 0) {
1829
+ this.messageReference = data.message_reference ? {
1830
+ channelId: data.message_reference.channel_id,
1831
+ messageId: data.message_reference.message_id,
1832
+ guildId: data.message_reference.guild_id ?? null,
1833
+ ...data.message_reference.type !== void 0 ? { type: data.message_reference.type } : {}
1834
+ } : null;
1835
+ }
1836
+ if (data.message_snapshots !== void 0) {
1837
+ this.messageSnapshots = (data.message_snapshots ?? []).map(
1838
+ (s) => toMessageSnapshot(this.client, s)
1839
+ );
1840
+ }
1841
+ if (data.call !== void 0) this.call = data.call ? toMessageCall(data.call) : null;
1842
+ if (data.referenced_message !== void 0) {
1843
+ this.referencedMessage = data.referenced_message ? new _Message(this.client, data.referenced_message) : null;
1844
+ }
1845
+ if (data.webhook_id !== void 0) this.webhookId = data.webhook_id ?? null;
1846
+ if (data.mentions !== void 0) {
1847
+ this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
1848
+ }
1849
+ if (data.mention_roles !== void 0) this.mentionRoles = data.mention_roles ?? [];
1850
+ if (data.nonce !== void 0) this.nonce = data.nonce ?? null;
1851
+ if (data.nsfw_emojis !== void 0) this.nsfwEmojis = data.nsfw_emojis ?? [];
1769
1852
  if (data.thread) this.thread = cacheThread(this.client, data.thread);
1770
1853
  }
1771
1854
  /**
@@ -1866,6 +1949,23 @@ var Message = class _Message extends Base {
1866
1949
  async fetch() {
1867
1950
  return this.client.channels.fetchMessage(this.channelId, this.id);
1868
1951
  }
1952
+ /** Publish this announcement message to channels following its channel. */
1953
+ async crosspost() {
1954
+ const data = await this.client.rest.post(
1955
+ import_types9.Routes.channelMessageCrosspost(this.channelId, this.id),
1956
+ { auth: true }
1957
+ );
1958
+ const published = new _Message(this.client, data);
1959
+ this.client._addMessageToCache(this.channelId, data);
1960
+ return published;
1961
+ }
1962
+ /** Fetch the source guild of a crossposted (followed-channel) message. */
1963
+ async fetchCrosspostSource() {
1964
+ return this.client.rest.get(
1965
+ import_types9.Routes.channelMessageCrosspostSource(this.channelId, this.id),
1966
+ { auth: true }
1967
+ );
1968
+ }
1869
1969
  /** Delete this message. */
1870
1970
  async delete(reason) {
1871
1971
  await this.client.rest.delete(import_types9.Routes.channelMessage(this.channelId, this.id), {
package/dist/message.mjs CHANGED
@@ -474,6 +474,7 @@ var Events = {
474
474
  GuildEmojisUpdate: "guildEmojisUpdate",
475
475
  GuildStickersUpdate: "guildStickersUpdate",
476
476
  GuildCountsUpdate: "guildCountsUpdate",
477
+ GuildHealthUpdate: "guildHealthUpdate",
477
478
  ChannelMemberCountsUpdate: "channelMemberCountsUpdate",
478
479
  GuildMemberAdd: "guildMemberAdd",
479
480
  GuildMemberUpdate: "guildMemberUpdate",
@@ -508,6 +509,8 @@ var Events = {
508
509
  VoiceStateAck: "voiceStateAck",
509
510
  VoiceServerUpdate: "voiceServerUpdate",
510
511
  EntranceSoundPlay: "entranceSoundPlay",
512
+ VoiceSignal: "voiceSignal",
513
+ OperatorPassUpdate: "operatorPassUpdate",
511
514
  VoiceStatesSync: "voiceStatesSync",
512
515
  WebhooksUpdate: "webhooksUpdate",
513
516
  Resumed: "resumed",
@@ -637,6 +640,45 @@ import { SnowflakeUtil } from "@fluxerjs/util";
637
640
  // src/ClientCore/MessageManager.ts
638
641
  import { Collection as Collection2 } from "@fluxerjs/collection";
639
642
  import { Routes as Routes2 } from "@fluxerjs/types";
643
+
644
+ // src/ClientCore/Resolve.ts
645
+ function normalizeSnowflakeId(value, label) {
646
+ if (typeof value === "number" && !Number.isSafeInteger(value)) {
647
+ throw new TypeError(
648
+ `${label} received an unsafe numeric ID; pass snowflakes as strings to avoid precision loss`
649
+ );
650
+ }
651
+ const id = typeof value === "bigint" ? value.toString() : String(value ?? "").trim();
652
+ if (!id || id === "undefined" || id === "null" || id === "[object Object]") {
653
+ throw new TypeError(`${label} requires a non-empty ID`);
654
+ }
655
+ return id;
656
+ }
657
+ function assertApiObjectWithId(data, label) {
658
+ if (!data || typeof data !== "object" || typeof data.id !== "string" || data.id.length === 0) {
659
+ throw new TypeError(`${label} received an invalid API payload (missing string id)`);
660
+ }
661
+ return data;
662
+ }
663
+ function assertApiArray(data, label) {
664
+ if (!Array.isArray(data)) {
665
+ throw new TypeError(`${label} received an invalid API payload (expected an array)`);
666
+ }
667
+ return data;
668
+ }
669
+ async function dedupeFetch(pending, key, fn) {
670
+ const existing = pending.get(key);
671
+ if (existing) return existing;
672
+ const request = fn();
673
+ pending.set(key, request);
674
+ try {
675
+ return await request;
676
+ } finally {
677
+ if (pending.get(key) === request) pending.delete(key);
678
+ }
679
+ }
680
+
681
+ // src/ClientCore/MessageManager.ts
640
682
  var MessageManager = class {
641
683
  constructor(client, channelId) {
642
684
  this.client = client;
@@ -644,25 +686,32 @@ var MessageManager = class {
644
686
  }
645
687
  /** Structure cache keyed by message id (identity for {@link get}). */
646
688
  _structures = new Collection2();
689
+ pendingFetches = /* @__PURE__ */ new Map();
647
690
  /** Retrieve a cached message by ID, or `undefined` if missing / caching disabled. */
648
691
  get(messageId) {
649
- const data = this.client._getMessageCache(this.channelId)?.get(messageId);
692
+ const id = String(messageId ?? "").trim();
693
+ if (!id) return void 0;
694
+ const data = this.client._getMessageCache(this.channelId)?.get(id);
650
695
  if (!data) {
651
- this._structures.delete(messageId);
696
+ this._structures.delete(id);
652
697
  return void 0;
653
698
  }
654
- const existing = this._structures.get(messageId);
655
- if (existing) return existing;
699
+ const existing = this._structures.get(id);
700
+ if (existing) {
701
+ existing._patch(data);
702
+ return existing;
703
+ }
656
704
  const message = new Message(this.client, data);
657
- this._structures.set(messageId, message);
705
+ this._structures.set(id, message);
658
706
  return message;
659
707
  }
660
708
  /** Retrieve from cache, otherwise {@link fetch}. */
661
709
  async resolve(messageId) {
662
- return this.get(messageId) ?? this.fetch(messageId);
710
+ const id = normalizeSnowflakeId(messageId, "messages.resolve()");
711
+ return this.get(id) ?? this.fetch(id);
663
712
  }
664
713
  async fetch(idOrOptions) {
665
- return typeof idOrOptions === "string" ? this.fetchOne(idOrOptions) : this.fetchMany(idOrOptions);
714
+ return typeof idOrOptions === "string" || typeof idOrOptions === "number" ? this.fetchOne(normalizeSnowflakeId(idOrOptions, "messages.fetch()")) : this.fetchMany(idOrOptions);
666
715
  }
667
716
  /** Cache API data and return a {@link Message} (reusing identity when present). */
668
717
  wrap(data) {
@@ -679,9 +728,13 @@ var MessageManager = class {
679
728
  }
680
729
  /** Fetch a single message from the API. */
681
730
  async fetchOne(messageId) {
731
+ return dedupeFetch(this.pendingFetches, messageId, async () => this.fetchOneFresh(messageId));
732
+ }
733
+ async fetchOneFresh(messageId) {
682
734
  try {
683
- const data = await this.client.rest.get(
684
- Routes2.channelMessage(this.channelId, messageId)
735
+ const data = assertApiObjectWithId(
736
+ await this.client.rest.get(Routes2.channelMessage(this.channelId, messageId)),
737
+ "messages.fetch()"
685
738
  );
686
739
  return this.wrap(data);
687
740
  } catch (err) {
@@ -707,9 +760,15 @@ var MessageManager = class {
707
760
  if (value != null && value !== "") qs.set(key, String(value));
708
761
  }
709
762
  const base = Routes2.channelMessages(this.channelId);
710
- const data = await this.client.rest.get(qs.size > 0 ? `${base}?${qs}` : base);
763
+ const data = assertApiArray(
764
+ await this.client.rest.get(qs.size > 0 ? `${base}?${qs}` : base),
765
+ "messages.fetch()"
766
+ );
711
767
  const collection = new Collection2();
712
- for (const msg of data) collection.set(msg.id, this.wrap(msg));
768
+ for (const msg of data) {
769
+ if (!msg?.id) continue;
770
+ collection.set(msg.id, this.wrap(msg));
771
+ }
713
772
  return collection;
714
773
  }
715
774
  };
@@ -913,6 +972,9 @@ async function uploadAttachmentsForSend(client, channelId, files) {
913
972
  }
914
973
 
915
974
  // src/Domain/Channel/Base.ts
975
+ function isFullChannelData(data) {
976
+ return "guild_id" in data || "permission_overwrites" in data || "position" in data || "last_message_id" in data || "topic" in data || "thread_metadata" in data || "available_tags" in data;
977
+ }
916
978
  var Channel = class extends Base {
917
979
  #messages;
918
980
  /** The {@link Client} that instantiated this channel. */
@@ -927,6 +989,11 @@ var Channel = class extends Base {
927
989
  icon;
928
990
  /** ISO8601 timestamp of the last pinned message update. */
929
991
  lastPinTimestamp;
992
+ /**
993
+ * True when built from a partial payload (e.g. a DM stub) and not yet hydrated
994
+ * with a full channel object. `channels.resolve()` refetches partial channels.
995
+ */
996
+ partial;
930
997
  constructor(client, data) {
931
998
  super();
932
999
  this.client = client;
@@ -935,6 +1002,7 @@ var Channel = class extends Base {
935
1002
  this.name = data.name ?? null;
936
1003
  this.icon = data.icon ?? null;
937
1004
  this.lastPinTimestamp = data.last_pin_timestamp ?? null;
1005
+ this.partial = !isFullChannelData(data);
938
1006
  }
939
1007
  /** Unix timestamp (ms) when this channel was created, derived from its snowflake ID. */
940
1008
  get createdTimestamp() {
@@ -955,6 +1023,7 @@ var Channel = class extends Base {
955
1023
  if ("last_pin_timestamp" in data && data.last_pin_timestamp !== void 0) {
956
1024
  this.lastPinTimestamp = data.last_pin_timestamp ?? null;
957
1025
  }
1026
+ if (isFullChannelData(data)) this.partial = false;
958
1027
  }
959
1028
  /** @internal Factory wired after subclasses load. */
960
1029
  static from(_c, _d) {
@@ -1682,10 +1751,10 @@ var Message = class _Message extends Base {
1682
1751
  this.channelId = data.channel_id;
1683
1752
  this.guildId = data.guild_id ?? null;
1684
1753
  this.author = client.getOrCreateUser(data.author);
1685
- this.content = data.content;
1686
- this.createdAt = new Date(data.timestamp);
1754
+ this.content = data.content ?? "";
1755
+ this.createdAt = data.timestamp ? new Date(data.timestamp) : /* @__PURE__ */ new Date(0);
1687
1756
  this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
1688
- this.pinned = data.pinned;
1757
+ this.pinned = data.pinned ?? false;
1689
1758
  this.attachments = new Collection5();
1690
1759
  for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
1691
1760
  this.type = data.type ?? MessageType.Default;
@@ -1717,33 +1786,47 @@ var Message = class _Message extends Base {
1717
1786
  * @internal
1718
1787
  */
1719
1788
  _patch(data) {
1720
- this.content = data.content;
1721
- this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
1722
- this.pinned = data.pinned;
1723
- this.attachments.clear();
1724
- for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
1725
- this.flags = new MessageFlagsBitField(BigInt(data.flags ?? 0));
1726
- this.mentionEveryone = data.mention_everyone ?? false;
1727
- this.tts = data.tts ?? false;
1728
- this.embeds = (data.embeds ?? []).map(toMessageEmbed);
1729
- this.stickers = (data.stickers ?? []).map((s) => new MessageSticker(this.client, s));
1730
- this.reactions._patch(data.reactions);
1731
- this.messageReference = data.message_reference ? {
1732
- channelId: data.message_reference.channel_id,
1733
- messageId: data.message_reference.message_id,
1734
- guildId: data.message_reference.guild_id ?? null,
1735
- ...data.message_reference.type !== void 0 ? { type: data.message_reference.type } : {}
1736
- } : null;
1737
- this.messageSnapshots = (data.message_snapshots ?? []).map(
1738
- (s) => toMessageSnapshot(this.client, s)
1739
- );
1740
- this.call = data.call ? toMessageCall(data.call) : null;
1741
- this.referencedMessage = data.referenced_message ? new _Message(this.client, data.referenced_message) : null;
1742
- this.webhookId = data.webhook_id ?? null;
1743
- this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
1744
- this.mentionRoles = data.mention_roles ?? [];
1745
- this.nonce = data.nonce ?? null;
1746
- this.nsfwEmojis = data.nsfw_emojis ?? [];
1789
+ if (data.content !== void 0) this.content = data.content ?? "";
1790
+ if (data.edited_timestamp !== void 0) {
1791
+ this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
1792
+ }
1793
+ if (data.pinned !== void 0) this.pinned = data.pinned;
1794
+ if (data.attachments !== void 0) {
1795
+ this.attachments.clear();
1796
+ for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
1797
+ }
1798
+ if (data.flags !== void 0) this.flags = new MessageFlagsBitField(BigInt(data.flags ?? 0));
1799
+ if (data.mention_everyone !== void 0) this.mentionEveryone = data.mention_everyone;
1800
+ if (data.tts !== void 0) this.tts = data.tts;
1801
+ if (data.embeds !== void 0) this.embeds = (data.embeds ?? []).map(toMessageEmbed);
1802
+ if (data.stickers !== void 0) {
1803
+ this.stickers = (data.stickers ?? []).map((s) => new MessageSticker(this.client, s));
1804
+ }
1805
+ if (data.reactions !== void 0) this.reactions._patch(data.reactions);
1806
+ if (data.message_reference !== void 0) {
1807
+ this.messageReference = data.message_reference ? {
1808
+ channelId: data.message_reference.channel_id,
1809
+ messageId: data.message_reference.message_id,
1810
+ guildId: data.message_reference.guild_id ?? null,
1811
+ ...data.message_reference.type !== void 0 ? { type: data.message_reference.type } : {}
1812
+ } : null;
1813
+ }
1814
+ if (data.message_snapshots !== void 0) {
1815
+ this.messageSnapshots = (data.message_snapshots ?? []).map(
1816
+ (s) => toMessageSnapshot(this.client, s)
1817
+ );
1818
+ }
1819
+ if (data.call !== void 0) this.call = data.call ? toMessageCall(data.call) : null;
1820
+ if (data.referenced_message !== void 0) {
1821
+ this.referencedMessage = data.referenced_message ? new _Message(this.client, data.referenced_message) : null;
1822
+ }
1823
+ if (data.webhook_id !== void 0) this.webhookId = data.webhook_id ?? null;
1824
+ if (data.mentions !== void 0) {
1825
+ this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
1826
+ }
1827
+ if (data.mention_roles !== void 0) this.mentionRoles = data.mention_roles ?? [];
1828
+ if (data.nonce !== void 0) this.nonce = data.nonce ?? null;
1829
+ if (data.nsfw_emojis !== void 0) this.nsfwEmojis = data.nsfw_emojis ?? [];
1747
1830
  if (data.thread) this.thread = cacheThread(this.client, data.thread);
1748
1831
  }
1749
1832
  /**
@@ -1844,6 +1927,23 @@ var Message = class _Message extends Base {
1844
1927
  async fetch() {
1845
1928
  return this.client.channels.fetchMessage(this.channelId, this.id);
1846
1929
  }
1930
+ /** Publish this announcement message to channels following its channel. */
1931
+ async crosspost() {
1932
+ const data = await this.client.rest.post(
1933
+ Routes7.channelMessageCrosspost(this.channelId, this.id),
1934
+ { auth: true }
1935
+ );
1936
+ const published = new _Message(this.client, data);
1937
+ this.client._addMessageToCache(this.channelId, data);
1938
+ return published;
1939
+ }
1940
+ /** Fetch the source guild of a crossposted (followed-channel) message. */
1941
+ async fetchCrosspostSource() {
1942
+ return this.client.rest.get(
1943
+ Routes7.channelMessageCrosspostSource(this.channelId, this.id),
1944
+ { auth: true }
1945
+ );
1946
+ }
1847
1947
  /** Delete this message. */
1848
1948
  async delete(reason) {
1849
1949
  await this.client.rest.delete(Routes7.channelMessage(this.channelId, this.id), {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.3.0",
6
+ "version": "3.4.0",
7
7
  "description": "A fully-featured SDK for Fluxer bots",
8
8
  "repository": {
9
9
  "type": "git",
@@ -59,12 +59,12 @@
59
59
  "dist"
60
60
  ],
61
61
  "dependencies": {
62
- "@fluxerjs/ws": "3.1.0",
63
- "@fluxerjs/builders": "3.0.0",
64
- "@fluxerjs/types": "3.3.0",
65
- "@fluxerjs/collection": "3.0.0",
66
- "@fluxerjs/util": "3.1.0",
67
- "@fluxerjs/rest": "3.1.0"
62
+ "@fluxerjs/rest": "3.4.0",
63
+ "@fluxerjs/builders": "3.4.0",
64
+ "@fluxerjs/ws": "3.4.0",
65
+ "@fluxerjs/util": "3.4.0",
66
+ "@fluxerjs/types": "3.4.0",
67
+ "@fluxerjs/collection": "3.4.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/node": "^20.0.0",