@fluxerjs/core 3.0.0 → 3.2.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,5 +1,5 @@
1
- import { R as RoleCreateOptions, a as RoleEditOptions } from './Sudo-CFfbmis3.mjs';
2
- export { t as toAttachmentUploadCompleteBody, b as toAttachmentUploadPlanBody, c as toAttachmentUploadPlanResponse, d as toBulkFetchWire, e as toChannelCreateBody, f as toChannelEditBody, g as toChannelInviteBody, h as toDiscoveryApplicationPayload, i as toDiscoveryBody, j as toDiscoveryStatusPayload, k as toGroupDmEditBody, l as toMemberEditBody, m as toMemberSearchBody, n as toMessageAttachmentEditWire, o as toMessageSearchBody, p as toMessageSearchResponse, q as toPresenceWire, r as toProfilePayload, s as toSudoBody } from './Sudo-CFfbmis3.mjs';
1
+ import { R as RoleCreateOptions, a as RoleEditOptions } from './Sudo-DwxTf-jj.mjs';
2
+ export { t as toAttachmentUploadCompleteBody, b as toAttachmentUploadPlanBody, c as toAttachmentUploadPlanResponse, d as toBulkFetchWire, e as toChannelCreateBody, f as toChannelEditBody, g as toChannelInviteBody, h as toDiscoveryApplicationPayload, i as toDiscoveryBody, j as toDiscoveryStatusPayload, k as toGroupDmEditBody, l as toMemberEditBody, m as toMemberSearchBody, n as toMessageAttachmentEditWire, o as toMessageSearchBody, p as toMessageSearchResponse, q as toPresenceWire, r as toProfilePayload, s as toSudoBody } from './Sudo-DwxTf-jj.mjs';
3
3
  export { t as toEmojiCreateBody, a as toEmojiEditBody, b as toStickerCreateBody, c as toStickerEditBody } from './Expressions-Bdgo72qI.mjs';
4
4
  import '@fluxerjs/types';
5
5
  import '@fluxerjs/util';
@@ -1,5 +1,5 @@
1
- import { R as RoleCreateOptions, a as RoleEditOptions } from './Sudo-CFfbmis3.js';
2
- export { t as toAttachmentUploadCompleteBody, b as toAttachmentUploadPlanBody, c as toAttachmentUploadPlanResponse, d as toBulkFetchWire, e as toChannelCreateBody, f as toChannelEditBody, g as toChannelInviteBody, h as toDiscoveryApplicationPayload, i as toDiscoveryBody, j as toDiscoveryStatusPayload, k as toGroupDmEditBody, l as toMemberEditBody, m as toMemberSearchBody, n as toMessageAttachmentEditWire, o as toMessageSearchBody, p as toMessageSearchResponse, q as toPresenceWire, r as toProfilePayload, s as toSudoBody } from './Sudo-CFfbmis3.js';
1
+ import { R as RoleCreateOptions, a as RoleEditOptions } from './Sudo-DwxTf-jj.js';
2
+ export { t as toAttachmentUploadCompleteBody, b as toAttachmentUploadPlanBody, c as toAttachmentUploadPlanResponse, d as toBulkFetchWire, e as toChannelCreateBody, f as toChannelEditBody, g as toChannelInviteBody, h as toDiscoveryApplicationPayload, i as toDiscoveryBody, j as toDiscoveryStatusPayload, k as toGroupDmEditBody, l as toMemberEditBody, m as toMemberSearchBody, n as toMessageAttachmentEditWire, o as toMessageSearchBody, p as toMessageSearchResponse, q as toPresenceWire, r as toProfilePayload, s as toSudoBody } from './Sudo-DwxTf-jj.js';
3
3
  export { t as toEmojiCreateBody, a as toEmojiEditBody, b as toStickerCreateBody, c as toStickerEditBody } from './Expressions-Bdgo72qI.js';
4
4
  import '@fluxerjs/types';
5
5
  import '@fluxerjs/util';
package/dist/internal.js CHANGED
@@ -124,6 +124,7 @@ function toOverwriteWire(overwrite) {
124
124
  }
