commandkit 0.1.11-dev.20250216145024 → 0.1.11-dev.20250306101654
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/bin/index.mjs +1 -1
- package/dist/index.d.ts +939 -741
- package/dist/index.js +5022 -33
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/index.d.mts +0 -1770
- package/dist/index.mjs +0 -50
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { Client, Interaction, CacheType, ChatInputCommandInteraction, ContextMenuCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction,
|
|
2
|
+
import { RESTPostAPIApplicationCommandsJSONBody, Client, Interaction, CacheType, PermissionsString, ChatInputCommandInteraction, ContextMenuCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction, ClientEvents, Awaitable, ButtonBuilder, ButtonInteraction, Events, ModalBuilder, ModalSubmitInteraction, ActionRowBuilder, TextInputBuilder, ButtonStyle, ComponentEmojiResolvable, TextInputStyle, Locale, Message as Message$1, ApplicationCommandOptionType, GuildMember, Attachment, User, Role, CommandInteractionOption, SlashCommandBuilder, ContextMenuCommandBuilder, PartialMessage } from 'discord.js';
|
|
3
3
|
import EventEmitter from 'node:events';
|
|
4
4
|
import { Channel } from 'diagnostics_channel';
|
|
5
5
|
import * as commander from 'commander';
|
|
@@ -67,14 +67,6 @@ interface CommandKitOptions {
|
|
|
67
67
|
*/
|
|
68
68
|
cacheProvider?: CacheProvider | null;
|
|
69
69
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Private data for the CommandKit class.
|
|
72
|
-
*/
|
|
73
|
-
interface CommandKitData extends CommandKitOptions {
|
|
74
|
-
commandHandler?: CommandHandler;
|
|
75
|
-
eventHandler?: EventHandler;
|
|
76
|
-
validationHandler?: ValidationHandler;
|
|
77
|
-
}
|
|
78
70
|
/**
|
|
79
71
|
* Represents a command context.
|
|
80
72
|
*/
|
|
@@ -266,531 +258,201 @@ declare enum ReloadType {
|
|
|
266
258
|
Global = "global"
|
|
267
259
|
}
|
|
268
260
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
261
|
+
interface EventInterceptorContextData<E extends keyof ClientEvents> {
|
|
262
|
+
/**
|
|
263
|
+
* The filter to use for the collector.
|
|
264
|
+
*/
|
|
265
|
+
filter?: (...args: ClientEvents[E]) => Awaitable<boolean>;
|
|
266
|
+
/**
|
|
267
|
+
* The duration (in ms) that the collector should run for.
|
|
268
|
+
*/
|
|
269
|
+
time?: number;
|
|
270
|
+
/**
|
|
271
|
+
* If the collector should automatically reset the timer when a button is clicked.
|
|
272
|
+
*/
|
|
273
|
+
autoReset?: boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Whether the collector should run only once.
|
|
276
|
+
*/
|
|
277
|
+
once?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* The handler to run when the collector ends.
|
|
280
|
+
*/
|
|
281
|
+
onEnd?: (reason: string) => Awaitable<void>;
|
|
282
|
+
/**
|
|
283
|
+
* The handler to run upon an error.
|
|
284
|
+
*/
|
|
285
|
+
onError?: EventInterceptorErrorHandler;
|
|
274
286
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
* A handler for command validations.
|
|
278
|
-
*/
|
|
279
|
-
declare class ValidationHandler {
|
|
287
|
+
type EventInterceptorErrorHandler = (error: Error) => Awaitable<void>;
|
|
288
|
+
declare class EventInterceptor {
|
|
280
289
|
#private;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Command handler options.
|
|
289
|
-
* Similar to CommandKit options in structure.
|
|
290
|
-
*/
|
|
291
|
-
interface CommandHandlerOptions {
|
|
290
|
+
readonly client: Client;
|
|
291
|
+
private subscribers;
|
|
292
|
+
private globalHandlers;
|
|
293
|
+
private cleanupTimer;
|
|
292
294
|
/**
|
|
293
|
-
*
|
|
295
|
+
* Creates the event interceptor.
|
|
294
296
|
*/
|
|
295
|
-
client: Client;
|
|
297
|
+
constructor(client: Client);
|
|
296
298
|
/**
|
|
297
|
-
*
|
|
299
|
+
* Destroys the event interceptor.
|
|
298
300
|
*/
|
|
299
|
-
|
|
301
|
+
destroy(): void;
|
|
300
302
|
/**
|
|
301
|
-
*
|
|
303
|
+
* Whether the event has subscribers.
|
|
304
|
+
* @param event The event to check.
|
|
302
305
|
*/
|
|
303
|
-
|
|
306
|
+
hasSubscribers(event: keyof ClientEvents): boolean;
|
|
304
307
|
/**
|
|
305
|
-
*
|
|
308
|
+
* Returns the number of subscribers for the event.
|
|
309
|
+
* @param event The event to check.
|
|
306
310
|
*/
|
|
307
|
-
|
|
311
|
+
getSubscriberCount(event: keyof ClientEvents): number;
|
|
308
312
|
/**
|
|
309
|
-
*
|
|
313
|
+
* Whether the event has global handlers.
|
|
310
314
|
*/
|
|
311
|
-
|
|
315
|
+
hasGlobalHandlers(): boolean;
|
|
312
316
|
/**
|
|
313
|
-
*
|
|
317
|
+
* Returns the number of global handlers.
|
|
314
318
|
*/
|
|
315
|
-
|
|
319
|
+
getGlobalHandlersCount(): number;
|
|
316
320
|
/**
|
|
317
|
-
*
|
|
321
|
+
* Subscribes to an event.
|
|
322
|
+
* @param event The event to subscribe to.
|
|
323
|
+
* @param listener The listener to call when the event is emitted.
|
|
324
|
+
* @returns A function to unsubscribe from the event.
|
|
318
325
|
*/
|
|
319
|
-
|
|
326
|
+
subscribe<Event extends keyof ClientEvents>(event: Event, listener: (...args: ClientEvents[Event]) => void, options?: EventInterceptorContextData<Event>): () => void;
|
|
320
327
|
/**
|
|
321
|
-
*
|
|
328
|
+
* Unsubscribes from an event.
|
|
329
|
+
* @param event The event to unsubscribe from.
|
|
322
330
|
*/
|
|
323
|
-
|
|
331
|
+
unsubscribe<Event extends keyof ClientEvents>(event: Event, listener: (...args: ClientEvents[Event]) => void, reason?: string): void;
|
|
324
332
|
/**
|
|
325
|
-
*
|
|
333
|
+
* Creates a global handler for the event.
|
|
334
|
+
* @param event The event to create a global handler for.
|
|
335
|
+
* @returns The global handler.
|
|
326
336
|
*/
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* A handler for client application commands.
|
|
332
|
-
*/
|
|
333
|
-
declare class CommandHandler {
|
|
334
|
-
#private;
|
|
335
|
-
constructor({ ...options }: CommandHandlerOptions);
|
|
336
|
-
init(): Promise<void>;
|
|
337
|
-
handleCommands(): void;
|
|
338
|
-
get commands(): CommandFileObject[];
|
|
339
|
-
reloadCommands(type?: ReloadOptions): Promise<void>;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Event handler options.
|
|
344
|
-
*/
|
|
345
|
-
interface EventHandlerOptions {
|
|
346
|
-
client: Client;
|
|
347
|
-
eventsPath?: string;
|
|
348
|
-
commandKitInstance: CommandKit;
|
|
337
|
+
private createGlobalHandler;
|
|
349
338
|
}
|
|
350
339
|
|
|
340
|
+
type ButtonKitPredicate = (interaction: ButtonInteraction) => Awaitable<boolean>;
|
|
351
341
|
/**
|
|
352
|
-
*
|
|
353
|
-
*
|
|
342
|
+
* The handler to run when a button is clicked. This handler is called with the interaction as the first argument.
|
|
343
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
354
344
|
*/
|
|
355
|
-
type
|
|
345
|
+
type OnButtonKitClick = CommandKitButtonBuilderInteractionCollectorDispatch;
|
|
356
346
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
347
|
+
* The handler to run when the interaction collector ends. This handler is called with the reason as the first argument.
|
|
348
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
359
349
|
*/
|
|
360
|
-
type
|
|
350
|
+
type OnButtonKitEnd = CommandKitButtonBuilderOnEnd;
|
|
361
351
|
/**
|
|
362
|
-
*
|
|
352
|
+
* The handler to run when a button is clicked. This handler is called with the interaction as the first argument.
|
|
353
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
363
354
|
*/
|
|
364
|
-
|
|
355
|
+
type CommandKitButtonBuilderInteractionCollectorDispatch = (interaction: ButtonInteraction, context: ButtonKit) => Awaitable<void>;
|
|
356
|
+
type CommandKitButtonBuilderOnEnd = (reason: string) => Awaitable<void>;
|
|
357
|
+
type CommandKitButtonBuilderInteractionCollectorDispatchContextData = EventInterceptorContextData<Events.InteractionCreate>;
|
|
358
|
+
declare class ButtonKit extends ButtonBuilder {
|
|
359
|
+
#private;
|
|
365
360
|
/**
|
|
366
|
-
*
|
|
361
|
+
* Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
|
|
362
|
+
* If unused, this expires after 24 hours or custom time if specified.
|
|
363
|
+
* @param handler The handler to run when the button is clicked
|
|
364
|
+
* @param data The context data to use for the interaction collector
|
|
365
|
+
* @returns This button
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* const button = new ButtonKit()
|
|
369
|
+
* .setLabel('Click me')
|
|
370
|
+
* .setStyle(ButtonStyle.Primary)
|
|
371
|
+
* .setCustomId('click_me')
|
|
372
|
+
* .filter((interaction) => interaction.user.id === '1234567890')
|
|
373
|
+
* .onClick(async (interaction) => {
|
|
374
|
+
* await interaction.reply('You clicked me!');
|
|
375
|
+
* });
|
|
376
|
+
*
|
|
377
|
+
* const row = new ActionRowBuilder().addComponents(button);
|
|
378
|
+
*
|
|
379
|
+
* const message = await channel.send({ content: 'Click the button', components: [row] });
|
|
380
|
+
*
|
|
381
|
+
* // Remove onClick handler and destroy the interaction collector
|
|
382
|
+
* button.onClick(null);
|
|
383
|
+
* ```
|
|
367
384
|
*/
|
|
368
|
-
|
|
385
|
+
onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data?: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
|
|
386
|
+
onEnd(handler: CommandKitButtonBuilderOnEnd): this;
|
|
369
387
|
/**
|
|
370
|
-
*
|
|
388
|
+
* Sets the handler to run when the interaction collector ends.
|
|
389
|
+
* @param handler - The handler to run when the interaction collector ends.
|
|
390
|
+
* @returns This instance of the modal builder.
|
|
371
391
|
*/
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
name: string;
|
|
381
|
-
/** Absolute file system path to the command file */
|
|
382
|
-
path: string;
|
|
383
|
-
/** Parent command name for nested commands, or null if root-level command */
|
|
384
|
-
parent: string | null;
|
|
385
|
-
/** Array of command segments representing the command hierarchy */
|
|
386
|
-
parentSegments: string[];
|
|
387
|
-
/** Array of middleware IDs that apply to this command */
|
|
388
|
-
middlewares: string[];
|
|
389
|
-
/** Absolute path to this command */
|
|
390
|
-
fullPath: string;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Represents a parsed middleware with its metadata
|
|
394
|
-
* @interface ParsedMiddleware
|
|
395
|
-
*/
|
|
396
|
-
interface ParsedMiddleware {
|
|
397
|
-
/** Unique identifier used to reference this middleware */
|
|
398
|
-
id: string;
|
|
399
|
-
/** Middleware name derived from the file path */
|
|
400
|
-
name: string;
|
|
401
|
-
/** Path to the middleware file, relative to the entrypoint */
|
|
402
|
-
path: string;
|
|
403
|
-
/** Absolute path to the middleware file */
|
|
404
|
-
fullPath: string;
|
|
392
|
+
onError(handler: EventInterceptorErrorHandler): this;
|
|
393
|
+
/**
|
|
394
|
+
* Sets a filter for the interaction collector.
|
|
395
|
+
* @param predicate The filter to use for the interaction collector
|
|
396
|
+
*/
|
|
397
|
+
filter(predicate: ButtonKitPredicate): this;
|
|
398
|
+
private get customId();
|
|
399
|
+
dispose(): this;
|
|
405
400
|
}
|
|
401
|
+
|
|
402
|
+
type ModalKitPredicate = (interaction: ModalSubmitInteraction) => Awaitable<boolean>;
|
|
406
403
|
/**
|
|
407
|
-
*
|
|
408
|
-
*
|
|
404
|
+
* The handler to run when a modal is submitted. This handler is called with the interaction as the first argument.
|
|
405
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
409
406
|
*/
|
|
410
|
-
|
|
411
|
-
/** Map of command names to their parsed metadata */
|
|
412
|
-
commands: Record<string, ParsedCommand>;
|
|
413
|
-
/** Map of middleware IDs to their parsed metadata */
|
|
414
|
-
middleware: Record<string, ParsedMiddleware>;
|
|
415
|
-
}
|
|
407
|
+
type OnModalKitSubmit = CommandKitModalBuilderInteractionCollectorDispatch;
|
|
416
408
|
/**
|
|
417
|
-
*
|
|
418
|
-
*
|
|
409
|
+
* The handler to run when the interaction collector ends. This handler is called with the reason as the first argument.
|
|
410
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
419
411
|
*/
|
|
420
|
-
|
|
421
|
-
/** The matched command metadata */
|
|
422
|
-
command: ParsedCommand;
|
|
423
|
-
/** Array of middleware that apply to the matched command */
|
|
424
|
-
middlewares: ParsedMiddleware[];
|
|
425
|
-
}
|
|
412
|
+
type OnModalKitEnd = CommandKitModalBuilderOnEnd;
|
|
426
413
|
/**
|
|
427
|
-
*
|
|
428
|
-
*
|
|
414
|
+
* The handler to run when a modal is submitted. This handler is called with the interaction as the first argument.
|
|
415
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
429
416
|
*/
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
* Creates a new CommandsRouter instance
|
|
436
|
-
* @param options - Configuration options for the router
|
|
437
|
-
*/
|
|
438
|
-
constructor(options: CommandsRouterOptions);
|
|
417
|
+
type CommandKitModalBuilderInteractionCollectorDispatch = (interaction: ModalSubmitInteraction, context: ModalKit) => Awaitable<void>;
|
|
418
|
+
type CommandKitModalBuilderOnEnd = (reason: string) => Awaitable<void>;
|
|
419
|
+
type CommandKitModalBuilderInteractionCollectorDispatchContextData = EventInterceptorContextData<Events.InteractionCreate>;
|
|
420
|
+
declare class ModalKit extends ModalBuilder {
|
|
421
|
+
#private;
|
|
439
422
|
/**
|
|
440
|
-
*
|
|
423
|
+
* Sets the handler to run when the modal is submitted.
|
|
424
|
+
* @param handler - The handler to run when the modal is submitted.
|
|
425
|
+
* @param data - The context data for the interaction collector.
|
|
426
|
+
* @returns This instance of the modal builder.
|
|
427
|
+
* @example
|
|
428
|
+
* ```ts
|
|
429
|
+
* const modal = new ModalKit()
|
|
430
|
+
* .setTitle('My Modal')
|
|
431
|
+
* .setCustomId('my-modal')
|
|
432
|
+
* .filter((interaction) => interaction.user.id === '1234567890')
|
|
433
|
+
* .onSubmit(async (interaction) => {
|
|
434
|
+
* await interaction.reply('You submitted the modal!');
|
|
435
|
+
* })
|
|
436
|
+
* .addComponents(actionRow1, actionRow2);
|
|
437
|
+
* ```
|
|
441
438
|
*/
|
|
442
|
-
|
|
439
|
+
onSubmit(handler: CommandKitModalBuilderInteractionCollectorDispatch, data?: CommandKitModalBuilderInteractionCollectorDispatchContextData): this;
|
|
443
440
|
/**
|
|
444
|
-
*
|
|
441
|
+
* Sets the handler to run when the interaction collector ends.
|
|
442
|
+
* @param handler - The handler to run when the interaction collector ends.
|
|
443
|
+
* @returns This instance of the modal builder.
|
|
445
444
|
*/
|
|
446
|
-
|
|
445
|
+
onEnd(handler: CommandKitModalBuilderOnEnd): this;
|
|
447
446
|
/**
|
|
448
|
-
*
|
|
447
|
+
* Sets the handler to run when the interaction collector ends.
|
|
448
|
+
* @param handler - The handler to run when the interaction collector ends.
|
|
449
|
+
* @returns This instance of the modal builder.
|
|
449
450
|
*/
|
|
450
|
-
|
|
451
|
-
commands: Map<string, ParsedCommand>;
|
|
452
|
-
middleware: Map<string, ParsedMiddleware>;
|
|
453
|
-
};
|
|
451
|
+
onError(handler: EventInterceptorErrorHandler): this;
|
|
454
452
|
/**
|
|
455
|
-
*
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Executes a matcher against a file path
|
|
460
|
-
* @param matcher - The matcher to use
|
|
461
|
-
* @param path - The file path to test
|
|
462
|
-
* @returns boolean indicating if the path matches
|
|
463
|
-
*/
|
|
464
|
-
private execMatcher;
|
|
465
|
-
/**
|
|
466
|
-
* Converts an absolute path to a path relative to the entrypoint
|
|
467
|
-
* @param path - The absolute path to convert
|
|
468
|
-
*/
|
|
469
|
-
private resolveRelativePath;
|
|
470
|
-
/**
|
|
471
|
-
* Matches a command by name or path segments
|
|
472
|
-
* @param commandOrSegment - Command name or array of path segments
|
|
473
|
-
* @returns Matched command and its middlewares, or null if no match
|
|
474
|
-
*/
|
|
475
|
-
match(commandOrSegment: string | string[]): CommandMatchResult | null;
|
|
476
|
-
/**
|
|
477
|
-
* Reloads the commands tree by re-scanning the entrypoint directory
|
|
478
|
-
*/
|
|
479
|
-
reload(): Promise<CommandsTree>;
|
|
480
|
-
/**
|
|
481
|
-
* Clears the internal commands and middleware maps
|
|
482
|
-
*/
|
|
483
|
-
clear(): void;
|
|
484
|
-
/**
|
|
485
|
-
* Scans the entrypoint directory for commands and middleware
|
|
486
|
-
* @returns Promise resolving to the complete commands tree
|
|
487
|
-
*/
|
|
488
|
-
scan(): Promise<CommandsTree>;
|
|
489
|
-
/**
|
|
490
|
-
* Converts the internal maps to a serializable object
|
|
491
|
-
* @returns CommandsTree containing all commands and middleware
|
|
492
|
-
*/
|
|
493
|
-
toJSON(): CommandsTree;
|
|
494
|
-
/**
|
|
495
|
-
* Recursively scans a directory for files
|
|
496
|
-
* @param dir - Directory to scan
|
|
497
|
-
* @param entries - Accumulator for found files
|
|
498
|
-
* @returns Promise resolving to array of file paths
|
|
499
|
-
*/
|
|
500
|
-
private scanDirectory;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Configuration options for the EventsRouter
|
|
505
|
-
* @interface EventsRouterOptions
|
|
506
|
-
*/
|
|
507
|
-
interface EventsRouterOptions {
|
|
508
|
-
/** Root directory path where event handlers are located */
|
|
509
|
-
entrypoint: string;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Represents a parsed event with its handlers
|
|
513
|
-
* @interface ParsedEvent
|
|
514
|
-
*/
|
|
515
|
-
interface ParsedEvent {
|
|
516
|
-
/** Name of the event derived from directory name */
|
|
517
|
-
event: string;
|
|
518
|
-
/** Absolute path to the event directory */
|
|
519
|
-
path: string;
|
|
520
|
-
/** Array of file paths to event listener handlers */
|
|
521
|
-
listeners: string[];
|
|
522
|
-
}
|
|
523
|
-
/** Map of event names to their parsed metadata */
|
|
524
|
-
type EventsTree = Record<string, ParsedEvent>;
|
|
525
|
-
/**
|
|
526
|
-
* Router for discovering and managing event handler files in a directory structure.
|
|
527
|
-
* Events are represented by directories, and handlers are files within those directories.
|
|
528
|
-
*/
|
|
529
|
-
declare class EventsRouter {
|
|
530
|
-
private options;
|
|
531
|
-
/** Internal storage of parsed events */
|
|
532
|
-
private events;
|
|
533
|
-
/**
|
|
534
|
-
* Creates a new EventsRouter instance
|
|
535
|
-
* @param options - Configuration options for the router
|
|
536
|
-
* @throws Error if entrypoint is not provided
|
|
537
|
-
*/
|
|
538
|
-
constructor(options: EventsRouterOptions);
|
|
539
|
-
/**
|
|
540
|
-
* Find a parsed event by its name
|
|
541
|
-
* @param event - Name of the event to find
|
|
542
|
-
* @returns Parsed event metadata or null if not found
|
|
543
|
-
*/
|
|
544
|
-
match(event: string): ParsedEvent | null;
|
|
545
|
-
/**
|
|
546
|
-
* Get the entrypoint directory path
|
|
547
|
-
* @returns Entrypoint directory path
|
|
548
|
-
*/
|
|
549
|
-
get entrypoint(): string;
|
|
550
|
-
/**
|
|
551
|
-
* Checks if the entrypoint path is valid
|
|
552
|
-
*/
|
|
553
|
-
isValidPath(): boolean;
|
|
554
|
-
/**
|
|
555
|
-
* Clear all parsed events
|
|
556
|
-
*/
|
|
557
|
-
clear(): void;
|
|
558
|
-
/**
|
|
559
|
-
* Reload and re-scan the entrypoint directory for events
|
|
560
|
-
* @returns Promise resolving to the updated events tree
|
|
561
|
-
*/
|
|
562
|
-
reload(): Promise<EventsTree>;
|
|
563
|
-
/**
|
|
564
|
-
* Scan the entrypoint directory for events and their handlers
|
|
565
|
-
* @returns Promise resolving to the events tree
|
|
566
|
-
*/
|
|
567
|
-
scan(): Promise<EventsTree>;
|
|
568
|
-
/**
|
|
569
|
-
* Convert the internal events map to a plain object
|
|
570
|
-
* @returns Events tree as a plain object
|
|
571
|
-
*/
|
|
572
|
-
toJSON(): EventsTree;
|
|
573
|
-
/**
|
|
574
|
-
* Recursively scan a directory for event handlers
|
|
575
|
-
* @param event - Name of the event
|
|
576
|
-
* @param path - Path to the event directory
|
|
577
|
-
* @param listeners - Array to collect listener file paths
|
|
578
|
-
* @returns Promise resolving to the parsed event metadata
|
|
579
|
-
*/
|
|
580
|
-
private scanEvent;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
/**
|
|
584
|
-
* A handler for client events.
|
|
585
|
-
*/
|
|
586
|
-
declare class EventHandler {
|
|
587
|
-
#private;
|
|
588
|
-
constructor({ ...options }: EventHandlerOptions);
|
|
589
|
-
init(): Promise<void>;
|
|
590
|
-
registerExternal(entry: ParsedEvent): Promise<void>;
|
|
591
|
-
resyncListeners(): void;
|
|
592
|
-
get events(): {
|
|
593
|
-
name: string;
|
|
594
|
-
functions: Function[];
|
|
595
|
-
}[];
|
|
596
|
-
reloadEvents(commandHandler?: CommandHandler): Promise<void>;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
interface EventInterceptorContextData<E extends keyof ClientEvents> {
|
|
600
|
-
/**
|
|
601
|
-
* The filter to use for the collector.
|
|
602
|
-
*/
|
|
603
|
-
filter?: (...args: ClientEvents[E]) => Awaitable<boolean>;
|
|
604
|
-
/**
|
|
605
|
-
* The duration (in ms) that the collector should run for.
|
|
606
|
-
*/
|
|
607
|
-
time?: number;
|
|
608
|
-
/**
|
|
609
|
-
* If the collector should automatically reset the timer when a button is clicked.
|
|
610
|
-
*/
|
|
611
|
-
autoReset?: boolean;
|
|
612
|
-
/**
|
|
613
|
-
* Whether the collector should run only once.
|
|
614
|
-
*/
|
|
615
|
-
once?: boolean;
|
|
616
|
-
/**
|
|
617
|
-
* The handler to run when the collector ends.
|
|
618
|
-
*/
|
|
619
|
-
onEnd?: (reason: string) => Awaitable<void>;
|
|
620
|
-
/**
|
|
621
|
-
* The handler to run upon an error.
|
|
622
|
-
*/
|
|
623
|
-
onError?: EventInterceptorErrorHandler;
|
|
624
|
-
}
|
|
625
|
-
type EventInterceptorErrorHandler = (error: Error) => Awaitable<void>;
|
|
626
|
-
declare class EventInterceptor {
|
|
627
|
-
#private;
|
|
628
|
-
readonly client: Client;
|
|
629
|
-
private subscribers;
|
|
630
|
-
private globalHandlers;
|
|
631
|
-
private cleanupTimer;
|
|
632
|
-
/**
|
|
633
|
-
* Creates the event interceptor.
|
|
634
|
-
*/
|
|
635
|
-
constructor(client: Client);
|
|
636
|
-
/**
|
|
637
|
-
* Destroys the event interceptor.
|
|
638
|
-
*/
|
|
639
|
-
destroy(): void;
|
|
640
|
-
/**
|
|
641
|
-
* Whether the event has subscribers.
|
|
642
|
-
* @param event The event to check.
|
|
643
|
-
*/
|
|
644
|
-
hasSubscribers(event: keyof ClientEvents): boolean;
|
|
645
|
-
/**
|
|
646
|
-
* Returns the number of subscribers for the event.
|
|
647
|
-
* @param event The event to check.
|
|
648
|
-
*/
|
|
649
|
-
getSubscriberCount(event: keyof ClientEvents): number;
|
|
650
|
-
/**
|
|
651
|
-
* Whether the event has global handlers.
|
|
652
|
-
*/
|
|
653
|
-
hasGlobalHandlers(): boolean;
|
|
654
|
-
/**
|
|
655
|
-
* Returns the number of global handlers.
|
|
656
|
-
*/
|
|
657
|
-
getGlobalHandlersCount(): number;
|
|
658
|
-
/**
|
|
659
|
-
* Subscribes to an event.
|
|
660
|
-
* @param event The event to subscribe to.
|
|
661
|
-
* @param listener The listener to call when the event is emitted.
|
|
662
|
-
* @returns A function to unsubscribe from the event.
|
|
663
|
-
*/
|
|
664
|
-
subscribe<Event extends keyof ClientEvents>(event: Event, listener: (...args: ClientEvents[Event]) => void, options?: EventInterceptorContextData<Event>): () => void;
|
|
665
|
-
/**
|
|
666
|
-
* Unsubscribes from an event.
|
|
667
|
-
* @param event The event to unsubscribe from.
|
|
668
|
-
*/
|
|
669
|
-
unsubscribe<Event extends keyof ClientEvents>(event: Event, listener: (...args: ClientEvents[Event]) => void, reason?: string): void;
|
|
670
|
-
/**
|
|
671
|
-
* Creates a global handler for the event.
|
|
672
|
-
* @param event The event to create a global handler for.
|
|
673
|
-
* @returns The global handler.
|
|
674
|
-
*/
|
|
675
|
-
private createGlobalHandler;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
type ButtonKitPredicate = (interaction: ButtonInteraction) => Awaitable<boolean>;
|
|
679
|
-
/**
|
|
680
|
-
* The handler to run when a button is clicked. This handler is called with the interaction as the first argument.
|
|
681
|
-
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
682
|
-
*/
|
|
683
|
-
type OnButtonKitClick = CommandKitButtonBuilderInteractionCollectorDispatch;
|
|
684
|
-
/**
|
|
685
|
-
* The handler to run when the interaction collector ends. This handler is called with the reason as the first argument.
|
|
686
|
-
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
687
|
-
*/
|
|
688
|
-
type OnButtonKitEnd = CommandKitButtonBuilderOnEnd;
|
|
689
|
-
/**
|
|
690
|
-
* The handler to run when a button is clicked. This handler is called with the interaction as the first argument.
|
|
691
|
-
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
692
|
-
*/
|
|
693
|
-
type CommandKitButtonBuilderInteractionCollectorDispatch = (interaction: ButtonInteraction, context: ButtonKit) => Awaitable<void>;
|
|
694
|
-
type CommandKitButtonBuilderOnEnd = (reason: string) => Awaitable<void>;
|
|
695
|
-
type CommandKitButtonBuilderInteractionCollectorDispatchContextData = EventInterceptorContextData<Events.InteractionCreate>;
|
|
696
|
-
declare class ButtonKit extends ButtonBuilder {
|
|
697
|
-
#private;
|
|
698
|
-
/**
|
|
699
|
-
* Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
|
|
700
|
-
* If unused, this expires after 24 hours or custom time if specified.
|
|
701
|
-
* @param handler The handler to run when the button is clicked
|
|
702
|
-
* @param data The context data to use for the interaction collector
|
|
703
|
-
* @returns This button
|
|
704
|
-
* @example
|
|
705
|
-
* ```ts
|
|
706
|
-
* const button = new ButtonKit()
|
|
707
|
-
* .setLabel('Click me')
|
|
708
|
-
* .setStyle(ButtonStyle.Primary)
|
|
709
|
-
* .setCustomId('click_me')
|
|
710
|
-
* .filter((interaction) => interaction.user.id === '1234567890')
|
|
711
|
-
* .onClick(async (interaction) => {
|
|
712
|
-
* await interaction.reply('You clicked me!');
|
|
713
|
-
* });
|
|
714
|
-
*
|
|
715
|
-
* const row = new ActionRowBuilder().addComponents(button);
|
|
716
|
-
*
|
|
717
|
-
* const message = await channel.send({ content: 'Click the button', components: [row] });
|
|
718
|
-
*
|
|
719
|
-
* // Remove onClick handler and destroy the interaction collector
|
|
720
|
-
* button.onClick(null);
|
|
721
|
-
* ```
|
|
722
|
-
*/
|
|
723
|
-
onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data?: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
|
|
724
|
-
onEnd(handler: CommandKitButtonBuilderOnEnd): this;
|
|
725
|
-
/**
|
|
726
|
-
* Sets the handler to run when the interaction collector ends.
|
|
727
|
-
* @param handler - The handler to run when the interaction collector ends.
|
|
728
|
-
* @returns This instance of the modal builder.
|
|
729
|
-
*/
|
|
730
|
-
onError(handler: EventInterceptorErrorHandler): this;
|
|
731
|
-
/**
|
|
732
|
-
* Sets a filter for the interaction collector.
|
|
733
|
-
* @param predicate The filter to use for the interaction collector
|
|
734
|
-
*/
|
|
735
|
-
filter(predicate: ButtonKitPredicate): this;
|
|
736
|
-
private get customId();
|
|
737
|
-
dispose(): this;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
type ModalKitPredicate = (interaction: ModalSubmitInteraction) => Awaitable<boolean>;
|
|
741
|
-
/**
|
|
742
|
-
* The handler to run when a modal is submitted. This handler is called with the interaction as the first argument.
|
|
743
|
-
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
744
|
-
*/
|
|
745
|
-
type OnModalKitSubmit = CommandKitModalBuilderInteractionCollectorDispatch;
|
|
746
|
-
/**
|
|
747
|
-
* The handler to run when the interaction collector ends. This handler is called with the reason as the first argument.
|
|
748
|
-
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
749
|
-
*/
|
|
750
|
-
type OnModalKitEnd = CommandKitModalBuilderOnEnd;
|
|
751
|
-
/**
|
|
752
|
-
* The handler to run when a modal is submitted. This handler is called with the interaction as the first argument.
|
|
753
|
-
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
754
|
-
*/
|
|
755
|
-
type CommandKitModalBuilderInteractionCollectorDispatch = (interaction: ModalSubmitInteraction, context: ModalKit) => Awaitable<void>;
|
|
756
|
-
type CommandKitModalBuilderOnEnd = (reason: string) => Awaitable<void>;
|
|
757
|
-
type CommandKitModalBuilderInteractionCollectorDispatchContextData = EventInterceptorContextData<Events.InteractionCreate>;
|
|
758
|
-
declare class ModalKit extends ModalBuilder {
|
|
759
|
-
#private;
|
|
760
|
-
/**
|
|
761
|
-
* Sets the handler to run when the modal is submitted.
|
|
762
|
-
* @param handler - The handler to run when the modal is submitted.
|
|
763
|
-
* @param data - The context data for the interaction collector.
|
|
764
|
-
* @returns This instance of the modal builder.
|
|
765
|
-
* @example
|
|
766
|
-
* ```ts
|
|
767
|
-
* const modal = new ModalKit()
|
|
768
|
-
* .setTitle('My Modal')
|
|
769
|
-
* .setCustomId('my-modal')
|
|
770
|
-
* .filter((interaction) => interaction.user.id === '1234567890')
|
|
771
|
-
* .onSubmit(async (interaction) => {
|
|
772
|
-
* await interaction.reply('You submitted the modal!');
|
|
773
|
-
* })
|
|
774
|
-
* .addComponents(actionRow1, actionRow2);
|
|
775
|
-
* ```
|
|
776
|
-
*/
|
|
777
|
-
onSubmit(handler: CommandKitModalBuilderInteractionCollectorDispatch, data?: CommandKitModalBuilderInteractionCollectorDispatchContextData): this;
|
|
778
|
-
/**
|
|
779
|
-
* Sets the handler to run when the interaction collector ends.
|
|
780
|
-
* @param handler - The handler to run when the interaction collector ends.
|
|
781
|
-
* @returns This instance of the modal builder.
|
|
782
|
-
*/
|
|
783
|
-
onEnd(handler: CommandKitModalBuilderOnEnd): this;
|
|
784
|
-
/**
|
|
785
|
-
* Sets the handler to run when the interaction collector ends.
|
|
786
|
-
* @param handler - The handler to run when the interaction collector ends.
|
|
787
|
-
* @returns This instance of the modal builder.
|
|
788
|
-
*/
|
|
789
|
-
onError(handler: EventInterceptorErrorHandler): this;
|
|
790
|
-
/**
|
|
791
|
-
* Sets a filter for the interaction collector.
|
|
792
|
-
* @param predicate - The filter to use for the interaction collector.
|
|
793
|
-
* @returns This instance of the modal builder.
|
|
453
|
+
* Sets a filter for the interaction collector.
|
|
454
|
+
* @param predicate - The filter to use for the interaction collector.
|
|
455
|
+
* @returns This instance of the modal builder.
|
|
794
456
|
*/
|
|
795
457
|
filter(predicate: ModalKitPredicate): this;
|
|
796
458
|
private get customId();
|
|
@@ -990,10 +652,10 @@ interface ParsedMessageCommand {
|
|
|
990
652
|
type MessageCommandOptionsSchema = Record<string, ApplicationCommandOptionType>;
|
|
991
653
|
declare class MessageCommandParser {
|
|
992
654
|
#private;
|
|
993
|
-
message: Message;
|
|
655
|
+
message: Message$1;
|
|
994
656
|
private prefix;
|
|
995
657
|
private schema;
|
|
996
|
-
constructor(message: Message, prefix: string[], schema: (command: string) => MessageCommandOptionsSchema);
|
|
658
|
+
constructor(message: Message$1, prefix: string[], schema: (command: string) => MessageCommandOptionsSchema);
|
|
997
659
|
getArgs(): string[];
|
|
998
660
|
get options(): MessageCommandOptions;
|
|
999
661
|
getOption<T>(name: string): T | undefined;
|
|
@@ -1184,7 +846,7 @@ interface ContextParameters<T extends CommandExecutionMode> {
|
|
|
1184
846
|
environment?: CommandKitEnvironment;
|
|
1185
847
|
executionMode: T;
|
|
1186
848
|
interaction: T extends 'chatInput' ? ChatInputCommandInteraction : T extends 'messageContextMenu' ? MessageContextMenuCommandInteraction : T extends 'userContextMenu' ? UserContextMenuCommandInteraction : T extends 'autocomplete' ? AutocompleteInteraction : never;
|
|
1187
|
-
message: T extends 'message' ? Message : never;
|
|
849
|
+
message: T extends 'message' ? Message$1 : never;
|
|
1188
850
|
forwarded?: boolean;
|
|
1189
851
|
messageCommandParser?: T extends 'message' ? MessageCommandParser : never;
|
|
1190
852
|
store?: Map<string, any>;
|
|
@@ -1219,130 +881,398 @@ declare class Context<ExecutionMode extends CommandExecutionMode = CommandExecut
|
|
|
1219
881
|
/**
|
|
1220
882
|
* The message that triggered the command.
|
|
1221
883
|
*/
|
|
1222
|
-
readonly message: ContextParameters<ExecutionMode>['message'];
|
|
884
|
+
readonly message: ContextParameters<ExecutionMode>['message'];
|
|
885
|
+
/**
|
|
886
|
+
* The client instance.
|
|
887
|
+
*/
|
|
888
|
+
readonly client: Client;
|
|
889
|
+
private _locale;
|
|
890
|
+
/**
|
|
891
|
+
* Creates a new command context.
|
|
892
|
+
* @param commandkit The command kit instance.
|
|
893
|
+
* @param config The context parameters.
|
|
894
|
+
*/
|
|
895
|
+
constructor(commandkit: CommandKit, config: ContextParameters<ExecutionMode>);
|
|
896
|
+
/**
|
|
897
|
+
* The shared key-value store for this context. This can be used to store data that needs to be shared between middlewares or commands.
|
|
898
|
+
* This store is shared across all contexts in the same command execution, including the cloned contexts and middleware contexts.
|
|
899
|
+
*/
|
|
900
|
+
get store(): Map<string, any>;
|
|
901
|
+
get commandName(): string;
|
|
902
|
+
get options(): CommandContextOptions<ExecutionMode>;
|
|
903
|
+
/**
|
|
904
|
+
* Whether this context was forwarded from another context. This happens when a command forwards its context to another command.
|
|
905
|
+
*/
|
|
906
|
+
get forwarded(): boolean;
|
|
907
|
+
/**
|
|
908
|
+
* Forwards the context to another command. The target handler will be the same as current handler.
|
|
909
|
+
* @param command The command to forward to.
|
|
910
|
+
*/
|
|
911
|
+
forwardCommand(command: string): Promise<never>;
|
|
912
|
+
/**
|
|
913
|
+
* The execution mode of the command.
|
|
914
|
+
*/
|
|
915
|
+
get executionMode(): ExecutionMode;
|
|
916
|
+
/**
|
|
917
|
+
* Whether the command was triggered by an interaction.
|
|
918
|
+
*/
|
|
919
|
+
isInteraction(): this is InteractionCommandContext;
|
|
920
|
+
/**
|
|
921
|
+
* Whether the command was triggered by a slash command interaction.
|
|
922
|
+
*/
|
|
923
|
+
isSlashCommand(): this is SlashCommandContext;
|
|
924
|
+
/**
|
|
925
|
+
* Whether the command was triggered by an autocomplete interaction.
|
|
926
|
+
*/
|
|
927
|
+
isAutocomplete(): this is AutocompleteCommandContext;
|
|
928
|
+
/**
|
|
929
|
+
* Whether the command was triggered by a message context menu interaction.
|
|
930
|
+
*/
|
|
931
|
+
isMessageContextMenu(): this is MessageContextMenuCommandContext;
|
|
932
|
+
/**
|
|
933
|
+
* Whether the command was triggered by a user context menu interaction.
|
|
934
|
+
*/
|
|
935
|
+
isUserContextMenu(): this is UserContextMenuCommandContext;
|
|
936
|
+
/**
|
|
937
|
+
* Whether the command was triggered by a message.
|
|
938
|
+
*/
|
|
939
|
+
isMessage(): this is Context<'message'>;
|
|
940
|
+
/**
|
|
941
|
+
* Returns the command identifier.
|
|
942
|
+
*/
|
|
943
|
+
getCommandIdentifier(): string;
|
|
944
|
+
/**
|
|
945
|
+
* Returns the locale of the guild where this command was triggered.
|
|
946
|
+
*/
|
|
947
|
+
getGuildLocale(): Locale | null;
|
|
948
|
+
/**
|
|
949
|
+
* Returns the locale of the user who triggered this command.
|
|
950
|
+
*/
|
|
951
|
+
getUserLocale(): Locale | null;
|
|
952
|
+
/**
|
|
953
|
+
* Returns the locale for this command.
|
|
954
|
+
* @param preferUser Whether to prefer the user's locale over the guild's locale.
|
|
955
|
+
* @returns The locale for this command. If no locale is found, the default locale is returned.
|
|
956
|
+
*/
|
|
957
|
+
getLocale(preferUser?: boolean): Locale;
|
|
958
|
+
/**
|
|
959
|
+
* Sets the locale for this command.
|
|
960
|
+
* @param locale The locale to set.
|
|
961
|
+
*/
|
|
962
|
+
setLocale(locale: Locale | null): void;
|
|
963
|
+
/**
|
|
964
|
+
* Returns the i18n api for this command.
|
|
965
|
+
* @param locale The locale to use for the i18n api.
|
|
966
|
+
*/
|
|
967
|
+
locale(locale?: Locale): Localization;
|
|
968
|
+
/**
|
|
969
|
+
* Creates a clone of this context
|
|
970
|
+
*/
|
|
971
|
+
clone(config?: Partial<ContextParameters<ExecutionMode>>): Context<ExecutionMode>;
|
|
972
|
+
isMiddleware(): this is MiddlewareContext<ExecutionMode>;
|
|
973
|
+
args(): string[];
|
|
974
|
+
/**
|
|
975
|
+
* Stops upcoming middleware or current command execution.
|
|
976
|
+
* If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.
|
|
977
|
+
* If this is called inside a command itself, it will skip all post-stage middlewares.
|
|
978
|
+
* If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
|
|
979
|
+
*/
|
|
980
|
+
exit(): void;
|
|
981
|
+
/**
|
|
982
|
+
* Defers the given function to be executed after this command's execution.
|
|
983
|
+
* @param fn The function to defer.
|
|
984
|
+
* @returns A unique identifier for the deferred function.
|
|
985
|
+
*/
|
|
986
|
+
defer(fn: GenericFunction<[CommandKitEnvironment]>): string;
|
|
987
|
+
/**
|
|
988
|
+
* Cancels the deferred function with the given identifier.
|
|
989
|
+
* @param id The identifier of the deferred function.
|
|
990
|
+
*/
|
|
991
|
+
cancelDeferred(id: string): void;
|
|
992
|
+
/**
|
|
993
|
+
* Validates if the given function is a cached function.
|
|
994
|
+
* @param fn The function to validate.
|
|
995
|
+
*/
|
|
996
|
+
isCached(fn: GenericFunction): boolean;
|
|
997
|
+
}
|
|
998
|
+
declare class MiddlewareContext<T extends CommandExecutionMode = CommandExecutionMode> extends Context<T> {
|
|
999
|
+
#private;
|
|
1000
|
+
/**
|
|
1001
|
+
* Whether the command execution was cancelled.
|
|
1002
|
+
*/
|
|
1003
|
+
get cancelled(): boolean;
|
|
1004
|
+
/**
|
|
1005
|
+
* Cancels the command execution.
|
|
1006
|
+
*/
|
|
1007
|
+
cancel(): void;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* Matcher type for identifying command and middleware files.
|
|
1012
|
+
* Can be a string suffix (e.g. '.cmd.js'), RegExp pattern, or custom matcher function.
|
|
1013
|
+
*/
|
|
1014
|
+
type CommandsRouterMatcher = string | RegExp | ((path: string) => boolean);
|
|
1015
|
+
/**
|
|
1016
|
+
* Maps file type identifiers to their respective matchers.
|
|
1017
|
+
* Used to identify command and middleware files in the directory structure.
|
|
1018
|
+
*/
|
|
1019
|
+
type CommandsRouterMatchersMap = Record<'command' | 'middleware', CommandsRouterMatcher>;
|
|
1020
|
+
/**
|
|
1021
|
+
* Configuration options for the CommandsRouter
|
|
1022
|
+
*/
|
|
1023
|
+
interface CommandsRouterOptions {
|
|
1024
|
+
/**
|
|
1025
|
+
* The path to the directory containing the command files.
|
|
1026
|
+
*/
|
|
1027
|
+
entrypoint: string;
|
|
1028
|
+
/**
|
|
1029
|
+
* The path to the directory containing the middleware files.
|
|
1030
|
+
*/
|
|
1031
|
+
matcher?: Partial<CommandsRouterMatchersMap>;
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Represents a parsed command with its metadata
|
|
1035
|
+
* @interface ParsedCommand
|
|
1036
|
+
*/
|
|
1037
|
+
interface ParsedCommand {
|
|
1038
|
+
/** Command name derived from the file name without extension */
|
|
1039
|
+
name: string;
|
|
1040
|
+
/** Absolute file system path to the command file */
|
|
1041
|
+
path: string;
|
|
1042
|
+
/** Parent command name for nested commands, or null if root-level command */
|
|
1043
|
+
parent: string | null;
|
|
1044
|
+
/** Array of command segments representing the command hierarchy */
|
|
1045
|
+
parentSegments: string[];
|
|
1046
|
+
/** Array of middleware IDs that apply to this command */
|
|
1047
|
+
middlewares: string[];
|
|
1048
|
+
/** Absolute path to this command */
|
|
1049
|
+
fullPath: string;
|
|
1050
|
+
/** Category the command belongs to, if any */
|
|
1051
|
+
category: string | null;
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Represents a parsed middleware with its metadata
|
|
1055
|
+
* @interface ParsedMiddleware
|
|
1056
|
+
*/
|
|
1057
|
+
interface ParsedMiddleware {
|
|
1058
|
+
/** Unique identifier used to reference this middleware */
|
|
1059
|
+
id: string;
|
|
1060
|
+
/** Middleware name derived from the file path */
|
|
1061
|
+
name: string;
|
|
1062
|
+
/** Path to the middleware file, relative to the entrypoint */
|
|
1063
|
+
path: string;
|
|
1064
|
+
/** Absolute path to the middleware file */
|
|
1065
|
+
fullPath: string;
|
|
1066
|
+
/** Category the middleware belongs to, if any */
|
|
1067
|
+
category: string | null;
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Complete tree structure of all commands and middleware
|
|
1071
|
+
* @interface CommandsTree
|
|
1072
|
+
*/
|
|
1073
|
+
interface CommandsTree {
|
|
1074
|
+
/** Map of command names to their parsed metadata */
|
|
1075
|
+
commands: Record<string, ParsedCommand>;
|
|
1076
|
+
/** Map of middleware IDs to their parsed metadata */
|
|
1077
|
+
middleware: Record<string, ParsedMiddleware>;
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Result of a successful command match operation
|
|
1081
|
+
* @interface CommandMatchResult
|
|
1082
|
+
*/
|
|
1083
|
+
interface CommandMatchResult {
|
|
1084
|
+
/** The matched command metadata */
|
|
1085
|
+
command: ParsedCommand;
|
|
1086
|
+
/** Array of middleware that apply to the matched command */
|
|
1087
|
+
middlewares: ParsedMiddleware[];
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* CommandsRouter handles the discovery and routing of commands and middleware files
|
|
1091
|
+
* in a directory structure. It supports nested commands and middleware inheritance.
|
|
1092
|
+
*/
|
|
1093
|
+
declare class CommandsRouter {
|
|
1094
|
+
private readonly options;
|
|
1095
|
+
private commands;
|
|
1096
|
+
private middlewares;
|
|
1097
|
+
/**
|
|
1098
|
+
* Creates a new CommandsRouter instance
|
|
1099
|
+
* @param options - Configuration options for the router
|
|
1100
|
+
*/
|
|
1101
|
+
constructor(options: CommandsRouterOptions);
|
|
1102
|
+
/**
|
|
1103
|
+
* Gets the configured entrypoint directory
|
|
1104
|
+
*/
|
|
1105
|
+
get entrypoint(): string;
|
|
1223
1106
|
/**
|
|
1224
|
-
*
|
|
1107
|
+
* Gets the configured matchers for command and middleware files
|
|
1225
1108
|
*/
|
|
1226
|
-
|
|
1227
|
-
private _locale;
|
|
1109
|
+
get matchers(): CommandsRouterMatchersMap;
|
|
1228
1110
|
/**
|
|
1229
|
-
*
|
|
1230
|
-
* @param commandkit The command kit instance.
|
|
1231
|
-
* @param config The context parameters.
|
|
1111
|
+
* Returns the cached data of the commands and middleware
|
|
1232
1112
|
*/
|
|
1233
|
-
|
|
1113
|
+
getData(): {
|
|
1114
|
+
commands: Map<string, ParsedCommand>;
|
|
1115
|
+
middleware: Map<string, ParsedMiddleware>;
|
|
1116
|
+
};
|
|
1234
1117
|
/**
|
|
1235
|
-
*
|
|
1236
|
-
* This store is shared across all contexts in the same command execution, including the cloned contexts and middleware contexts.
|
|
1118
|
+
* Checks if the entrypoint path is valid
|
|
1237
1119
|
*/
|
|
1238
|
-
|
|
1239
|
-
get commandName(): string;
|
|
1240
|
-
get options(): CommandContextOptions<ExecutionMode>;
|
|
1120
|
+
isValidPath(): boolean;
|
|
1241
1121
|
/**
|
|
1242
|
-
*
|
|
1122
|
+
* Executes a matcher against a file path
|
|
1123
|
+
* @param matcher - The matcher to use
|
|
1124
|
+
* @param path - The file path to test
|
|
1125
|
+
* @returns boolean indicating if the path matches
|
|
1243
1126
|
*/
|
|
1244
|
-
|
|
1127
|
+
private execMatcher;
|
|
1245
1128
|
/**
|
|
1246
|
-
*
|
|
1247
|
-
* @param
|
|
1129
|
+
* Converts an absolute path to a path relative to the entrypoint
|
|
1130
|
+
* @param path - The absolute path to convert
|
|
1248
1131
|
*/
|
|
1249
|
-
|
|
1132
|
+
private resolveRelativePath;
|
|
1250
1133
|
/**
|
|
1251
|
-
*
|
|
1134
|
+
* Matches a command by name or path segments
|
|
1135
|
+
* @param commandOrSegment - Command name or array of path segments
|
|
1136
|
+
* @returns Matched command and its middlewares, or null if no match
|
|
1252
1137
|
*/
|
|
1253
|
-
|
|
1138
|
+
match(commandOrSegment: string | string[]): CommandMatchResult | null;
|
|
1254
1139
|
/**
|
|
1255
|
-
*
|
|
1140
|
+
* Reloads the commands tree by re-scanning the entrypoint directory
|
|
1256
1141
|
*/
|
|
1257
|
-
|
|
1142
|
+
reload(): Promise<CommandsTree>;
|
|
1258
1143
|
/**
|
|
1259
|
-
*
|
|
1144
|
+
* Clears the internal commands and middleware maps
|
|
1260
1145
|
*/
|
|
1261
|
-
|
|
1146
|
+
clear(): void;
|
|
1262
1147
|
/**
|
|
1263
|
-
*
|
|
1148
|
+
* Scans the entrypoint directory for commands and middleware
|
|
1149
|
+
* @returns Promise resolving to the complete commands tree
|
|
1264
1150
|
*/
|
|
1265
|
-
|
|
1151
|
+
scan(): Promise<CommandsTree>;
|
|
1266
1152
|
/**
|
|
1267
|
-
*
|
|
1153
|
+
* Converts the internal maps to a serializable object
|
|
1154
|
+
* @returns CommandsTree containing all commands and middleware
|
|
1268
1155
|
*/
|
|
1269
|
-
|
|
1156
|
+
toJSON(): CommandsTree;
|
|
1270
1157
|
/**
|
|
1271
|
-
*
|
|
1158
|
+
* Recursively scans a directory for files
|
|
1159
|
+
* @param dir - Directory to scan
|
|
1160
|
+
* @param entries - Accumulator for found files
|
|
1161
|
+
* @returns Promise resolving to array of file paths
|
|
1272
1162
|
*/
|
|
1273
|
-
|
|
1163
|
+
private scanDirectory;
|
|
1164
|
+
private isIgnoredFile;
|
|
1165
|
+
private isCommandFile;
|
|
1166
|
+
private parseCategories;
|
|
1167
|
+
private parseCommandPath;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Configuration options for the EventsRouter
|
|
1172
|
+
* @interface EventsRouterOptions
|
|
1173
|
+
*/
|
|
1174
|
+
interface EventsRouterOptions {
|
|
1175
|
+
/** Root directory path where event handlers are located */
|
|
1176
|
+
entrypoint: string;
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Represents a parsed event with its handlers
|
|
1180
|
+
* @interface ParsedEvent
|
|
1181
|
+
*/
|
|
1182
|
+
interface ParsedEvent {
|
|
1183
|
+
/** Name of the event derived from directory name */
|
|
1184
|
+
event: string;
|
|
1185
|
+
/** Absolute path to the event directory */
|
|
1186
|
+
path: string;
|
|
1187
|
+
/** Array of file paths to event listener handlers */
|
|
1188
|
+
listeners: string[];
|
|
1189
|
+
/** Namespace of the event */
|
|
1190
|
+
namespace: string | null;
|
|
1191
|
+
}
|
|
1192
|
+
/** Map of event names to their parsed metadata */
|
|
1193
|
+
type EventsTree = Record<string, ParsedEvent>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Router for discovering and managing event handler files in a directory structure.
|
|
1196
|
+
* Events are represented by directories, and handlers are files within those directories.
|
|
1197
|
+
*/
|
|
1198
|
+
declare class EventsRouter {
|
|
1199
|
+
private options;
|
|
1200
|
+
/** Internal storage of parsed events */
|
|
1201
|
+
private events;
|
|
1274
1202
|
/**
|
|
1275
|
-
*
|
|
1203
|
+
* Creates a new EventsRouter instance
|
|
1204
|
+
* @param options - Configuration options for the router
|
|
1205
|
+
* @throws Error if entrypoint is not provided
|
|
1276
1206
|
*/
|
|
1277
|
-
|
|
1207
|
+
constructor(options: EventsRouterOptions);
|
|
1278
1208
|
/**
|
|
1279
|
-
*
|
|
1209
|
+
* Find a parsed event by its name
|
|
1210
|
+
* @param event - Name of the event to find
|
|
1211
|
+
* @returns Parsed event metadata or null if not found
|
|
1280
1212
|
*/
|
|
1281
|
-
|
|
1213
|
+
match(event: string): ParsedEvent | null;
|
|
1282
1214
|
/**
|
|
1283
|
-
*
|
|
1215
|
+
* Get the entrypoint directory path
|
|
1216
|
+
* @returns Entrypoint directory path
|
|
1284
1217
|
*/
|
|
1285
|
-
|
|
1218
|
+
get entrypoint(): string;
|
|
1286
1219
|
/**
|
|
1287
|
-
*
|
|
1220
|
+
* Checks if the entrypoint path is valid
|
|
1288
1221
|
*/
|
|
1289
|
-
|
|
1222
|
+
isValidPath(): boolean;
|
|
1290
1223
|
/**
|
|
1291
|
-
*
|
|
1292
|
-
* @param preferUser Whether to prefer the user's locale over the guild's locale.
|
|
1293
|
-
* @returns The locale for this command. If no locale is found, the default locale is returned.
|
|
1224
|
+
* Clear all parsed events
|
|
1294
1225
|
*/
|
|
1295
|
-
|
|
1226
|
+
clear(): void;
|
|
1296
1227
|
/**
|
|
1297
|
-
*
|
|
1298
|
-
* @
|
|
1228
|
+
* Reload and re-scan the entrypoint directory for events
|
|
1229
|
+
* @returns Promise resolving to the updated events tree
|
|
1299
1230
|
*/
|
|
1300
|
-
|
|
1231
|
+
reload(): Promise<EventsTree>;
|
|
1301
1232
|
/**
|
|
1302
|
-
*
|
|
1303
|
-
* @
|
|
1233
|
+
* Scan the entrypoint directory for events and their handlers
|
|
1234
|
+
* @returns Promise resolving to the events tree
|
|
1304
1235
|
*/
|
|
1305
|
-
|
|
1236
|
+
scan(): Promise<EventsTree>;
|
|
1306
1237
|
/**
|
|
1307
|
-
*
|
|
1238
|
+
* Convert the internal events map to a plain object
|
|
1239
|
+
* @returns Events tree as a plain object
|
|
1308
1240
|
*/
|
|
1309
|
-
|
|
1310
|
-
isMiddleware(): this is MiddlewareContext<ExecutionMode>;
|
|
1311
|
-
args(): string[];
|
|
1241
|
+
toJSON(): EventsTree;
|
|
1312
1242
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1243
|
+
* Recursively scan a directory for event handlers
|
|
1244
|
+
* @param event - Name of the event
|
|
1245
|
+
* @param path - Path to the event directory
|
|
1246
|
+
* @param listeners - Array to collect listener file paths
|
|
1247
|
+
* @returns Promise resolving to the parsed event metadata
|
|
1317
1248
|
*/
|
|
1318
|
-
|
|
1249
|
+
private scanEvent;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
declare class CommandRegistrar {
|
|
1253
|
+
readonly commandkit: CommandKit;
|
|
1254
|
+
private api;
|
|
1319
1255
|
/**
|
|
1320
|
-
*
|
|
1321
|
-
* @param
|
|
1322
|
-
* @returns A unique identifier for the deferred function.
|
|
1256
|
+
* Creates an instance of CommandRegistrar.
|
|
1257
|
+
* @param commandkit The commandkit instance.
|
|
1323
1258
|
*/
|
|
1324
|
-
|
|
1259
|
+
constructor(commandkit: CommandKit);
|
|
1325
1260
|
/**
|
|
1326
|
-
*
|
|
1327
|
-
* @param id The identifier of the deferred function.
|
|
1261
|
+
* Gets the commands data.
|
|
1328
1262
|
*/
|
|
1329
|
-
|
|
1263
|
+
getCommandsData(): CommandData[];
|
|
1330
1264
|
/**
|
|
1331
|
-
*
|
|
1332
|
-
* @param fn The function to validate.
|
|
1265
|
+
* Registers loaded commands.
|
|
1333
1266
|
*/
|
|
1334
|
-
|
|
1335
|
-
}
|
|
1336
|
-
declare class MiddlewareContext<T extends CommandExecutionMode = CommandExecutionMode> extends Context<T> {
|
|
1337
|
-
#private;
|
|
1267
|
+
register(): Promise<void>;
|
|
1338
1268
|
/**
|
|
1339
|
-
*
|
|
1269
|
+
* Updates the global commands.
|
|
1340
1270
|
*/
|
|
1341
|
-
|
|
1271
|
+
updateGlobalCommands(commands: CommandData[]): Promise<void>;
|
|
1342
1272
|
/**
|
|
1343
|
-
*
|
|
1273
|
+
* Updates the guild commands.
|
|
1344
1274
|
*/
|
|
1345
|
-
|
|
1275
|
+
updateGuildCommands(commands: CommandData[]): Promise<void>;
|
|
1346
1276
|
}
|
|
1347
1277
|
|
|
1348
1278
|
interface AppCommand {
|
|
@@ -1367,192 +1297,269 @@ interface LoadedMiddleware {
|
|
|
1367
1297
|
data: AppCommandMiddleware;
|
|
1368
1298
|
}
|
|
1369
1299
|
interface PreparedAppCommandExecution {
|
|
1370
|
-
command: LoadedCommand;
|
|
1371
|
-
middlewares: LoadedMiddleware[];
|
|
1372
|
-
messageCommandParser?: MessageCommandParser;
|
|
1373
|
-
}
|
|
1374
|
-
type CommandBuilderLike = SlashCommandBuilder | ContextMenuCommandBuilder | Record<string, any>;
|
|
1375
|
-
declare class AppCommandHandler {
|
|
1376
|
-
readonly commandkit: CommandKit;
|
|
1377
|
-
private loadedCommands;
|
|
1378
|
-
private loadedMiddlewares;
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
eventsRouter: EventsRouter;
|
|
1399
|
-
appCommandsHandler: AppCommandHandler;
|
|
1400
|
-
static instance: CommandKit | undefined;
|
|
1401
|
-
/**
|
|
1402
|
-
* Create a new command and event handler with CommandKit.
|
|
1403
|
-
*
|
|
1404
|
-
* @param options - The default CommandKit configuration.
|
|
1405
|
-
* @see {@link https://commandkit.js.org/docs/guide/commandkit-setup}
|
|
1406
|
-
*/
|
|
1407
|
-
constructor(options: CommandKitOptions);
|
|
1408
|
-
/**
|
|
1409
|
-
* Starts the commandkit application.
|
|
1410
|
-
* @param token The application token to connect to the discord gateway. If not provided, it will use the `TOKEN` or `DISCORD_TOKEN` environment variable. If set to `false`, it will not login.
|
|
1411
|
-
*/
|
|
1412
|
-
start(token?: string | false): Promise<void>;
|
|
1413
|
-
/**
|
|
1414
|
-
* Whether or not the commandkit application has started.
|
|
1415
|
-
*/
|
|
1416
|
-
get started(): boolean;
|
|
1417
|
-
/**
|
|
1418
|
-
* Sets the prefix resolver for the command handler.
|
|
1419
|
-
* @param resolver The resolver function.
|
|
1420
|
-
*/
|
|
1421
|
-
setPrefixResolver(resolver: (message: Message) => Awaitable<string | string[]>): this;
|
|
1422
|
-
/**
|
|
1423
|
-
* Sets the default locale for the command handler.
|
|
1424
|
-
* @param locale The default locale.
|
|
1425
|
-
*/
|
|
1426
|
-
setDefaultLocale(locale: Locale): this;
|
|
1427
|
-
/**
|
|
1428
|
-
* Sets the localization strategy for the command handler.
|
|
1429
|
-
* @param strategy The localization strategy.
|
|
1430
|
-
*/
|
|
1431
|
-
setLocalizationStrategy(strategy: LocalizationStrategy): this;
|
|
1432
|
-
/**
|
|
1433
|
-
* Resolves the current cache provider.
|
|
1434
|
-
*/
|
|
1435
|
-
getCacheProvider(): CacheProvider | null;
|
|
1436
|
-
/**
|
|
1437
|
-
* Whether or not to debug the command handler.
|
|
1438
|
-
*/
|
|
1439
|
-
isDebuggingCommands(): boolean;
|
|
1440
|
-
/**
|
|
1441
|
-
* Get the client attached to this CommandKit instance.
|
|
1442
|
-
*/
|
|
1443
|
-
get client(): discord_js.Client<boolean>;
|
|
1444
|
-
/**
|
|
1445
|
-
* Get command handler instance.
|
|
1446
|
-
*/
|
|
1447
|
-
get commandHandler(): CommandHandler | undefined;
|
|
1448
|
-
/**
|
|
1449
|
-
* Updates application commands with the latest from "commandsPath".
|
|
1450
|
-
*/
|
|
1451
|
-
reloadCommands(type?: ReloadOptions): Promise<void>;
|
|
1452
|
-
/**
|
|
1453
|
-
* Updates application events with the latest from "eventsPath".
|
|
1454
|
-
*/
|
|
1300
|
+
command: LoadedCommand;
|
|
1301
|
+
middlewares: LoadedMiddleware[];
|
|
1302
|
+
messageCommandParser?: MessageCommandParser;
|
|
1303
|
+
}
|
|
1304
|
+
type CommandBuilderLike = SlashCommandBuilder | ContextMenuCommandBuilder | Record<string, any>;
|
|
1305
|
+
declare class AppCommandHandler {
|
|
1306
|
+
readonly commandkit: CommandKit;
|
|
1307
|
+
private loadedCommands;
|
|
1308
|
+
private loadedMiddlewares;
|
|
1309
|
+
readonly registrar: CommandRegistrar;
|
|
1310
|
+
private onInteraction;
|
|
1311
|
+
private onMessageCreate;
|
|
1312
|
+
private onMessageUpdate;
|
|
1313
|
+
constructor(commandkit: CommandKit);
|
|
1314
|
+
getCommandsArray(): LoadedCommand[];
|
|
1315
|
+
registerCommandHandler(): void;
|
|
1316
|
+
getExecutionMode(source: Interaction | Message$1): CommandExecutionMode;
|
|
1317
|
+
runCommand(command: PreparedAppCommandExecution, source: Interaction | Message$1): Promise<void>;
|
|
1318
|
+
prepareCommandRun(source: Interaction | Message$1): Promise<PreparedAppCommandExecution | null>;
|
|
1319
|
+
reloadCommands(): Promise<void>;
|
|
1320
|
+
loadCommands(): Promise<void>;
|
|
1321
|
+
applyLocalizations(command: CommandBuilderLike): Promise<discord_js.RESTPostAPIContextMenuApplicationCommandsJSONBody | CommandBuilderLike>;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
declare class AppEventsHandler {
|
|
1325
|
+
readonly commandkit: CommandKit;
|
|
1326
|
+
private loadedEvents;
|
|
1327
|
+
constructor(commandkit: CommandKit);
|
|
1455
1328
|
reloadEvents(): Promise<void>;
|
|
1329
|
+
loadEvents(): Promise<void>;
|
|
1330
|
+
unregisterAll(): void;
|
|
1331
|
+
registerAllClientEvents(): void;
|
|
1332
|
+
unregisterAllClientListeners(): void;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
interface OnLoadArgs {
|
|
1336
|
+
path: string;
|
|
1337
|
+
namespace: string;
|
|
1338
|
+
suffix: string;
|
|
1339
|
+
pluginData: any;
|
|
1340
|
+
with: Record<string, string>;
|
|
1341
|
+
}
|
|
1342
|
+
interface OnLoadOptions {
|
|
1343
|
+
filter: RegExp;
|
|
1344
|
+
namespace?: string;
|
|
1345
|
+
}
|
|
1346
|
+
type Loader = `${'j' | 't'}s` | (string & {});
|
|
1347
|
+
interface OnLoadResult {
|
|
1348
|
+
contents?: string | Uint8Array;
|
|
1349
|
+
errors?: Message[];
|
|
1350
|
+
loader?: Loader;
|
|
1351
|
+
pluginData?: any;
|
|
1352
|
+
pluginName?: string;
|
|
1353
|
+
resolveDir?: string;
|
|
1354
|
+
warnings?: Message[];
|
|
1355
|
+
watchDirs?: string[];
|
|
1356
|
+
watchFiles?: string[];
|
|
1357
|
+
}
|
|
1358
|
+
interface Message {
|
|
1359
|
+
text: string;
|
|
1360
|
+
location: Location | null;
|
|
1361
|
+
detail: any;
|
|
1362
|
+
}
|
|
1363
|
+
interface Location {
|
|
1364
|
+
file: string;
|
|
1365
|
+
namespace: string;
|
|
1366
|
+
line: number;
|
|
1367
|
+
column: number;
|
|
1368
|
+
length: number;
|
|
1369
|
+
lineText: string;
|
|
1370
|
+
}
|
|
1371
|
+
interface OnResolveOptions {
|
|
1372
|
+
filter: RegExp;
|
|
1373
|
+
namespace?: string;
|
|
1374
|
+
}
|
|
1375
|
+
interface OnResolveArgs {
|
|
1376
|
+
path: string;
|
|
1377
|
+
importer: string;
|
|
1378
|
+
namespace: string;
|
|
1379
|
+
resolveDir: string;
|
|
1380
|
+
kind: ResolveKind;
|
|
1381
|
+
pluginData: any;
|
|
1382
|
+
with: Record<string, string>;
|
|
1383
|
+
}
|
|
1384
|
+
type ResolveKind = 'entry-point' | 'import-statement' | 'require-call' | 'dynamic-import' | 'require-resolve' | 'import-rule' | 'composes-from' | 'url-token';
|
|
1385
|
+
interface OnResolveResult {
|
|
1386
|
+
errors?: Message[];
|
|
1387
|
+
external?: boolean;
|
|
1388
|
+
namespace?: string;
|
|
1389
|
+
path?: string;
|
|
1390
|
+
pluginData?: any;
|
|
1391
|
+
pluginName?: string;
|
|
1392
|
+
sideEffects?: boolean;
|
|
1393
|
+
suffix?: string;
|
|
1394
|
+
warnings?: Message[];
|
|
1395
|
+
watchDirs?: string[];
|
|
1396
|
+
watchFiles?: string[];
|
|
1397
|
+
}
|
|
1398
|
+
interface Setup {
|
|
1399
|
+
onStart(fn: () => Promise<void>): void;
|
|
1400
|
+
onEnd(fn: () => Promise<void>): void;
|
|
1401
|
+
onDispose(fn: () => Promise<void>): void;
|
|
1402
|
+
onLoad(options: OnLoadOptions, cb: (args: OnLoadArgs) => Promise<OnLoadResult>): Promise<any>;
|
|
1403
|
+
onResolve(options: OnResolveOptions, cb: (args: OnResolveArgs) => Promise<OnResolveResult>): Promise<any>;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
type CommandKitPlugin = RuntimePlugin | CompilerPlugin;
|
|
1407
|
+
type MaybeFalsey<T> = T | false | null | undefined;
|
|
1408
|
+
|
|
1409
|
+
interface PluginTransformParameters {
|
|
1410
|
+
args: OnLoadArgs;
|
|
1411
|
+
path: string;
|
|
1412
|
+
contents: string | Uint8Array;
|
|
1413
|
+
loader?: Loader;
|
|
1414
|
+
}
|
|
1415
|
+
interface TransformedResult {
|
|
1416
|
+
contents?: string | Uint8Array;
|
|
1417
|
+
loader?: Loader;
|
|
1418
|
+
}
|
|
1419
|
+
interface ResolveResult {
|
|
1420
|
+
path?: string;
|
|
1421
|
+
external?: boolean;
|
|
1422
|
+
}
|
|
1423
|
+
declare abstract class CompilerPlugin<T extends PluginOptions = PluginOptions> extends PluginCommon<T, CompilerPluginRuntime> {
|
|
1456
1424
|
/**
|
|
1457
|
-
*
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
/**
|
|
1461
|
-
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
1462
|
-
*/
|
|
1463
|
-
get commands(): CommandObject[];
|
|
1464
|
-
/**
|
|
1465
|
-
* @returns The path to the commands folder which was set when instantiating CommandKit.
|
|
1466
|
-
*/
|
|
1467
|
-
get commandsPath(): string | undefined;
|
|
1468
|
-
/**
|
|
1469
|
-
* @returns The path to the events folder which was set when instantiating CommandKit.
|
|
1425
|
+
* Called when transformation is requested to this plugin
|
|
1426
|
+
* @param params The parameters for the transformation
|
|
1427
|
+
* @returns The transformed result
|
|
1470
1428
|
*/
|
|
1471
|
-
|
|
1429
|
+
transform(params: PluginTransformParameters): Promise<MaybeFalsey<TransformedResult>>;
|
|
1472
1430
|
/**
|
|
1473
|
-
*
|
|
1431
|
+
* Called when a resolve is requested to this plugin
|
|
1432
|
+
* @param args The arguments for the resolve
|
|
1433
|
+
* @returns The resolved result
|
|
1474
1434
|
*/
|
|
1475
|
-
|
|
1435
|
+
resolve(args: OnResolveArgs): Promise<MaybeFalsey<ResolveResult>>;
|
|
1476
1436
|
/**
|
|
1477
|
-
*
|
|
1437
|
+
* Called when a build is started
|
|
1478
1438
|
*/
|
|
1479
|
-
|
|
1439
|
+
onBuildStart(): Promise<void>;
|
|
1480
1440
|
/**
|
|
1481
|
-
*
|
|
1441
|
+
* Called when a build is ended
|
|
1482
1442
|
*/
|
|
1483
|
-
|
|
1443
|
+
onBuildEnd(): Promise<void>;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
declare class CompilerPluginRuntime {
|
|
1447
|
+
private readonly plugins;
|
|
1448
|
+
readonly name = "CompilerPluginRuntime";
|
|
1449
|
+
constructor(plugins: CompilerPlugin[]);
|
|
1450
|
+
isEmpty(): boolean;
|
|
1451
|
+
private onLoad;
|
|
1452
|
+
private onResolve;
|
|
1453
|
+
private onStart;
|
|
1454
|
+
private onEnd;
|
|
1455
|
+
private onDispose;
|
|
1456
|
+
private onInit;
|
|
1457
|
+
cleanup(): Promise<void>;
|
|
1458
|
+
setup(build: Setup): Promise<void>;
|
|
1459
|
+
toEsbuildPlugin(): {
|
|
1460
|
+
name: string;
|
|
1461
|
+
setup: (build: Setup) => Promise<void>;
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
type CommonPluginRuntime = CommandKitPluginRuntime | CompilerPluginRuntime;
|
|
1466
|
+
|
|
1467
|
+
type PluginOptions = Record<string, any>;
|
|
1468
|
+
declare abstract class PluginCommon<T extends PluginOptions = PluginOptions, C extends CommonPluginRuntime = CommonPluginRuntime> {
|
|
1469
|
+
protected readonly options: T;
|
|
1470
|
+
abstract readonly name: string;
|
|
1471
|
+
constructor(options: T);
|
|
1484
1472
|
/**
|
|
1485
|
-
*
|
|
1473
|
+
* Called when this plugin is activated
|
|
1486
1474
|
*/
|
|
1487
|
-
|
|
1475
|
+
activate(ctx: C): Promise<void>;
|
|
1488
1476
|
/**
|
|
1489
|
-
*
|
|
1477
|
+
* Called when this plugin is deactivated
|
|
1490
1478
|
*/
|
|
1491
|
-
|
|
1479
|
+
deactivate(ctx: C): Promise<void>;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
declare class DefaultLocalizationStrategy implements LocalizationStrategy {
|
|
1483
|
+
private readonly commandkit;
|
|
1484
|
+
private translations;
|
|
1485
|
+
constructor(commandkit: CommandKit);
|
|
1486
|
+
locateTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
1487
|
+
getTranslationStrict(scope: string, locale: Locale): Promise<Translation>;
|
|
1488
|
+
getTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
1489
|
+
translate(request: LocalizationTranslationRequest): Promise<TranslationResult>;
|
|
1490
|
+
private applyTranslation;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Cancel upcoming middleware execution.
|
|
1495
|
+
* If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.
|
|
1496
|
+
* If this is called inside a command itself, it will skip all post-stage middlewares.
|
|
1497
|
+
* If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
|
|
1498
|
+
*/
|
|
1499
|
+
declare function exitMiddleware(): never;
|
|
1500
|
+
/**
|
|
1501
|
+
* Rethrow the error if it is a CommandKit error.
|
|
1502
|
+
* @param error The error to rethrow.
|
|
1503
|
+
*/
|
|
1504
|
+
declare function rethrow(error: unknown): void;
|
|
1505
|
+
/**
|
|
1506
|
+
* Stops current command assuming it has been redirected to another command.
|
|
1507
|
+
*/
|
|
1508
|
+
declare function redirect(): never;
|
|
1509
|
+
|
|
1510
|
+
declare abstract class RuntimePlugin<T extends PluginOptions = PluginOptions> extends PluginCommon<T, CommandKitPluginRuntime> {
|
|
1492
1511
|
/**
|
|
1493
|
-
*
|
|
1512
|
+
* Called before commands are loaded
|
|
1494
1513
|
*/
|
|
1495
|
-
|
|
1514
|
+
onBeforeCommandsLoad(ctx: CommandKitPluginRuntime): Promise<void>;
|
|
1496
1515
|
/**
|
|
1497
|
-
*
|
|
1498
|
-
* The lookup order is:
|
|
1499
|
-
* - `./app`
|
|
1500
|
-
* - `./src/app`
|
|
1516
|
+
* Called after commands are loaded
|
|
1501
1517
|
*/
|
|
1502
|
-
|
|
1503
|
-
getPath(to: 'locales' | 'commands' | 'events'): string | null;
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
interface CommandKitConfig {
|
|
1518
|
+
onAfterCommandsLoad(ctx: CommandKitPluginRuntime): Promise<void>;
|
|
1507
1519
|
/**
|
|
1508
|
-
*
|
|
1520
|
+
* Called before events are loaded
|
|
1509
1521
|
*/
|
|
1510
|
-
|
|
1522
|
+
onBeforeEventsLoad(ctx: CommandKitPluginRuntime): Promise<void>;
|
|
1511
1523
|
/**
|
|
1512
|
-
*
|
|
1524
|
+
* Called after events are loaded
|
|
1513
1525
|
*/
|
|
1514
|
-
|
|
1526
|
+
onAfterEventsLoad(ctx: CommandKitPluginRuntime): Promise<void>;
|
|
1515
1527
|
/**
|
|
1516
|
-
*
|
|
1528
|
+
* Called before the client logs in
|
|
1517
1529
|
*/
|
|
1518
|
-
|
|
1530
|
+
onBeforeClientLogin(ctx: CommandKitPluginRuntime): Promise<void>;
|
|
1519
1531
|
/**
|
|
1520
|
-
*
|
|
1532
|
+
* Called after the client logs in
|
|
1521
1533
|
*/
|
|
1522
|
-
|
|
1534
|
+
onAfterClientLogin(ctx: CommandKitPluginRuntime): Promise<void>;
|
|
1523
1535
|
/**
|
|
1524
|
-
*
|
|
1536
|
+
* Called before interaction is handled
|
|
1537
|
+
* @param interaction The interaction
|
|
1525
1538
|
*/
|
|
1526
|
-
|
|
1539
|
+
onBeforeInteraction(ctx: CommandKitPluginRuntime, interaction: Interaction): Promise<void>;
|
|
1527
1540
|
/**
|
|
1528
|
-
*
|
|
1541
|
+
* Called after interaction is handled
|
|
1542
|
+
* @param interaction The interaction that was handled
|
|
1529
1543
|
*/
|
|
1530
|
-
|
|
1544
|
+
onAfterInteraction(ctx: CommandKitPluginRuntime, interaction: Interaction): Promise<void>;
|
|
1531
1545
|
/**
|
|
1532
|
-
*
|
|
1546
|
+
* Called before message command is processed
|
|
1547
|
+
* @param message The message
|
|
1533
1548
|
*/
|
|
1534
|
-
|
|
1549
|
+
onBeforeMessageCommand(ctx: CommandKitPluginRuntime, message: Message$1): Promise<void>;
|
|
1535
1550
|
/**
|
|
1536
|
-
*
|
|
1551
|
+
* Called before message update command is processed
|
|
1552
|
+
* @param message The message
|
|
1537
1553
|
*/
|
|
1538
|
-
|
|
1554
|
+
onBeforeMessageUpdateCommand(ctx: CommandKitPluginRuntime, oldMessage: Message$1 | PartialMessage, newMessage: Message$1 | PartialMessage): Promise<void>;
|
|
1539
1555
|
/**
|
|
1540
|
-
*
|
|
1556
|
+
* Called before command is executed. This method can execute the command itself.
|
|
1557
|
+
* @param source The source that triggered the command
|
|
1558
|
+
* @param command The command
|
|
1559
|
+
* @param execute The function that executes the command
|
|
1541
1560
|
*/
|
|
1542
|
-
|
|
1561
|
+
executeCommand(ctx: CommandKitPluginRuntime, source: Interaction | Message$1, command: PreparedAppCommandExecution, execute: () => Promise<any>): Promise<boolean>;
|
|
1543
1562
|
}
|
|
1544
|
-
declare function getConfig(): CommandKitConfig;
|
|
1545
|
-
declare function defineConfig(config: Partial<CommandKitConfig>): {
|
|
1546
|
-
outDir: string;
|
|
1547
|
-
watch: boolean;
|
|
1548
|
-
envExtra: boolean;
|
|
1549
|
-
nodeOptions: string[];
|
|
1550
|
-
clearRestartLogs: boolean;
|
|
1551
|
-
minify: boolean;
|
|
1552
|
-
sourcemap: boolean | "inline";
|
|
1553
|
-
antiCrash: boolean;
|
|
1554
|
-
requirePolyfill: boolean;
|
|
1555
|
-
};
|
|
1556
1563
|
|
|
1557
1564
|
declare class MemoryCache extends CacheProvider {
|
|
1558
1565
|
#private;
|
|
@@ -1682,33 +1689,224 @@ declare function revalidate<T = unknown>(tag: string, ...args: any[]): Promise<T
|
|
|
1682
1689
|
*/
|
|
1683
1690
|
declare function isCachedFunction(fn: GenericFunction): boolean;
|
|
1684
1691
|
|
|
1685
|
-
declare class
|
|
1686
|
-
|
|
1687
|
-
private
|
|
1692
|
+
declare class CommandKitPluginRuntime extends EventTarget {
|
|
1693
|
+
readonly commandkit: CommandKit;
|
|
1694
|
+
private plugins;
|
|
1695
|
+
private onClientLogin;
|
|
1688
1696
|
constructor(commandkit: CommandKit);
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1697
|
+
getPlugin(pluginName: string): RuntimePlugin | null;
|
|
1698
|
+
registerPlugin(plugin: RuntimePlugin): Promise<void>;
|
|
1699
|
+
unregisterPlugin(plugin: RuntimePlugin): Promise<void>;
|
|
1700
|
+
unregisterAllPlugins(): Promise<void>;
|
|
1701
|
+
capture(): void;
|
|
1702
|
+
execute<R = any>(f: AsyncFunction<[CommandKitPluginRuntime, RuntimePlugin], R | undefined>): Promise<true | R | undefined>;
|
|
1694
1703
|
}
|
|
1695
1704
|
|
|
1705
|
+
interface CommandKitConfiguration {
|
|
1706
|
+
defaultLocale: Locale;
|
|
1707
|
+
localizationStrategy: LocalizationStrategy;
|
|
1708
|
+
getMessageCommandPrefix: (message: Message$1) => Awaitable<string | string[]>;
|
|
1709
|
+
}
|
|
1710
|
+
declare class CommandKit extends EventEmitter {
|
|
1711
|
+
#private;
|
|
1712
|
+
private options;
|
|
1713
|
+
readonly eventInterceptor: EventInterceptor;
|
|
1714
|
+
static readonly createElement: typeof createElement;
|
|
1715
|
+
static readonly Fragment: typeof Fragment;
|
|
1716
|
+
readonly config: CommandKitConfiguration;
|
|
1717
|
+
commandsRouter: CommandsRouter;
|
|
1718
|
+
eventsRouter: EventsRouter;
|
|
1719
|
+
readonly commandHandler: AppCommandHandler;
|
|
1720
|
+
readonly eventHandler: AppEventsHandler;
|
|
1721
|
+
readonly plugins: CommandKitPluginRuntime;
|
|
1722
|
+
static instance: CommandKit | undefined;
|
|
1723
|
+
/**
|
|
1724
|
+
* Create a new command and event handler with CommandKit.
|
|
1725
|
+
*
|
|
1726
|
+
* @param options - The default CommandKit configuration.
|
|
1727
|
+
* @see {@link https://commandkit.js.org/docs/guide/commandkit-setup}
|
|
1728
|
+
*/
|
|
1729
|
+
constructor(options: CommandKitOptions);
|
|
1730
|
+
/**
|
|
1731
|
+
* Starts the commandkit application.
|
|
1732
|
+
* @param token The application token to connect to the discord gateway. If not provided, it will use the `TOKEN` or `DISCORD_TOKEN` environment variable. If set to `false`, it will not login.
|
|
1733
|
+
*/
|
|
1734
|
+
start(token?: string | false): Promise<void>;
|
|
1735
|
+
/**
|
|
1736
|
+
* Whether or not the commandkit application has started.
|
|
1737
|
+
*/
|
|
1738
|
+
get started(): boolean;
|
|
1739
|
+
/**
|
|
1740
|
+
* Sets the prefix resolver for the command handler.
|
|
1741
|
+
* @param resolver The resolver function.
|
|
1742
|
+
*/
|
|
1743
|
+
setPrefixResolver(resolver: (message: Message$1) => Awaitable<string | string[]>): this;
|
|
1744
|
+
/**
|
|
1745
|
+
* Sets the default locale for the command handler.
|
|
1746
|
+
* @param locale The default locale.
|
|
1747
|
+
*/
|
|
1748
|
+
setDefaultLocale(locale: Locale): this;
|
|
1749
|
+
/**
|
|
1750
|
+
* Sets the localization strategy for the command handler.
|
|
1751
|
+
* @param strategy The localization strategy.
|
|
1752
|
+
*/
|
|
1753
|
+
setLocalizationStrategy(strategy: LocalizationStrategy): this;
|
|
1754
|
+
/**
|
|
1755
|
+
* Resolves the current cache provider.
|
|
1756
|
+
*/
|
|
1757
|
+
getCacheProvider(): CacheProvider | null;
|
|
1758
|
+
/**
|
|
1759
|
+
* Whether or not to debug the command handler.
|
|
1760
|
+
*/
|
|
1761
|
+
isDebuggingCommands(): boolean;
|
|
1762
|
+
/**
|
|
1763
|
+
* Get the client attached to this CommandKit instance.
|
|
1764
|
+
*/
|
|
1765
|
+
get client(): discord_js.Client<boolean>;
|
|
1766
|
+
/**
|
|
1767
|
+
* Updates application commands with the latest from "commandsPath".
|
|
1768
|
+
*/
|
|
1769
|
+
reloadCommands(): Promise<void>;
|
|
1770
|
+
/**
|
|
1771
|
+
* Updates application events with the latest from "eventsPath".
|
|
1772
|
+
*/
|
|
1773
|
+
reloadEvents(): Promise<void>;
|
|
1774
|
+
/**
|
|
1775
|
+
* @returns The path to the commands folder which was set when instantiating CommandKit.
|
|
1776
|
+
*/
|
|
1777
|
+
get commandsPath(): string | undefined;
|
|
1778
|
+
/**
|
|
1779
|
+
* @returns The path to the events folder which was set when instantiating CommandKit.
|
|
1780
|
+
*/
|
|
1781
|
+
get eventsPath(): string | undefined;
|
|
1782
|
+
/**
|
|
1783
|
+
* @returns The path to the validations folder which was set when instantiating CommandKit.
|
|
1784
|
+
*/
|
|
1785
|
+
get validationsPath(): string | undefined;
|
|
1786
|
+
/**
|
|
1787
|
+
* @returns An array of all the developer user IDs which was set when instantiating CommandKit.
|
|
1788
|
+
*/
|
|
1789
|
+
get devUserIds(): string[];
|
|
1790
|
+
/**
|
|
1791
|
+
* @returns An array of all the developer guild IDs which was set when instantiating CommandKit.
|
|
1792
|
+
*/
|
|
1793
|
+
get devGuildIds(): string[];
|
|
1794
|
+
/**
|
|
1795
|
+
* @returns An array of all the developer role IDs which was set when instantiating CommandKit.
|
|
1796
|
+
*/
|
|
1797
|
+
get devRoleIds(): string[];
|
|
1798
|
+
/**
|
|
1799
|
+
* Increment the client listeners count.
|
|
1800
|
+
*/
|
|
1801
|
+
incrementClientListenersCount(): void;
|
|
1802
|
+
/**
|
|
1803
|
+
* Decrement the client listeners count.
|
|
1804
|
+
*/
|
|
1805
|
+
decrementClientListenersCount(): void;
|
|
1806
|
+
/**
|
|
1807
|
+
* Path to the app directory. Returns `null` if not found.
|
|
1808
|
+
* The lookup order is:
|
|
1809
|
+
* - `./app`
|
|
1810
|
+
* - `./src/app`
|
|
1811
|
+
*/
|
|
1812
|
+
getAppDirectory(): string | null;
|
|
1813
|
+
getPath(to: 'locales' | 'commands' | 'events'): string | null;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
interface CommandKitConfig {
|
|
1817
|
+
/**
|
|
1818
|
+
* The plugins to use with CommandKit.
|
|
1819
|
+
*/
|
|
1820
|
+
plugins?: CommandKitPlugin[];
|
|
1821
|
+
/**
|
|
1822
|
+
* The esbuild plugins to use with CommandKit.
|
|
1823
|
+
*/
|
|
1824
|
+
esbuildPlugins?: any[];
|
|
1825
|
+
/**
|
|
1826
|
+
* The compiler options to use with CommandKit.
|
|
1827
|
+
*/
|
|
1828
|
+
compilerOptions?: {
|
|
1829
|
+
/**
|
|
1830
|
+
* Macro compiler configuration.
|
|
1831
|
+
*/
|
|
1832
|
+
macro?: {
|
|
1833
|
+
/**
|
|
1834
|
+
* Whether to enable macro function compilation in development mode.
|
|
1835
|
+
* @default false
|
|
1836
|
+
*/
|
|
1837
|
+
development?: boolean;
|
|
1838
|
+
};
|
|
1839
|
+
/**
|
|
1840
|
+
* Cached function compiler configuration.
|
|
1841
|
+
*/
|
|
1842
|
+
cache?: {
|
|
1843
|
+
/**
|
|
1844
|
+
* Whether to enable caching of compiled functions in development mode.
|
|
1845
|
+
*/
|
|
1846
|
+
development?: boolean;
|
|
1847
|
+
};
|
|
1848
|
+
};
|
|
1849
|
+
/**
|
|
1850
|
+
* The typescript configuration to use with CommandKit.
|
|
1851
|
+
*/
|
|
1852
|
+
typescript?: {
|
|
1853
|
+
/**
|
|
1854
|
+
* Whether to ignore type checking during builds.
|
|
1855
|
+
*/
|
|
1856
|
+
ignoreDuringBuilds?: boolean;
|
|
1857
|
+
};
|
|
1858
|
+
/**
|
|
1859
|
+
* Whether to generate static command handler data in production builds.
|
|
1860
|
+
*/
|
|
1861
|
+
static?: boolean;
|
|
1862
|
+
/**
|
|
1863
|
+
* Statically define the environment variables to use.
|
|
1864
|
+
*/
|
|
1865
|
+
env?: Record<string, string>;
|
|
1866
|
+
/**
|
|
1867
|
+
* The custom build directory name to use.
|
|
1868
|
+
* @default `dist`
|
|
1869
|
+
*/
|
|
1870
|
+
distDir?: string;
|
|
1871
|
+
/**
|
|
1872
|
+
* Whether or not to enable the source map generation.
|
|
1873
|
+
*/
|
|
1874
|
+
sourceMap?: {
|
|
1875
|
+
/**
|
|
1876
|
+
* Whether to enable source map generation in development mode.
|
|
1877
|
+
*/
|
|
1878
|
+
development?: boolean;
|
|
1879
|
+
/**
|
|
1880
|
+
* Whether to enable source map generation in production mode.
|
|
1881
|
+
*/
|
|
1882
|
+
production?: boolean;
|
|
1883
|
+
};
|
|
1884
|
+
/**
|
|
1885
|
+
* Whether or not to enable typed locales.
|
|
1886
|
+
* @default true
|
|
1887
|
+
*/
|
|
1888
|
+
typedLocales?: boolean;
|
|
1889
|
+
/**
|
|
1890
|
+
* Whether or not to enable the typed commands.
|
|
1891
|
+
* @default true
|
|
1892
|
+
*/
|
|
1893
|
+
typedCommands?: boolean;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
type DeepRequired<T> = {
|
|
1897
|
+
[P in keyof T]-?: DeepRequired<T[P]>;
|
|
1898
|
+
};
|
|
1899
|
+
type ResolvedCommandKitConfig = DeepRequired<CommandKitConfig>;
|
|
1900
|
+
|
|
1696
1901
|
/**
|
|
1697
|
-
*
|
|
1698
|
-
* If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.
|
|
1699
|
-
* If this is called inside a command itself, it will skip all post-stage middlewares.
|
|
1700
|
-
* If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
|
|
1701
|
-
*/
|
|
1702
|
-
declare function exitMiddleware(): never;
|
|
1703
|
-
/**
|
|
1704
|
-
* Rethrow the error if it is a CommandKit error.
|
|
1705
|
-
* @param error The error to rethrow.
|
|
1902
|
+
* Get the defined configuration for CommandKit.
|
|
1706
1903
|
*/
|
|
1707
|
-
declare function
|
|
1904
|
+
declare function getConfig(): ResolvedCommandKitConfig;
|
|
1708
1905
|
/**
|
|
1709
|
-
*
|
|
1906
|
+
* Define the configuration for CommandKit.
|
|
1907
|
+
* @param config The configuration to use.
|
|
1710
1908
|
*/
|
|
1711
|
-
declare function
|
|
1909
|
+
declare function defineConfig(config?: Partial<CommandKitConfig>): ResolvedCommandKitConfig;
|
|
1712
1910
|
|
|
1713
1911
|
interface ILogger {
|
|
1714
1912
|
log(...args: any[]): void;
|
|
@@ -1755,6 +1953,11 @@ interface LoggerImpl extends ILogger {
|
|
|
1755
1953
|
declare function createLogger(options: CommandKitLoggerOptions): LoggerImpl;
|
|
1756
1954
|
declare const Logger: LoggerImpl;
|
|
1757
1955
|
|
|
1956
|
+
/**
|
|
1957
|
+
* The current version of CommandKit.
|
|
1958
|
+
*/
|
|
1959
|
+
declare const version: string;
|
|
1960
|
+
|
|
1758
1961
|
/**
|
|
1759
1962
|
* Creates a command line interface for CommandKit.
|
|
1760
1963
|
* @param argv The arguments passed to the CLI.
|
|
@@ -1762,9 +1965,4 @@ declare const Logger: LoggerImpl;
|
|
|
1762
1965
|
*/
|
|
1763
1966
|
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
1764
1967
|
|
|
1765
|
-
|
|
1766
|
-
* The current version of CommandKit.
|
|
1767
|
-
*/
|
|
1768
|
-
declare const version: string;
|
|
1769
|
-
|
|
1770
|
-
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, type AutocompleteProps, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, type CommandFileObject, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfig, type CommandKitConfiguration, type CommandKitData, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandMatchResult, type CommandObject, type CommandOptions, type CommandProps, CommandsRouter, type CommandsRouterMatcher, type CommandsRouterMatchersMap, type CommandsRouterOptions, type CommandsTree, Context, type ContextMenuCommandProps, type ContextParameters, DefaultLocalizationStrategy, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, Localization, type LocalizationConfig, type LocalizationStrategy, type LocalizationTranslationRequest, Logger, type LoggerImpl, type MaybeArray, MemoryCache, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type MessageContextMenuCommandProps, MiddlewareContext, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnModalKitEnd, type OnModalKitSubmit, ParagraphInput, type ParsedCommand, type ParsedEvent, type ParsedMessageCommand, type ParsedMiddleware, type PreparedAppCommandExecution, type ReloadOptions, ReloadType, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, type SlashCommandProps, TextInput, type TextInputProps, type TranslatableArguments, type TranslatableCommand, type TranslatableCommandOptions, type Translation, type TranslationResult, type Translator, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, type UserContextMenuCommandProps, type ValidationProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, createElement, createLogger, CommandKit as default, defineConfig, dmOnly, exitContext, exitMiddleware, getCommandKit, getConfig, getContext, getElement, guildOnly, invalidate, isCachedFunction, isCommandKitElement, makeContextAwareFunction, redirect, rethrow, revalidate, useCache as super_duper_secret_internal_for_use_cache_directive_of_commandkit_cli_do_not_use_it_directly_or_you_will_be_fired_from_your_job_kthxbai, useEnvironment, version };
|
|
1968
|
+
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, type AutocompleteProps, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, type CommandFileObject, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandMatchResult, type CommandObject, type CommandOptions, type CommandProps, CommandsRouter, type CommandsRouterMatcher, type CommandsRouterMatchersMap, type CommandsRouterOptions, type CommandsTree, Context, type ContextMenuCommandProps, type ContextParameters, DefaultLocalizationStrategy, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, Localization, type LocalizationConfig, type LocalizationStrategy, type LocalizationTranslationRequest, Logger, type LoggerImpl, type MaybeArray, MemoryCache, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type MessageContextMenuCommandProps, MiddlewareContext, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnModalKitEnd, type OnModalKitSubmit, ParagraphInput, type ParsedCommand, type ParsedEvent, type ParsedMessageCommand, type ParsedMiddleware, type PreparedAppCommandExecution, type ReloadOptions, ReloadType, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, type SlashCommandProps, TextInput, type TextInputProps, type TranslatableArguments, type TranslatableCommand, type TranslatableCommandOptions, type Translation, type TranslationResult, type Translator, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, type UserContextMenuCommandProps, type ValidationProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, createElement, createLogger, CommandKit as default, defineConfig, dmOnly, exitContext, exitMiddleware, getCommandKit, getConfig, getContext, getElement, guildOnly, invalidate, isCachedFunction, isCommandKitElement, makeContextAwareFunction, redirect, rethrow, revalidate, useCache as super_duper_secret_internal_for_use_cache_directive_of_commandkit_cli_do_not_use_it_directly_or_you_will_be_fired_from_your_job_kthxbai, useEnvironment, version };
|