@minesa-org/mini-interaction 0.3.0 → 0.3.2

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
1
  import { type APIEmbed, type APIEmbedAuthor, type APIEmbedField, type APIEmbedFooter, type APIEmbedImage, type APIEmbedThumbnail } from "discord-api-types/v10";
2
- import type { JSONEncodable } from "./shared.js";
2
+ import { type JSONEncodable } from "./shared.js";
3
3
  /** Shape describing data used to seed an embed builder instance. */
4
4
  export type EmbedBuilderData = Partial<APIEmbed>;
5
5
  /** Builder for Discord embed payloads. */
@@ -1,3 +1,4 @@
1
+ import { resolveJSONEncodable } from "./shared.js";
1
2
  /** Builder for Discord embed payloads. */
2
3
  export class EmbedBuilder {
3
4
  data;
@@ -84,11 +85,19 @@ export class EmbedBuilder {
84
85
  toJSON() {
85
86
  return {
86
87
  ...this.data,
87
- footer: this.data.footer ? { ...this.data.footer } : undefined,
88
- image: this.data.image ? { ...this.data.image } : undefined,
89
- thumbnail: this.data.thumbnail ? { ...this.data.thumbnail } : undefined,
90
- author: this.data.author ? { ...this.data.author } : undefined,
91
- fields: this.data.fields?.map((field) => ({ ...field })),
88
+ footer: this.data.footer
89
+ ? resolveJSONEncodable(this.data.footer)
90
+ : undefined,
91
+ image: this.data.image
92
+ ? resolveJSONEncodable(this.data.image)
93
+ : undefined,
94
+ thumbnail: this.data.thumbnail
95
+ ? resolveJSONEncodable(this.data.thumbnail)
96
+ : undefined,
97
+ author: this.data.author
98
+ ? resolveJSONEncodable(this.data.author)
99
+ : undefined,
100
+ fields: this.data.fields?.map((field) => resolveJSONEncodable(field)),
92
101
  };
93
102
  }
94
103
  }
@@ -66,7 +66,7 @@ export class ContainerBuilder {
66
66
  return {
67
67
  ...this.data,
68
68
  type: ComponentType.Container,
69
- components: components.map((component) => ({ ...component })),
69
+ components: components.map((component) => resolveJSONEncodable(component)),
70
70
  };
71
71
  }
72
72
  }
@@ -113,7 +113,7 @@ export class SectionBuilder {
113
113
  toJSON() {
114
114
  const components = this.data.components ?? [];
115
115
  const accessory = this.data.accessory
116
- ? { ...this.data.accessory }
116
+ ? resolveJSONEncodable(this.data.accessory)
117
117
  : undefined;
118
118
  if (!accessory) {
119
119
  throw new Error("[SectionBuilder] accessory is required for sections");
@@ -121,7 +121,7 @@ export class SectionBuilder {
121
121
  return {
122
122
  ...this.data,
123
123
  type: ComponentType.Section,
124
- components: components.map((component) => ({ ...component })),
124
+ components: components.map((component) => resolveJSONEncodable(component)),
125
125
  accessory,
126
126
  };
127
127
  }
@@ -331,7 +331,7 @@ export class GalleryBuilder {
331
331
  return {
332
332
  ...this.data,
333
333
  type: ComponentType.MediaGallery,
334
- items: items.map((item) => ({ ...item })),
334
+ items: items.map((item) => resolveJSONEncodable(item)),
335
335
  };
336
336
  }
337
337
  }
@@ -1,6 +1,6 @@
1
1
  export declare enum InteractionFlags {
2
2
  Ephemeral = 64,
3
- IsComponentsV2 = 32768,
3
+ IsComponentsV2 = 4096,
4
4
  SuppressEmbeds = 4
5
5
  }
6
6
  /** @deprecated Use InteractionFlags instead. */
@@ -1,7 +1,7 @@
1
1
  export var InteractionFlags;
2
2
  (function (InteractionFlags) {
3
3
  InteractionFlags[InteractionFlags["Ephemeral"] = 64] = "Ephemeral";
4
- InteractionFlags[InteractionFlags["IsComponentsV2"] = 32768] = "IsComponentsV2";
4
+ InteractionFlags[InteractionFlags["IsComponentsV2"] = 4096] = "IsComponentsV2";
5
5
  InteractionFlags[InteractionFlags["SuppressEmbeds"] = 4] = "SuppressEmbeds";
6
6
  })(InteractionFlags || (InteractionFlags = {}));
7
7
  /** @deprecated Use InteractionFlags instead. */
@@ -1,7 +1,7 @@
1
1
  import type { APIInteractionResponseCallbackData, MessageFlags } from "discord-api-types/v10";
2
2
  import type { APIActionRowComponent, APIComponentInMessageActionRow, APIContainerComponent } from "discord-api-types/v10";
3
3
  import type { JSONEncodable } from "../builders/shared.js";
4
- import type { InteractionFlags } from "../types/InteractionFlags.js";
4
+ import { InteractionFlags } from "../types/InteractionFlags.js";
5
5
  /** Union of helper flag enums and raw Discord message flags. */
6
6
  export type MessageFlagLike = MessageFlags | InteractionFlags;
7
7
  /** Top-level components allowed in messages (ActionRows or Containers) */
@@ -1,5 +1,6 @@
1
1
  import { resolveJSONEncodable } from "../builders/shared.js";
2
2
  import { ComponentType, } from "discord-api-types/v10";
3
+ import { InteractionFlags } from "../types/InteractionFlags.js";
3
4
  const COMPONENTS_V2_TYPES = new Set([
4
5
  ComponentType.Container,
5
6
  ComponentType.Section,
@@ -8,6 +9,8 @@ const COMPONENTS_V2_TYPES = new Set([
8
9
  ComponentType.File,
9
10
  ComponentType.Separator,
10
11
  ComponentType.Thumbnail,
12
+ 18, // Label
13
+ 19, // FileUpload
11
14
  ]);
12
15
  /**
13
16
  * Normalises helper flag enums into the raw Discord `MessageFlags` bitfield.
@@ -56,7 +59,7 @@ export function normaliseInteractionMessageData(data) {
56
59
  if (responseData.components && Array.isArray(responseData.components)) {
57
60
  if (containsComponentsV2(responseData.components)) {
58
61
  const currentFlags = responseData.flags ?? 0;
59
- responseData.flags = (currentFlags | (0x1 << 12)); // 0x1 << 12 is IsComponentsV2
62
+ responseData.flags = (currentFlags | InteractionFlags.IsComponentsV2);
60
63
  }
61
64
  }
62
65
  return responseData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Mini interaction, connecting your app with Discord via HTTP-interaction (Vercel support).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",