125
125
  function toChannelEditBody(options) {
126
126
  const body = {};
127
+ if (options.type !== void 0) body.type = options.type;
127
128
  if (options.name !== void 0) body.name = options.name;
128
129
  if (options.topic !== void 0) body.topic = options.topic;
129
130
  if (options.url !== void 0) body.url = options.url;
package/dist/internal.mjs CHANGED
@@ -74,6 +74,7 @@ function toOverwriteWire(overwrite) {
74
74
  }
75
75
  function toChannelEditBody(options) {
76
76
  const body = {};
77
+ if (options.type !== void 0) body.type = options.type;
77
78
  if (options.name !== void 0) body.name = options.name;
78
79
  if (options.topic !== void 0) body.topic = options.topic;
79
80
  if (options.url !== void 0) body.url = options.url;
@@ -1,9 +1,9 @@
1
- export { a3 as Message, a4 as MessageAttachment, aa as MessageEditOptions, ab as MessageEmbed, ac as MessageEmbedAuthor, ad as MessageEmbedField, ae as MessageEmbedFooter, af as MessageEmbedMedia, ap as MessageReference, ar as MessageSendOptions, av as PartialMessage, aI as ReplyOptions } from './SubpathMessage-CjQBbVmb.mjs';
1
+ export { a5 as Message, a6 as MessageAttachment, ac as MessageEditOptions, ad as MessageEmbed, ae as MessageEmbedAuthor, af as MessageEmbedField, ag as MessageEmbedFooter, ah as MessageEmbedMedia, ar as MessageReference, at as MessageSendOptions, ax as PartialMessage, aK as ReplyOptions } from './SubpathMessage-DW9TgPNl.mjs';
2
2
  import '@fluxerjs/types';
3
3
  import '@fluxerjs/collection';
4
4
  import '@fluxerjs/util';
5
5
  import 'node:events';
6
6
  import '@fluxerjs/rest';
7
7
  import '@fluxerjs/ws';
8
- import './Sudo-CFfbmis3.mjs';
8
+ import './Sudo-DwxTf-jj.mjs';
9
9
  import '@fluxerjs/builders';
package/dist/message.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { a3 as Message, a4 as MessageAttachment, aa as MessageEditOptions, ab as MessageEmbed, ac as MessageEmbedAuthor, ad as MessageEmbedField, ae as MessageEmbedFooter, af as MessageEmbedMedia, ap as MessageReference, ar as MessageSendOptions, av as PartialMessage, aI as ReplyOptions } from './SubpathMessage-DNlKq2Nj.js';
1
+ export { a5 as Message, a6 as MessageAttachment, ac as MessageEditOptions, ad as MessageEmbed, ae as MessageEmbedAuthor, af as MessageEmbedField, ag as MessageEmbedFooter, ah as MessageEmbedMedia, ar as MessageReference, at as MessageSendOptions, ax as PartialMessage, aK as ReplyOptions } from './SubpathMessage-DHo7ltTz.js';
2
2
  import '@fluxerjs/types';
3
3
  import '@fluxerjs/collection';
4
4
  import '@fluxerjs/util';
5
5
  import 'node:events';
6
6
  import '@fluxerjs/rest';
7
7
  import '@fluxerjs/ws';
8
- import './Sudo-CFfbmis3.js';
8
+ import './Sudo-DwxTf-jj.js';
9
9
  import '@fluxerjs/builders';
package/dist/message.js CHANGED
@@ -46,6 +46,13 @@ function toMessageAttachmentEditWire(attachments) {
46
46
  });
47
47
  }
48
48
 
49
+ // src/Helpers/AuditReason.ts
50
+ var AUDIT_LOG_REASON_HEADER = "X-Audit-Log-Reason";
51
+ function auditReasonHeaders(reason) {
52
+ if (reason == null || reason === "") return {};
53
+ return { headers: { [AUDIT_LOG_REASON_HEADER]: encodeURIComponent(reason) } };
54
+ }
55
+
49
56
  // src/Helpers/MessageUtils/Body.ts
