@minesa-org/mini-interaction 0.2.25 → 0.2.26

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.
@@ -7,8 +7,8 @@ import { type ModalSubmitInteraction } from "../utils/ModalSubmitInteraction.js"
7
7
  import { type OAuthConfig, type OAuthTokens, type DiscordUser } from "../oauth/DiscordOAuth.js";
8
8
  /** Configuration parameters for the MiniInteraction client. */
9
9
  export type InteractionClientOptions = {
10
- applicationId: string;
11
- publicKey: string;
10
+ applicationId?: string;
11
+ publicKey?: string;
12
12
  commandsDirectory?: string | false;
13
13
  componentsDirectory?: string | false;
14
14
  utilsDirectory?: string | false;
@@ -49,18 +49,20 @@ export class MiniInteraction {
49
49
  * Creates a new MiniInteraction client with optional command auto-loading and custom runtime hooks.
50
50
  */
51
51
  constructor({ applicationId, publicKey, commandsDirectory, componentsDirectory, utilsDirectory, fetchImplementation, verifyKeyImplementation, timeoutConfig, }) {
52
- if (!applicationId) {
53
- throw new Error("[MiniInteraction] applicationId is required");
52
+ const resolvedAppId = applicationId ?? (typeof process !== "undefined" ? process.env.DISCORD_APPLICATION_ID : undefined);
53
+ const resolvedPublicKey = publicKey ?? (typeof process !== "undefined" ? process.env.DISCORD_PUBLIC_KEY : undefined);
54
+ if (!resolvedAppId) {
55
+ throw new Error("[MiniInteraction] applicationId is required (or DISCORD_APPLICATION_ID env var)");
54
56
  }
55
- if (!publicKey) {
56
- throw new Error("[MiniInteraction] publicKey is required");
57
+ if (!resolvedPublicKey) {
58
+ throw new Error("[MiniInteraction] publicKey is required (or DISCORD_PUBLIC_KEY env var)");
57
59
  }
58
60
  const fetchImpl = fetchImplementation ?? globalThis.fetch;
59
61
  if (typeof fetchImpl !== "function") {
60
62
  throw new Error("[MiniInteraction] fetch is not available. Provide a global fetch implementation.");
61
63
  }
62
- this.applicationId = applicationId;
63
- this.publicKey = publicKey;
64
+ this.applicationId = resolvedAppId;
65
+ this.publicKey = resolvedPublicKey;
64
66
  this.fetchImpl = fetchImpl;
65
67
  this.verifyKeyImpl = verifyKeyImplementation ?? verifyKey;
66
68
  this.commandsDirectory =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
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",