@minesa-org/mini-interaction 0.2.27 → 0.3.1
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/builders/EmbedBuilder.d.ts +1 -1
- package/dist/builders/EmbedBuilder.js +14 -5
- package/dist/builders/MiniContainerBuilder.js +4 -4
- package/dist/clients/MiniInteraction.js +5 -6
- package/dist/types/InteractionFlags.d.ts +1 -1
- package/dist/types/InteractionFlags.js +1 -1
- package/package.json +5 -2
|
@@ -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
|
|
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
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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) => (
|
|
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
|
-
?
|
|
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) => (
|
|
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) => (
|
|
334
|
+
items: items.map((item) => resolveJSONEncodable(item)),
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
}
|
|
@@ -49,15 +49,14 @@ export class MiniInteraction {
|
|
|
49
49
|
* Creates a new MiniInteraction client with optional command auto-loading and custom runtime hooks.
|
|
50
50
|
*/
|
|
51
51
|
constructor(options = {}) {
|
|
52
|
+
// Attempt to load .env if dotenv is available (non-blocking)
|
|
53
|
+
if (typeof process !== "undefined" && !process.env.DISCORD_APPLICATION_ID) {
|
|
54
|
+
// @ts-ignore - Optional dependency, may not have types available during build
|
|
55
|
+
import("dotenv/config").catch(() => { });
|
|
56
|
+
}
|
|
52
57
|
const { applicationId, publicKey, commandsDirectory, componentsDirectory, utilsDirectory, fetchImplementation, verifyKeyImplementation, timeoutConfig, } = options;
|
|
53
58
|
const resolvedAppId = applicationId ?? (typeof process !== "undefined" ? process.env.DISCORD_APPLICATION_ID : undefined);
|
|
54
59
|
const resolvedPublicKey = publicKey ?? (typeof process !== "undefined" ? (process.env.DISCORD_PUBLIC_KEY ?? process.env.DISCORD_APP_PUBLIC_KEY) : undefined);
|
|
55
|
-
if (!resolvedAppId) {
|
|
56
|
-
throw new Error("[MiniInteraction] applicationId is required (or DISCORD_APPLICATION_ID env var)");
|
|
57
|
-
}
|
|
58
|
-
if (!resolvedPublicKey) {
|
|
59
|
-
throw new Error("[MiniInteraction] publicKey is required (or DISCORD_PUBLIC_KEY env var)");
|
|
60
|
-
}
|
|
61
60
|
const fetchImpl = fetchImplementation ?? globalThis.fetch;
|
|
62
61
|
if (typeof fetchImpl !== "function") {
|
|
63
62
|
throw new Error("[MiniInteraction] fetch is not available. Provide a global fetch implementation.");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var InteractionFlags;
|
|
2
2
|
(function (InteractionFlags) {
|
|
3
3
|
InteractionFlags[InteractionFlags["Ephemeral"] = 64] = "Ephemeral";
|
|
4
|
-
InteractionFlags[InteractionFlags["IsComponentsV2"] =
|
|
4
|
+
InteractionFlags[InteractionFlags["IsComponentsV2"] = 4096] = "IsComponentsV2";
|
|
5
5
|
InteractionFlags[InteractionFlags["SuppressEmbeds"] = 4] = "SuppressEmbeds";
|
|
6
6
|
})(InteractionFlags || (InteractionFlags = {}));
|
|
7
7
|
/** @deprecated Use InteractionFlags instead. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minesa-org/mini-interaction",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -40,8 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://github.com/minesa-org/mini-interaction#readme",
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@vercel/functions": "^1.6.0",
|
|
43
44
|
"discord-api-types": "^0.38.32",
|
|
44
|
-
"discord-interactions": "^4.4.0"
|
|
45
|
+
"discord-interactions": "^4.4.0",
|
|
46
|
+
"dotenv": "^17.2.3",
|
|
47
|
+
"mongodb": "^7.0.0"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
47
50
|
"@types/node": "^24.10.0",
|