50
57
  var import_builders = require("@fluxerjs/builders");
51
58
  var import_types = require("@fluxerjs/types");
@@ -684,12 +691,79 @@ var import_rest2 = require("@fluxerjs/rest");
684
691
  var CDN_URL = "https://fluxerusercontent.com";
685
692
 
686
693
  // src/Helpers/Cdn.ts
694
+ var CDN_SIZE_LADDER = [
695
+ 16,
696
+ 20,
697
+ 22,
698
+ 24,
699
+ 28,
700
+ 32,
701
+ 40,
702
+ 44,
703
+ 48,
704
+ 56,
705
+ 60,
706
+ 64,
707
+ 80,
708
+ 96,
709
+ 100,
710
+ 128,
711
+ 160,
712
+ 240,
713
+ 256,
714
+ 300,
715
+ 320,
716
+ 480,
717
+ 512,
718
+ 600,
719
+ 640,
720
+ 1024,
721
+ 1280,
722
+ 1536,
723
+ 2048,
724
+ 3072,
725
+ 4096,
726
+ 8192,
727
+ 16384
728
+ ];
729
+ var CDN_ASSET_CLASS_RANGE = {
730
+ icon: { min: 128, max: 1024 },
731
+ banner: { min: 480, max: 2400 },
732
+ emoji: { min: 32, max: 512 },
733
+ sticker: { min: 128, max: 512 }
734
+ };
735
+ function nearestSize(requested, candidates) {
736
+ let best = candidates[0];
737
+ let bestDist = Math.abs(requested - best);
738
+ for (let i = 1; i < candidates.length; i++) {
739
+ const step = candidates[i];
740
+ const dist = Math.abs(requested - step);
741
+ if (dist < bestDist || dist === bestDist && step > best) {
742
+ best = step;
743
+ bestDist = dist;
744
+ }
745
+ }
746
+ return best;
747
+ }
748
+ function snapCdnSize(requested, assetClass) {
749
+ const { min, max } = CDN_ASSET_CLASS_RANGE[assetClass];
750
+ const snapped = nearestSize(requested, CDN_SIZE_LADDER);
751
+ const clamped = Math.min(max, Math.max(min, snapped));
752
+ const allowed = CDN_SIZE_LADDER.filter((step) => step >= min && step <= max);
753
+ return nearestSize(clamped, allowed);
754
+ }
687
755
  function mediaBase(options) {
688
756
  return (options?.mediaBase ?? CDN_URL).replace(/\/+$/, "");
689
757
  }
758
+ function appendSize(options, assetClass) {
759
+ const size = options?.size;
760
+ if (size == null || !Number.isFinite(size) || size <= 0) return "";
761
+ return `?size=${snapCdnSize(size, assetClass)}`;
762
+ }
690
763
  function cdnStickerURL(stickerId, animated, options) {
691
764
  const ext = animated ? "gif" : "png";
692
- return `${mediaBase(options)}/stickers/${stickerId}.${ext}`;
765
+ const size = appendSize(options, "sticker");
766
+ return `${mediaBase(options)}/stickers/${stickerId}.${ext}${size}`;
693
767
  }
694
768
 
695
769
  // src/Domain/Message/MessageSticker.ts
