@minesa-org/mini-interaction 0.4.17 → 0.4.18

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,5 @@
1
1
  import { type DiscordUser, type OAuthTokens } from "../oauth/DiscordOAuth.js";
2
+ import type { RegisterMetadataResult, RoleConnectionMetadataInput } from "../types/RoleConnectionMetadata.js";
2
3
  type TimeoutConfig = {
3
4
  initialResponseTimeout?: number;
4
5
  autoDeferSlowOperations?: boolean;
@@ -53,6 +54,7 @@ export declare class MiniInteraction {
53
54
  private loadedModulesPromise?;
54
55
  constructor(options?: MiniInteractionOptions);
55
56
  createNodeHandler(): (req: NodeRequest, res: NodeResponse) => Promise<void>;
57
+ registerMetadata(botToken: string, metadata: RoleConnectionMetadataInput[]): Promise<RegisterMetadataResult>;
56
58
  registerCommands(tokenOverride?: string): Promise<unknown>;
57
59
  discordOAuthVerificationPage(options: {
58
60
  htmlFile: string;
@@ -106,6 +106,19 @@ export class MiniInteraction {
106
106
  }
107
107
  };
108
108
  }
109
+ async registerMetadata(botToken, metadata) {
110
+ if (!botToken) {
111
+ throw new Error("[MiniInteraction] botToken is required");
112
+ }
113
+ if (!Array.isArray(metadata) || metadata.length === 0) {
114
+ throw new Error("[MiniInteraction] metadata must be a non-empty array payload");
115
+ }
116
+ const payload = metadata.map((field) => ({
117
+ ...field,
118
+ type: field.type,
119
+ }));
120
+ return this.rest.putApplicationRoleConnectionMetadata(payload);
121
+ }
109
122
  async registerCommands(tokenOverride) {
110
123
  const modules = await this.loadModules();
111
124
  const payload = modules.commands.map((command) => this.resolveCommandPayload(command));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.4.17",
3
+ "version": "0.4.18",
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",