@minesa-org/mini-interaction 0.4.0 → 0.4.3
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/README.md +130 -20
- package/dist/builders/ActionRowBuilder.d.ts +4 -5
- package/dist/builders/CheckboxBuilder.d.ts +17 -0
- package/dist/builders/CheckboxBuilder.js +24 -0
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.js +1 -0
- package/dist/index.d.ts +6 -11
- package/dist/index.js +3 -5
- package/dist/types/Commands.d.ts +14 -0
- package/dist/types/ComponentTypes.d.ts +17 -3
- package/dist/types/InteractionFlags.d.ts +0 -4
- package/dist/types/InteractionFlags.js +0 -4
- package/dist/types/checkbox.d.ts +23 -0
- package/dist/types/checkbox.js +5 -0
- package/dist/utils/MessageComponentInteraction.d.ts +38 -0
- package/dist/utils/MessageComponentInteraction.js +2 -0
- package/dist/utils/ModalSubmitInteraction.js +5 -2
- package/dist/utils/interactionMessageHelpers.d.ts +3 -2
- package/dist/utils/interactionMessageHelpers.js +2 -0
- package/package.json +1 -1
- package/dist/clients/MiniInteraction.d.ts +0 -441
- package/dist/clients/MiniInteraction.js +0 -1731
- package/dist/compat/LegacyMiniInteractionAdapter.d.ts +0 -19
- package/dist/compat/LegacyMiniInteractionAdapter.js +0 -23
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import { APIInteractionResponse, RESTPostAPIChatInputApplicationCommandsJSONBody, RESTPostAPIContextMenuApplicationCommandsJSONBody, RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody } from "discord-api-types/v10";
|
|
3
|
-
import type { InteractionCommand } from "../types/Commands.js";
|
|
4
|
-
import { RoleConnectionMetadataTypes } from "../types/RoleConnectionMetadataTypes.js";
|
|
5
|
-
import { type MessageComponentInteraction, type ButtonInteraction, type StringSelectInteraction, type RoleSelectInteraction, type UserSelectInteraction, type ChannelSelectInteraction, type MentionableSelectInteraction } from "../utils/MessageComponentInteraction.js";
|
|
6
|
-
import { type ModalSubmitInteraction } from "../utils/ModalSubmitInteraction.js";
|
|
7
|
-
import { type OAuthConfig, type OAuthTokens, type DiscordUser } from "../oauth/DiscordOAuth.js";
|
|
8
|
-
/** Configuration parameters for the MiniInteraction client. */
|
|
9
|
-
export type InteractionClientOptions = {
|
|
10
|
-
applicationId?: string;
|
|
11
|
-
publicKey?: string;
|
|
12
|
-
commandsDirectory?: string | false;
|
|
13
|
-
componentsDirectory?: string | false;
|
|
14
|
-
utilsDirectory?: string | false;
|
|
15
|
-
debug?: boolean;
|
|
16
|
-
fetchImplementation?: typeof fetch;
|
|
17
|
-
verifyKeyImplementation?: VerifyKeyFunction;
|
|
18
|
-
timeoutConfig?: InteractionTimeoutConfig;
|
|
19
|
-
};
|
|
20
|
-
/** Payload structure for role connection metadata registration. */
|
|
21
|
-
export type RoleConnectionMetadataField = {
|
|
22
|
-
key: string;
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
type: RoleConnectionMetadataTypes;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* HTTP request information needed to validate and handle Discord interaction payloads.
|
|
29
|
-
*/
|
|
30
|
-
export type InteractionRequest = {
|
|
31
|
-
body: string | Uint8Array;
|
|
32
|
-
signature?: string;
|
|
33
|
-
timestamp?: string;
|
|
34
|
-
};
|
|
35
|
-
/** Result payload returned by request handlers when processing an interaction. */
|
|
36
|
-
export type InteractionHandlerResult = {
|
|
37
|
-
status: number;
|
|
38
|
-
body: APIInteractionResponse | {
|
|
39
|
-
error: string;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Promise that resolves when all background work (like editReply) completes.
|
|
43
|
-
* Pass this to Vercel's waitUntil() to prevent premature termination.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // In Next.js App Router
|
|
48
|
-
* import { waitUntil } from '@vercel/functions';
|
|
49
|
-
*
|
|
50
|
-
* export async function POST(request: Request) {
|
|
51
|
-
* const result = await client.handleRequest({ ... });
|
|
52
|
-
* if (result.backgroundWork) {
|
|
53
|
-
* waitUntil(result.backgroundWork);
|
|
54
|
-
* }
|
|
55
|
-
* return Response.json(result.body, { status: result.status });
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
backgroundWork?: Promise<void>;
|
|
60
|
-
};
|
|
61
|
-
/** Configuration for interaction timeout handling. */
|
|
62
|
-
export type InteractionTimeoutConfig = {
|
|
63
|
-
/** Maximum time in milliseconds to wait for initial response (default: 2800ms) */
|
|
64
|
-
initialResponseTimeout?: number;
|
|
65
|
-
/** Whether to enable timeout warnings (default: true) */
|
|
66
|
-
enableTimeoutWarnings?: boolean;
|
|
67
|
-
/** Whether to force deferReply for slow operations (default: true) */
|
|
68
|
-
autoDeferSlowOperations?: boolean;
|
|
69
|
-
/** Whether to enable debug logging for interaction responses (default: false) */
|
|
70
|
-
enableResponseDebugLogging?: boolean;
|
|
71
|
-
};
|
|
72
|
-
/** Handler signature invoked for Discord button interactions. */
|
|
73
|
-
export type ButtonComponentHandler = (interaction: ButtonInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
74
|
-
/** Handler signature invoked for Discord string select menu interactions. */
|
|
75
|
-
export type StringSelectComponentHandler = (interaction: StringSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
76
|
-
/** Handler signature invoked for Discord role select menu interactions. */
|
|
77
|
-
export type RoleSelectComponentHandler = (interaction: RoleSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
78
|
-
/** Handler signature invoked for Discord user select menu interactions. */
|
|
79
|
-
export type UserSelectComponentHandler = (interaction: UserSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
80
|
-
/** Handler signature invoked for Discord channel select menu interactions. */
|
|
81
|
-
export type ChannelSelectComponentHandler = (interaction: ChannelSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
82
|
-
/** Handler signature invoked for Discord mentionable select menu interactions. */
|
|
83
|
-
export type MentionableSelectComponentHandler = (interaction: MentionableSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
84
|
-
/** Handler signature invoked for Discord message component interactions (generic). */
|
|
85
|
-
export type ComponentHandler = (interaction: MessageComponentInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
86
|
-
/** Handler signature invoked for Discord modal submit interactions. */
|
|
87
|
-
export type ModalHandler = (interaction: ModalSubmitInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
88
|
-
/** Unified handler signature that accepts any component or modal interaction. */
|
|
89
|
-
export type InteractionHandler = ButtonComponentHandler | StringSelectComponentHandler | RoleSelectComponentHandler | UserSelectComponentHandler | ChannelSelectComponentHandler | MentionableSelectComponentHandler | ComponentHandler | ModalHandler;
|
|
90
|
-
type CommandDataPayload = RESTPostAPIChatInputApplicationCommandsJSONBody | RESTPostAPIContextMenuApplicationCommandsJSONBody | RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody;
|
|
91
|
-
/**
|
|
92
|
-
* Structure describing a component or modal handler mapped to a custom id.
|
|
93
|
-
* When auto-loading from the components directory:
|
|
94
|
-
* - Files in `components/modals/` are treated as modal handlers
|
|
95
|
-
* - Other files are treated as component handlers
|
|
96
|
-
* You can use this type for both - the system will figure out which one it is.
|
|
97
|
-
*/
|
|
98
|
-
export type ComponentCommand = {
|
|
99
|
-
customId: string;
|
|
100
|
-
handler: InteractionHandler;
|
|
101
|
-
};
|
|
102
|
-
/** Structure describing a modal handler mapped to a custom id. */
|
|
103
|
-
export type ModalCommand = {
|
|
104
|
-
customId: string;
|
|
105
|
-
handler: ModalHandler;
|
|
106
|
-
};
|
|
107
|
-
/** Node.js HTTP handler compatible with frameworks like Express or Next.js API routes. */
|
|
108
|
-
export type InteractionNodeHandler = (request: IncomingMessage, response: ServerResponse) => void;
|
|
109
|
-
/** Web Fetch API compatible request handler for platforms such as Cloudflare Workers. */
|
|
110
|
-
export type InteractionFetchHandler = (request: Request) => Promise<Response>;
|
|
111
|
-
/** Context passed to OAuth success handlers and templates. */
|
|
112
|
-
export type DiscordOAuthAuthorizeContext = {
|
|
113
|
-
tokens: OAuthTokens;
|
|
114
|
-
user: DiscordUser;
|
|
115
|
-
state: string | null;
|
|
116
|
-
request: IncomingMessage;
|
|
117
|
-
response: ServerResponse;
|
|
118
|
-
};
|
|
119
|
-
/** Context provided to templates that only need access to the state value. */
|
|
120
|
-
export type DiscordOAuthStateTemplateContext = {
|
|
121
|
-
state: string | null;
|
|
122
|
-
};
|
|
123
|
-
/** Context provided to templates that display OAuth error messages. */
|
|
124
|
-
export type DiscordOAuthErrorTemplateContext = DiscordOAuthStateTemplateContext & {
|
|
125
|
-
error: string;
|
|
126
|
-
};
|
|
127
|
-
/** Context provided to templates used for successful authorisation messages. */
|
|
128
|
-
export type DiscordOAuthSuccessTemplateContext = DiscordOAuthStateTemplateContext & {
|
|
129
|
-
user: DiscordUser;
|
|
130
|
-
tokens: OAuthTokens;
|
|
131
|
-
};
|
|
132
|
-
/** Context provided to templates that handle server side failures. */
|
|
133
|
-
export type DiscordOAuthServerErrorTemplateContext = DiscordOAuthStateTemplateContext;
|
|
134
|
-
/** Template functions used to render HTML responses during the OAuth flow. */
|
|
135
|
-
export type DiscordOAuthCallbackTemplates = {
|
|
136
|
-
success: (context: DiscordOAuthSuccessTemplateContext) => string;
|
|
137
|
-
missingCode: (context: DiscordOAuthStateTemplateContext) => string;
|
|
138
|
-
oauthError: (context: DiscordOAuthErrorTemplateContext) => string;
|
|
139
|
-
invalidState: (context: DiscordOAuthStateTemplateContext) => string;
|
|
140
|
-
serverError: (context: DiscordOAuthServerErrorTemplateContext) => string;
|
|
141
|
-
};
|
|
142
|
-
/** Options accepted by {@link MiniInteraction.discordOAuthCallback}. */
|
|
143
|
-
export type DiscordOAuthCallbackOptions = {
|
|
144
|
-
oauth?: OAuthConfig;
|
|
145
|
-
onAuthorize?: (context: DiscordOAuthAuthorizeContext) => Promise<void> | void;
|
|
146
|
-
validateState?: (state: string | null, request: IncomingMessage) => Promise<boolean> | boolean;
|
|
147
|
-
successRedirect?: string | ((context: DiscordOAuthAuthorizeContext) => string | null | undefined);
|
|
148
|
-
templates?: Partial<DiscordOAuthCallbackTemplates>;
|
|
149
|
-
};
|
|
150
|
-
/** Options accepted by {@link MiniInteraction.discordOAuthVerificationPage}. */
|
|
151
|
-
export type DiscordOAuthVerificationPageOptions = {
|
|
152
|
-
oauth?: OAuthConfig;
|
|
153
|
-
scopes?: string[];
|
|
154
|
-
/**
|
|
155
|
-
* Path to the HTML file to load. Relative paths resolve from {@link process.cwd}.
|
|
156
|
-
*
|
|
157
|
-
* @defaultValue "index.html"
|
|
158
|
-
*/
|
|
159
|
-
htmlFile?: string;
|
|
160
|
-
/**
|
|
161
|
-
* Placeholder token (with or without the `{{ }}` wrapper) that will be replaced with the generated OAuth URL.
|
|
162
|
-
*
|
|
163
|
-
* @defaultValue "OAUTH_URL"
|
|
164
|
-
*/
|
|
165
|
-
placeholder?: string;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Minimal interface describing a function capable of verifying Discord interaction signatures.
|
|
169
|
-
*/
|
|
170
|
-
type VerifyKeyFunction = (message: string | Uint8Array, signature: string, timestamp: string, publicKey: string) => boolean | Promise<boolean>;
|
|
171
|
-
/**
|
|
172
|
-
* Lightweight client for registering, loading, and handling Discord slash command interactions.
|
|
173
|
-
*/
|
|
174
|
-
export declare class MiniInteraction {
|
|
175
|
-
readonly applicationId: string;
|
|
176
|
-
readonly publicKey: string;
|
|
177
|
-
private readonly fetchImpl;
|
|
178
|
-
private readonly verifyKeyImpl;
|
|
179
|
-
private readonly commandsDirectory;
|
|
180
|
-
private readonly componentsDirectory;
|
|
181
|
-
readonly utilsDirectory: string | null;
|
|
182
|
-
private readonly debug;
|
|
183
|
-
private readonly timeoutConfig;
|
|
184
|
-
private readonly commands;
|
|
185
|
-
private readonly componentHandlers;
|
|
186
|
-
private readonly modalHandlers;
|
|
187
|
-
private readonly htmlTemplateCache;
|
|
188
|
-
private readonly interactionStates;
|
|
189
|
-
private commandsLoaded;
|
|
190
|
-
private loadCommandsPromise;
|
|
191
|
-
private componentsLoaded;
|
|
192
|
-
private loadComponentsPromise;
|
|
193
|
-
private registerCommandsPromise;
|
|
194
|
-
private registerCommandsSignature;
|
|
195
|
-
private vercelWaitUntil;
|
|
196
|
-
private searchedForVercel;
|
|
197
|
-
/**
|
|
198
|
-
* Creates a new MiniInteraction client with optional command auto-loading and custom runtime hooks.
|
|
199
|
-
*/
|
|
200
|
-
constructor(options?: InteractionClientOptions);
|
|
201
|
-
private log;
|
|
202
|
-
private trackInteractionState;
|
|
203
|
-
/**
|
|
204
|
-
* Checks if an interaction can still respond (not expired and not already responded).
|
|
205
|
-
*/
|
|
206
|
-
private canRespond;
|
|
207
|
-
/**
|
|
208
|
-
* Gets the current state of an interaction.
|
|
209
|
-
*/
|
|
210
|
-
private getInteractionState;
|
|
211
|
-
/**
|
|
212
|
-
* Clears expired interaction states to prevent memory leaks.
|
|
213
|
-
* Call this periodically to clean up old interaction data.
|
|
214
|
-
*/
|
|
215
|
-
cleanupExpiredInteractions(): number;
|
|
216
|
-
/**
|
|
217
|
-
* Attempt to find a waitUntil implementation in the environment (e.g. Vercel or Cloudflare).
|
|
218
|
-
*/
|
|
219
|
-
private getAutoWaitUntil;
|
|
220
|
-
private normalizeCommandData;
|
|
221
|
-
private registerCommand;
|
|
222
|
-
/**
|
|
223
|
-
* Registers a single command handler with the client.
|
|
224
|
-
*
|
|
225
|
-
* @param command - The command definition to register.
|
|
226
|
-
*/
|
|
227
|
-
useCommand(command: InteractionCommand): this;
|
|
228
|
-
/**
|
|
229
|
-
* Registers multiple command handlers with the client.
|
|
230
|
-
*
|
|
231
|
-
* @param commands - The command definitions to register.
|
|
232
|
-
*/
|
|
233
|
-
useCommands(commands: InteractionCommand[]): this;
|
|
234
|
-
/**
|
|
235
|
-
* Registers a single component handler mapped to a custom identifier.
|
|
236
|
-
*
|
|
237
|
-
* @param component - The component definition to register.
|
|
238
|
-
*/
|
|
239
|
-
useComponent(component: ComponentCommand): this;
|
|
240
|
-
/**
|
|
241
|
-
* Registers multiple component handlers in a single call.
|
|
242
|
-
*
|
|
243
|
-
* @param components - The component definitions to register.
|
|
244
|
-
*/
|
|
245
|
-
useComponents(components: ComponentCommand[]): this;
|
|
246
|
-
/**
|
|
247
|
-
* Registers a single modal handler mapped to a custom identifier.
|
|
248
|
-
*
|
|
249
|
-
* @param modal - The modal definition to register.
|
|
250
|
-
*/
|
|
251
|
-
useModal(modal: ModalCommand): this;
|
|
252
|
-
/**
|
|
253
|
-
* Registers multiple modal handlers in a single call.
|
|
254
|
-
*
|
|
255
|
-
* @param modals - The modal definitions to register.
|
|
256
|
-
*/
|
|
257
|
-
useModals(modals: ModalCommand[]): this;
|
|
258
|
-
/**
|
|
259
|
-
* Recursively loads components from the configured components directory.
|
|
260
|
-
*
|
|
261
|
-
* @param directory - Optional directory override for component discovery.
|
|
262
|
-
*/
|
|
263
|
-
loadComponentsFromDirectory(directory?: string): Promise<this>;
|
|
264
|
-
/**
|
|
265
|
-
* Recursively loads commands from the configured commands directory.
|
|
266
|
-
*
|
|
267
|
-
* @param directory - Optional directory override for command discovery.
|
|
268
|
-
*/
|
|
269
|
-
loadCommandsFromDirectory(directory?: string): Promise<this>;
|
|
270
|
-
/**
|
|
271
|
-
* Lists the raw command data payloads for registration with Discord.
|
|
272
|
-
*/
|
|
273
|
-
listCommandData(): CommandDataPayload[];
|
|
274
|
-
/**
|
|
275
|
-
* Registers commands with Discord's REST API.
|
|
276
|
-
*
|
|
277
|
-
* @param botToken - The bot token authorising the registration request.
|
|
278
|
-
* @param commands - Optional command list to register instead of auto-loaded commands.
|
|
279
|
-
*/
|
|
280
|
-
registerCommands(botToken: string, commands?: CommandDataPayload[]): Promise<unknown>;
|
|
281
|
-
/**
|
|
282
|
-
* Registers role connection metadata with Discord's REST API.
|
|
283
|
-
*
|
|
284
|
-
* @param botToken - The bot token authorising the request.
|
|
285
|
-
* @param metadata - The metadata collection to register.
|
|
286
|
-
*/
|
|
287
|
-
registerMetadata(botToken: string, metadata: RoleConnectionMetadataField[]): Promise<unknown>;
|
|
288
|
-
/**
|
|
289
|
-
* Validates and handles a single Discord interaction request.
|
|
290
|
-
*
|
|
291
|
-
* @param request - The request payload containing headers and body data.
|
|
292
|
-
*/
|
|
293
|
-
handleRequest(request: InteractionRequest): Promise<InteractionHandlerResult>;
|
|
294
|
-
/**
|
|
295
|
-
* Creates a Node.js style request handler compatible with Express, Next.js API routes,
|
|
296
|
-
* Vercel serverless functions, and any runtime that expects a `(req, res)` listener.
|
|
297
|
-
*/
|
|
298
|
-
createNodeHandler(options?: {
|
|
299
|
-
waitUntil?: (promise: Promise<void>) => void;
|
|
300
|
-
}): InteractionNodeHandler;
|
|
301
|
-
/**
|
|
302
|
-
* Generates a lightweight verification handler that serves an HTML page with an embedded OAuth link.
|
|
303
|
-
*
|
|
304
|
-
* This is primarily used when Discord asks for a verification URL while setting up Linked Roles.
|
|
305
|
-
* Provide an HTML file that contains the `{{OAUTH_URL}}` placeholder (or a custom placeholder defined in options)
|
|
306
|
-
* and this helper will replace the token with a freshly generated OAuth link on every request.
|
|
307
|
-
*
|
|
308
|
-
* Available placeholders:
|
|
309
|
-
* - `{{OAUTH_URL}}` - HTML-escaped OAuth URL for links/buttons.
|
|
310
|
-
* - `{{OAUTH_URL_RAW}}` - raw OAuth URL, ideal for `<script>` usage.
|
|
311
|
-
* - `{{OAUTH_STATE}}` - HTML-escaped OAuth state value.
|
|
312
|
-
* - Custom placeholder name (from {@link DiscordOAuthVerificationPageOptions.placeholder}) and its `_RAW` variant.
|
|
313
|
-
*/
|
|
314
|
-
discordOAuthVerificationPage(options?: DiscordOAuthVerificationPageOptions): InteractionNodeHandler;
|
|
315
|
-
/**
|
|
316
|
-
* Loads an HTML file and returns a success template that replaces useful placeholders.
|
|
317
|
-
*
|
|
318
|
-
* The following placeholders are available in the HTML file:
|
|
319
|
-
* - `{{username}}`, `{{discriminator}}`, `{{user_id}}`, `{{user_tag}}`
|
|
320
|
-
* - `{{access_token}}`, `{{refresh_token}}`, `{{token_type}}`, `{{scope}}`, `{{expires_at}}`
|
|
321
|
-
* - `{{state}}`
|
|
322
|
-
*/
|
|
323
|
-
connectedOAuthPage(filePath: string): DiscordOAuthCallbackTemplates["success"];
|
|
324
|
-
/**
|
|
325
|
-
* Loads an HTML file and returns an error template that can be reused for all failure cases.
|
|
326
|
-
*
|
|
327
|
-
* The following placeholders are available in the HTML file:
|
|
328
|
-
* - `{{error}}`
|
|
329
|
-
* - `{{state}}`
|
|
330
|
-
*/
|
|
331
|
-
failedOAuthPage(filePath: string): ((context: DiscordOAuthErrorTemplateContext) => string) & ((context: DiscordOAuthStateTemplateContext) => string);
|
|
332
|
-
/**
|
|
333
|
-
* Resolves an HTML template from disk and caches the result for reuse.
|
|
334
|
-
*/
|
|
335
|
-
private loadHtmlTemplate;
|
|
336
|
-
/**
|
|
337
|
-
* Replaces placeholder tokens in a template with escaped HTML values.
|
|
338
|
-
*/
|
|
339
|
-
private renderHtmlTemplate;
|
|
340
|
-
/**
|
|
341
|
-
* Normalizes placeholder tokens to the bare key the HTML renderer expects.
|
|
342
|
-
*/
|
|
343
|
-
private normalizeTemplateKey;
|
|
344
|
-
/**
|
|
345
|
-
* Creates a minimal Discord OAuth callback handler that renders helpful HTML responses.
|
|
346
|
-
*
|
|
347
|
-
* This helper keeps the user-side implementation tiny while still exposing hooks for
|
|
348
|
-
* storing metadata or validating the OAuth state value.
|
|
349
|
-
*/
|
|
350
|
-
discordOAuthCallback(options: DiscordOAuthCallbackOptions): InteractionNodeHandler;
|
|
351
|
-
/**
|
|
352
|
-
* Creates a Fetch API compatible handler for runtimes like Workers or Deno.
|
|
353
|
-
*/
|
|
354
|
-
/**
|
|
355
|
-
* Generates a Fetch-standard request handler compatible with Cloudflare Workers,
|
|
356
|
-
* Bun, Deno, and Next.js Edge Runtime.
|
|
357
|
-
*/
|
|
358
|
-
createFetchHandler(options?: {
|
|
359
|
-
waitUntil?: (promise: Promise<void>) => void;
|
|
360
|
-
}): InteractionFetchHandler;
|
|
361
|
-
/**
|
|
362
|
-
* Checks if the provided directory path exists on disk.
|
|
363
|
-
*/
|
|
364
|
-
private pathExists;
|
|
365
|
-
/**
|
|
366
|
-
* Recursively collects all command module file paths from the target directory.
|
|
367
|
-
*/
|
|
368
|
-
private collectModuleFiles;
|
|
369
|
-
/**
|
|
370
|
-
* Determines whether the provided file path matches a supported command file extension.
|
|
371
|
-
*/
|
|
372
|
-
private isSupportedModuleFile;
|
|
373
|
-
/**
|
|
374
|
-
* Dynamically imports and validates a command module from disk.
|
|
375
|
-
* Supports multiple export patterns:
|
|
376
|
-
* - export default { data, handler }
|
|
377
|
-
* - export const command = { data, handler }
|
|
378
|
-
* - export const ping_command = { data, handler }
|
|
379
|
-
* - export const data = ...; export const handler = ...;
|
|
380
|
-
*/
|
|
381
|
-
private importCommandModule;
|
|
382
|
-
/**
|
|
383
|
-
* Dynamically imports and validates a component module from disk.
|
|
384
|
-
* Also handles modal components if they're in a "modals" subdirectory.
|
|
385
|
-
* Supports multiple export patterns:
|
|
386
|
-
* - export default { customId, handler }
|
|
387
|
-
* - export const component = { customId, handler }
|
|
388
|
-
* - export const ping_button = { customId, handler }
|
|
389
|
-
* - export const customId = "..."; export const handler = ...;
|
|
390
|
-
* - export const components = [{ customId, handler }, ...]
|
|
391
|
-
*/
|
|
392
|
-
private importComponentModule;
|
|
393
|
-
/**
|
|
394
|
-
* Normalises the request body into a UTF-8 string for signature validation and parsing.
|
|
395
|
-
*/
|
|
396
|
-
private normalizeBody;
|
|
397
|
-
/**
|
|
398
|
-
* Ensures components have been loaded from disk once before being accessed.
|
|
399
|
-
*/
|
|
400
|
-
private ensureComponentsLoaded;
|
|
401
|
-
/**
|
|
402
|
-
* Ensures commands have been loaded from disk once before being accessed.
|
|
403
|
-
*/
|
|
404
|
-
private ensureCommandsLoaded;
|
|
405
|
-
/**
|
|
406
|
-
* Resolves the absolute commands directory path from configuration.
|
|
407
|
-
*/
|
|
408
|
-
private resolveCommandsDirectory;
|
|
409
|
-
/**
|
|
410
|
-
* Resolves the absolute components directory path from configuration.
|
|
411
|
-
*/
|
|
412
|
-
private resolveComponentsDirectory;
|
|
413
|
-
/**
|
|
414
|
-
* Resolves the absolute utilities directory path from configuration.
|
|
415
|
-
*/
|
|
416
|
-
private resolveUtilsDirectory;
|
|
417
|
-
/**
|
|
418
|
-
* Resolves a directory relative to the project "src" or "dist" folders with optional overrides.
|
|
419
|
-
*/
|
|
420
|
-
private resolveDirectory;
|
|
421
|
-
/**
|
|
422
|
-
* Handles execution of a message component interaction.
|
|
423
|
-
*/
|
|
424
|
-
private handleMessageComponent;
|
|
425
|
-
/**
|
|
426
|
-
* Handles execution of a modal submit interaction.
|
|
427
|
-
*/
|
|
428
|
-
private handleModalSubmit;
|
|
429
|
-
/**
|
|
430
|
-
* Handles execution of an application command interaction.
|
|
431
|
-
*/
|
|
432
|
-
private handleApplicationCommand;
|
|
433
|
-
/**
|
|
434
|
-
* Sends a follow-up response or edits an existing response via Discord's interaction webhooks.
|
|
435
|
-
* This is used for interactions that have already been acknowledged (e.g., via deferReply).
|
|
436
|
-
*
|
|
437
|
-
* Includes retry logic to handle race conditions where the ACK hasn't reached Discord yet.
|
|
438
|
-
*/
|
|
439
|
-
private sendFollowUp;
|
|
440
|
-
}
|
|
441
|
-
export {};
|