@@ -917,6 +991,8 @@ var Message = class _Message extends Base {
917
991
  mentionRoles;
918
992
  /** Client-side nonce for deduplication. */
919
993
  nonce;
994
+ /** IDs of custom emojis in the message classified as explicit. */
995
+ nsfwEmojis;
920
996
  /**
921
997
  * Cached text-capable channel (guild text, guild voice, or DM), or null if uncached / not text-based.
922
998
  * Narrowed type has {@link Channel.send} and {@link Channel.delete}.
@@ -991,6 +1067,7 @@ var Message = class _Message extends Base {
991
1067
  this.mentions = (data.mentions ?? []).map((u) => client.getOrCreateUser(u));
992
1068
  this.mentionRoles = data.mention_roles ?? [];
993
1069
  this.nonce = data.nonce ?? null;
1070
+ this.nsfwEmojis = data.nsfw_emojis ?? [];
994
1071
  }
995
1072
  /**
996
1073
  * Apply an API message payload in place (cache identity / MESSAGE_UPDATE).
@@ -1023,6 +1100,7 @@ var Message = class _Message extends Base {
1023
1100
  this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
1024
1101
  this.mentionRoles = data.mention_roles ?? [];
1025
1102
  this.nonce = data.nonce ?? null;
1103
+ this.nsfwEmojis = data.nsfw_emojis ?? [];
1026
1104
  }
1027
1105
  /**
1028
1106
  * Send a standalone message in this channel (not a reply).
@@ -1106,8 +1184,10 @@ var Message = class _Message extends Base {
1106
1184
  return this.client.channels.fetchMessage(this.channelId, this.id);
1107
1185
  }
1108
1186
  /** Delete this message. */
1109
- async delete() {
1110
- await this.client.rest.delete(import_types5.Routes.channelMessage(this.channelId, this.id));
1187
+ async delete(reason) {
1188
+ await this.client.rest.delete(import_types5.Routes.channelMessage(this.channelId, this.id), {
1189
+ ...auditReasonHeaders(reason)
1190
+ });
1111
1191
  this.client._removeMessageFromCache(this.channelId, this.id);
1112
1192
  }
1113
1193
  /** Delete a specific attachment from this message. */
package/dist/message.mjs CHANGED
@@ -22,6 +22,13 @@ function toMessageAttachmentEditWire(attachments) {
22
22
  });
23
23
  }
24
24
 
25
+ // src/Helpers/AuditReason.ts
26
+ var AUDIT_LOG_REASON_HEADER = "X-Audit-Log-Reason";
27
+ function auditReasonHeaders(reason) {
28
+ if (reason == null || reason === "") return {};
29
+ return { headers: { [AUDIT_LOG_REASON_HEADER]: encodeURIComponent(reason) } };
30
+ }
31
+
25
32
  // src/Helpers/MessageUtils/Body.ts
26
33
  import { AttachmentBuilder, EmbedBuilder, MessagePayload } from "@fluxerjs/builders";
27
34
  import { MessageAttachmentFlags, MessageReferenceType } from "@fluxerjs/types";
@@ -660,12 +667,79 @@ import { DEFAULT_USER_AGENT } from "@fluxerjs/rest";
660
667
  var CDN_URL = "https://fluxerusercontent.com";
661
668
 
662
669
  // src/Helpers/Cdn.ts
670
+ var CDN_SIZE_LADDER = [
671
+ 16,
672
+ 20,
673
+ 22,
674
+ 24,
675
+ 28,
676
+ 32,
677
+ 40,
678
+ 44,
679
+ 48,
680
+ 56,
681
+ 60,
682
+ 64,
683
+ 80,
684
+ 96,
685
+ 100,
686
+ 128,
687
+ 160,
688
+ 240,
689
+ 256,
690
+ 300,
691
+ 320,
692
+ 480,
693
+ 512,
694
+ 600,
695
+ 640,
696
+ 1024,
697
+ 1280,
698
+ 1536,
699
+ 2048,
700
+ 3072,
701
+ 4096,
702
+ 8192,
703
+ 16384
704
+ ];
705
+ var CDN_ASSET_CLASS_RANGE = {
706
+ icon: { min: 128, max: 1024 },
707
+ banner: { min: 480, max: 2400 },
708
+ emoji: { min: 32, max: 512 },
709
+ sticker: { min: 128, max: 512 }
710
+ };
711
+ function nearestSize(requested, candidates) {
712
+ let best = candidates[0];
713
+ let bestDist = Math.abs(requested - best);
714
+ for (let i = 1; i < candidates.length; i++) {
715
+ const step = candidates[i];
716
+ const dist = Math.abs(requested - step);
717
+ if (dist < bestDist || dist === bestDist && step > best) {
718
+ best = step;
719
+ bestDist = dist;
720
+ }
721
+ }
722
+ return best;
723
+ }
724
+ function snapCdnSize(requested, assetClass) {
725
+ const { min, max } = CDN_ASSET_CLASS_RANGE[assetClass];
726
+ const snapped = nearestSize(requested, CDN_SIZE_LADDER);
727
+ const clamped = Math.min(max, Math.max(min, snapped));
728
+ const allowed = CDN_SIZE_LADDER.filter((step) => step >= min && step <= max);
729
+ return nearestSize(clamped, allowed);
730
+ }
663
731
  function mediaBase(options) {
664
732
  return (options?.mediaBase ?? CDN_URL).replace(/\/+$/, "");
665
733
  }
734
+ function appendSize(options, assetClass) {
735
+ const size = options?.size;
736
+ if (size == null || !Number.isFinite(size) || size <= 0) return "";
737
+ return `?size=${snapCdnSize(size, assetClass)}`;
738
+ }
666
739
  function cdnStickerURL(stickerId, animated, options) {
667
740
  const ext = animated ? "gif" : "png";
668
- return `${mediaBase(options)}/stickers/${stickerId}.${ext}`;
741
+ const size = appendSize(options, "sticker");
742
+ return `${mediaBase(options)}/stickers/${stickerId}.${ext}${size}`;
669
743
  }
670
744
 
671
745
  // src/Domain/Message/MessageSticker.ts
@@ -893,6 +967,8 @@ var Message = class _Message extends Base {
893
967
  mentionRoles;
894
968
  /** Client-side nonce for deduplication. */
895
969
  nonce;
970
+ /** IDs of custom emojis in the message classified as explicit. */
971
+ nsfwEmojis;
896
972
  /**
897
973
  * Cached text-capable channel (guild text, guild voice, or DM), or null if uncached / not text-based.
898
974
  * Narrowed type has {@link Channel.send} and {@link Channel.delete}.
@@ -967,6 +1043,7 @@ var Message = class _Message extends Base {
967
1043
  this.mentions = (data.mentions ?? []).map((u) => client.getOrCreateUser(u));
968
1044
  this.mentionRoles = data.mention_roles ?? [];
969
1045
  this.nonce = data.nonce ?? null;
1046
+ this.nsfwEmojis = data.nsfw_emojis ?? [];
970
1047
  }
971
1048
  /**
972
1049
  * Apply an API message payload in place (cache identity / MESSAGE_UPDATE).
@@ -999,6 +1076,7 @@ var Message = class _Message extends Base {
999
1076
  this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
1000
1077
  this.mentionRoles = data.mention_roles ?? [];
1001
1078
  this.nonce = data.nonce ?? null;
1079
+ this.nsfwEmojis = data.nsfw_emojis ?? [];
1002
1080
  }
1003
1081
  /**
1004
1082
  * Send a standalone message in this channel (not a reply).
@@ -1082,8 +1160,10 @@ var Message = class _Message extends Base {
1082
1160
  return this.client.channels.fetchMessage(this.channelId, this.id);
1083
1161
  }
1084
1162
  /** Delete this message. */
1085
- async delete() {
1086
- await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id));
1163
+ async delete(reason) {
1164
+ await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id), {
1165
+ ...auditReasonHeaders(reason)
1166
+ });
1087
1167
  this.client._removeMessageFromCache(this.channelId, this.id);
1088
1168
  }
1089
1169
  /** Delete a specific attachment from this message. */
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.0.0",
6
+ "version": "3.2.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/rest": "3.0.0",
63
- "@fluxerjs/ws": "3.0.0",
62
+ "@fluxerjs/rest": "3.1.0",
63
+ "@fluxerjs/ws": "3.1.0",
64
64
  "@fluxerjs/builders": "3.0.0",
65
- "@fluxerjs/collection": "3.0.0",
66
- "@fluxerjs/util": "3.0.0",
67
- "@fluxerjs/types": "3.0.0"
65
+ "@fluxerjs/util": "3.1.0",
66
+ "@fluxerjs/types": "3.2.0",
67
+ "@fluxerjs/collection": "3.0.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/node": "^20.0.0",