commandkit 0.1.11-dev.20250306152436 → 0.1.11-dev.20250307192025
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +243 -192
- package/dist/index.js +634 -348
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1007,131 +1007,155 @@ declare class MiddlewareContext<T extends CommandExecutionMode = CommandExecutio
|
|
|
1007
1007
|
cancel(): void;
|
|
1008
1008
|
}
|
|
1009
1009
|
|
|
1010
|
+
/**
|
|
1011
|
+
* Represents a command file info parsed from the file system.
|
|
1012
|
+
* It does not contain any command specific data, as that's loaded later by the command handler.
|
|
1013
|
+
*/
|
|
1010
1014
|
interface ParsedCommand {
|
|
1011
1015
|
/**
|
|
1012
|
-
* The unique identifier of
|
|
1016
|
+
* The unique identifier of the command. This is used to distinguish between commands that may have the same name.
|
|
1013
1017
|
*/
|
|
1014
1018
|
id: string;
|
|
1015
1019
|
/**
|
|
1016
|
-
* The file name
|
|
1020
|
+
* The file name of the command.
|
|
1017
1021
|
*/
|
|
1018
1022
|
name: string;
|
|
1019
1023
|
/**
|
|
1020
|
-
* The
|
|
1021
|
-
* This can be null for directories that function as command groups but have no index file.
|
|
1024
|
+
* The absolute path to the command file.
|
|
1022
1025
|
*/
|
|
1023
|
-
path: string
|
|
1026
|
+
path: string;
|
|
1024
1027
|
/**
|
|
1025
|
-
* The
|
|
1028
|
+
* The relative path from the cwd to the command file.
|
|
1026
1029
|
*/
|
|
1027
|
-
|
|
1030
|
+
relativePath: string;
|
|
1028
1031
|
/**
|
|
1029
|
-
* The
|
|
1032
|
+
* The category of this command. This will be the parent directory segment that matches /(category)/ in the path.
|
|
1033
|
+
* When there are multiple segments, they are combined with a colon.
|
|
1034
|
+
* Example: `/commands/(games)/tictactoe.js` -> category is `games`
|
|
1035
|
+
* Example: `/commands/(games)/(fun)/tictactoe.js` -> category is `games:fun`
|
|
1036
|
+
* Category is `null` if the parent directory segment does not match `/(\w+)/`.
|
|
1030
1037
|
*/
|
|
1031
|
-
|
|
1038
|
+
category: string | null;
|
|
1032
1039
|
/**
|
|
1033
|
-
*
|
|
1040
|
+
* Array of ids referencing the associated middleware for this command.
|
|
1034
1041
|
*/
|
|
1035
1042
|
middlewares: string[];
|
|
1043
|
+
/**
|
|
1044
|
+
* Array of ids referencing the associated subcommands for this command.
|
|
1045
|
+
*/
|
|
1046
|
+
subcommands: string[];
|
|
1036
1047
|
}
|
|
1037
|
-
|
|
1048
|
+
/**
|
|
1049
|
+
* Represents a middleware file info parsed from the file system.
|
|
1050
|
+
*/
|
|
1051
|
+
interface ParsedMiddleware {
|
|
1038
1052
|
/**
|
|
1039
|
-
* The unique identifier of
|
|
1053
|
+
* The unique identifier of the middleware. This is used to distinguish between middlewares that may have the same name.
|
|
1040
1054
|
*/
|
|
1041
1055
|
id: string;
|
|
1042
1056
|
/**
|
|
1043
|
-
* The file name
|
|
1057
|
+
* The file name of the middleware.
|
|
1044
1058
|
*/
|
|
1045
1059
|
name: string;
|
|
1046
1060
|
/**
|
|
1047
|
-
* The
|
|
1061
|
+
* The absolute path to the middleware file.
|
|
1048
1062
|
*/
|
|
1049
1063
|
path: string;
|
|
1050
1064
|
/**
|
|
1051
|
-
* The
|
|
1065
|
+
* The relative path from the cwd to the middleware file.
|
|
1052
1066
|
*/
|
|
1053
|
-
|
|
1067
|
+
relativePath: string;
|
|
1054
1068
|
/**
|
|
1055
|
-
* The
|
|
1069
|
+
* The category of this middleware. This will be the parent directory segment that matches /(category)/ in the path.
|
|
1056
1070
|
*/
|
|
1057
|
-
|
|
1071
|
+
category: string | null;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Represents a subcommand file info parsed from the file system.
|
|
1075
|
+
*/
|
|
1076
|
+
interface ParsedSubCommand {
|
|
1058
1077
|
/**
|
|
1059
|
-
* The
|
|
1078
|
+
* The unique identifier of the subcommand. This is used to distinguish between subcommands that may have the same name.
|
|
1060
1079
|
*/
|
|
1061
|
-
|
|
1062
|
-
}
|
|
1063
|
-
interface ParsedMiddleware {
|
|
1080
|
+
id: string;
|
|
1064
1081
|
/**
|
|
1065
|
-
* The
|
|
1082
|
+
* The name of the subcommand.
|
|
1066
1083
|
*/
|
|
1067
1084
|
name: string;
|
|
1068
1085
|
/**
|
|
1069
|
-
* The
|
|
1086
|
+
* The group name of the subcommand. This is used to group subcommands together in the Discord UI.
|
|
1070
1087
|
*/
|
|
1071
|
-
|
|
1088
|
+
group: string | null;
|
|
1072
1089
|
/**
|
|
1073
|
-
* The
|
|
1090
|
+
* The absolute path to the subcommand file.
|
|
1074
1091
|
*/
|
|
1075
1092
|
path: string;
|
|
1076
1093
|
/**
|
|
1077
|
-
* The
|
|
1094
|
+
* The relative path from the cwd to the subcommand file.
|
|
1078
1095
|
*/
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
interface CommandsTree {
|
|
1096
|
+
relativePath: string;
|
|
1082
1097
|
/**
|
|
1083
|
-
*
|
|
1098
|
+
* Array of ids referencing the associated middleware for this subcommand.
|
|
1084
1099
|
*/
|
|
1100
|
+
middlewares: string[];
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Represents a JSON compatible object that contains all the parsed commands, middlewares, and subcommands.
|
|
1104
|
+
*/
|
|
1105
|
+
interface CommandTree {
|
|
1085
1106
|
commands: Record<string, ParsedCommand>;
|
|
1086
|
-
/**
|
|
1087
|
-
* The record of subcommands mapped by their unique identifiers.
|
|
1088
|
-
*/
|
|
1089
|
-
subcommands: Record<string, ParsedSubCommand>;
|
|
1090
|
-
/**
|
|
1091
|
-
* The record of middlewares mapped by their unique identifiers.
|
|
1092
|
-
*/
|
|
1093
1107
|
middlewares: Record<string, ParsedMiddleware>;
|
|
1108
|
+
subcommands: Record<string, ParsedSubCommand>;
|
|
1094
1109
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1110
|
+
/**
|
|
1111
|
+
* Represents the scanned and parsed command files.
|
|
1112
|
+
*/
|
|
1113
|
+
interface ParsedCommandData {
|
|
1099
1114
|
commands: Collection<string, ParsedCommand>;
|
|
1100
|
-
/**
|
|
1101
|
-
* The collection of parsed subcommands.
|
|
1102
|
-
*/
|
|
1103
|
-
subcommands: Collection<string, ParsedSubCommand>;
|
|
1104
|
-
/**
|
|
1105
|
-
* The collection of parsed middlewares.
|
|
1106
|
-
*/
|
|
1107
1115
|
middlewares: Collection<string, ParsedMiddleware>;
|
|
1116
|
+
subcommands: Collection<string, ParsedSubCommand>;
|
|
1108
1117
|
}
|
|
1109
1118
|
interface CommandsRouterOptions {
|
|
1110
1119
|
/**
|
|
1111
|
-
* The
|
|
1120
|
+
* The path to the directory containing the command files.
|
|
1112
1121
|
*/
|
|
1113
1122
|
entrypoint: string;
|
|
1114
1123
|
}
|
|
1115
1124
|
declare class CommandsRouter {
|
|
1116
|
-
private
|
|
1125
|
+
private options;
|
|
1117
1126
|
private commands;
|
|
1118
|
-
private subcommands;
|
|
1119
1127
|
private middlewares;
|
|
1128
|
+
private subcommands;
|
|
1120
1129
|
constructor(options: CommandsRouterOptions);
|
|
1121
|
-
get entrypoint(): string;
|
|
1122
1130
|
isValidPath(): boolean;
|
|
1123
|
-
|
|
1124
|
-
toJSON(): CommandsTree;
|
|
1131
|
+
get entrypoint(): string;
|
|
1125
1132
|
clear(): void;
|
|
1126
|
-
reload(): Promise<
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1133
|
+
reload(): Promise<CommandTree>;
|
|
1134
|
+
visualize(): string;
|
|
1135
|
+
getData(): ParsedCommandData;
|
|
1136
|
+
toJSON(): CommandTree;
|
|
1137
|
+
scan(): Promise<CommandTree>;
|
|
1138
|
+
private scanDeep;
|
|
1139
|
+
private processMiddleware;
|
|
1140
|
+
private processSubcommand;
|
|
1130
1141
|
private processCommand;
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1142
|
+
/**
|
|
1143
|
+
* Gets the appropriate file name, handling index files specially
|
|
1144
|
+
* For index files, it returns the parent directory name (excluding category markers)
|
|
1145
|
+
*/
|
|
1146
|
+
private getAppropriateFileName;
|
|
1147
|
+
/**
|
|
1148
|
+
* Extract the clean directory name, removing any category markers
|
|
1149
|
+
*/
|
|
1150
|
+
private getDirectoryName;
|
|
1151
|
+
private isCategoryDirectory;
|
|
1152
|
+
private applyMiddlewareToCommands;
|
|
1153
|
+
private applySubcommandToCommands;
|
|
1154
|
+
private extractCategory;
|
|
1155
|
+
private getRelativePath;
|
|
1156
|
+
private isMiddleware;
|
|
1157
|
+
private shouldIgnore;
|
|
1158
|
+
private extractName;
|
|
1135
1159
|
}
|
|
1136
1160
|
|
|
1137
1161
|
/**
|
|
@@ -1308,6 +1332,154 @@ declare class AppCommandHandler {
|
|
|
1308
1332
|
applyLocalizations(command: CommandBuilderLike): Promise<discord_js.RESTPostAPIContextMenuApplicationCommandsJSONBody | CommandBuilderLike>;
|
|
1309
1333
|
}
|
|
1310
1334
|
|
|
1335
|
+
declare class MemoryCache extends CacheProvider {
|
|
1336
|
+
#private;
|
|
1337
|
+
get<T>(key: string): Promise<CacheEntry<T> | undefined>;
|
|
1338
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
1339
|
+
exists(key: string): Promise<boolean>;
|
|
1340
|
+
delete(key: string): Promise<void>;
|
|
1341
|
+
clear(): Promise<void>;
|
|
1342
|
+
expire(key: string, ttl: number): Promise<void>;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Context for managing cache operations within an async scope
|
|
1347
|
+
*/
|
|
1348
|
+
interface CacheContext {
|
|
1349
|
+
params: {
|
|
1350
|
+
/** Custom name for the cache entry */
|
|
1351
|
+
name?: string;
|
|
1352
|
+
/** Time-to-live in milliseconds */
|
|
1353
|
+
ttl?: number;
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Represents an async function that can be cached
|
|
1358
|
+
* @template R - Array of argument types
|
|
1359
|
+
* @template T - Return type
|
|
1360
|
+
*/
|
|
1361
|
+
type AsyncFunction<R extends any[] = any[], T = any> = (...args: R) => Promise<T>;
|
|
1362
|
+
/**
|
|
1363
|
+
* Configuration options for cache behavior
|
|
1364
|
+
*/
|
|
1365
|
+
interface CacheMetadata {
|
|
1366
|
+
/** Time-to-live duration in milliseconds or as a string (e.g., '1h', '5m') */
|
|
1367
|
+
ttl?: number | string;
|
|
1368
|
+
/** Custom name for the cache entry */
|
|
1369
|
+
name?: string;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Internal cache implementation
|
|
1373
|
+
* @internal
|
|
1374
|
+
* @private
|
|
1375
|
+
* This is used directly by the compiler if the function is annotated with `"use cache"` directive.
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```ts
|
|
1378
|
+
* async function myCachedFunction() {
|
|
1379
|
+
* "use cache";
|
|
1380
|
+
* // can use cacheTag() and cacheLife() here to customize cache behavior
|
|
1381
|
+
* return await db.query('SELECT * FROM users');
|
|
1382
|
+
* }
|
|
1383
|
+
* ```
|
|
1384
|
+
*/
|
|
1385
|
+
declare function useCache<R extends any[], F extends AsyncFunction<R>>(fn: F, id?: string, params?: CacheMetadata): F;
|
|
1386
|
+
/**
|
|
1387
|
+
* Wraps an async function with caching capability
|
|
1388
|
+
* @template R - Array of argument types
|
|
1389
|
+
* @template F - Type of the async function
|
|
1390
|
+
* @param fn - The async function to cache
|
|
1391
|
+
* @param params - Optional cache configuration
|
|
1392
|
+
* @returns The wrapped function with caching behavior
|
|
1393
|
+
* @example
|
|
1394
|
+
* ```ts
|
|
1395
|
+
* const cachedFetch = cache(async (id: string) => {
|
|
1396
|
+
* return await db.findOne(id);
|
|
1397
|
+
* }, { ttl: '1h' });
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
declare function cache<R extends any[], F extends AsyncFunction<R>>(fn: F, params?: CacheMetadata): F;
|
|
1401
|
+
/**
|
|
1402
|
+
* Sets a custom identifier for the current cache operation
|
|
1403
|
+
* @param tag - The custom cache tag
|
|
1404
|
+
* @throws {Error} When called outside a cached function or without a tag
|
|
1405
|
+
* @example
|
|
1406
|
+
* ```ts
|
|
1407
|
+
* const fetchUser = cache(async (id: string) => {
|
|
1408
|
+
* cacheTag(`user:${id}`);
|
|
1409
|
+
* return await db.users.findOne(id);
|
|
1410
|
+
* });
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
declare function cacheTag(tag: string): void;
|
|
1414
|
+
/**
|
|
1415
|
+
* Sets the TTL for the current cache operation
|
|
1416
|
+
* @param ttl - Time-to-live in milliseconds or as a string (e.g., '1h', '5m')
|
|
1417
|
+
* @throws {Error} When called outside a cached function or with invalid TTL
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```ts
|
|
1420
|
+
* const fetchData = cache(async () => {
|
|
1421
|
+
* cacheLife('30m');
|
|
1422
|
+
* return await expensiveOperation();
|
|
1423
|
+
* });
|
|
1424
|
+
* ```
|
|
1425
|
+
*/
|
|
1426
|
+
declare function cacheLife(ttl: number | string): void;
|
|
1427
|
+
/**
|
|
1428
|
+
* Removes a cached value by its tag
|
|
1429
|
+
* @param tag - The cache tag to invalidate
|
|
1430
|
+
* @throws {Error} When the cache key is not found
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* await invalidate('user:123');
|
|
1434
|
+
* ```
|
|
1435
|
+
*/
|
|
1436
|
+
declare function invalidate(tag: string): Promise<void>;
|
|
1437
|
+
/**
|
|
1438
|
+
* Forces a refresh of cached data by its tag (on-demand revalidation)
|
|
1439
|
+
* @template T - Type of the cached value
|
|
1440
|
+
* @param tag - The cache tag to revalidate
|
|
1441
|
+
* @param args - Arguments to pass to the cached function
|
|
1442
|
+
* @returns Fresh data from the cached function
|
|
1443
|
+
* @throws {Error} When the cache key or function is not found
|
|
1444
|
+
* @example
|
|
1445
|
+
* ```ts
|
|
1446
|
+
* const freshData = await revalidate('user:123');
|
|
1447
|
+
* ```
|
|
1448
|
+
*/
|
|
1449
|
+
declare function revalidate<T = unknown>(tag: string, ...args: any[]): Promise<T>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Checks if a function is wrapped with cache functionality
|
|
1452
|
+
* @param fn - Function to check
|
|
1453
|
+
* @returns True if the function is cached
|
|
1454
|
+
* @example
|
|
1455
|
+
* ```ts
|
|
1456
|
+
* if (isCachedFunction(myFunction)) {
|
|
1457
|
+
* console.log('Function is cached');
|
|
1458
|
+
* }
|
|
1459
|
+
* ```
|
|
1460
|
+
*/
|
|
1461
|
+
declare function isCachedFunction(fn: GenericFunction): boolean;
|
|
1462
|
+
|
|
1463
|
+
type ListenerFunction = GenericFunction | AsyncFunction;
|
|
1464
|
+
declare class CommandKitEventsChannel {
|
|
1465
|
+
readonly commandkit: CommandKit;
|
|
1466
|
+
private emitter;
|
|
1467
|
+
constructor(commandkit: CommandKit);
|
|
1468
|
+
to(namespace: string): {
|
|
1469
|
+
on: (event: string, listener: ListenerFunction) => void;
|
|
1470
|
+
off: (event: string, listener: ListenerFunction) => void;
|
|
1471
|
+
once: (event: string, listener: ListenerFunction) => void;
|
|
1472
|
+
emit: (event: string, ...args: any[]) => boolean;
|
|
1473
|
+
removeAllListeners: (event: string) => void;
|
|
1474
|
+
};
|
|
1475
|
+
on(namespace: string, event: string, listener: ListenerFunction): void;
|
|
1476
|
+
off(namespace: string, event: string, listener: ListenerFunction): void;
|
|
1477
|
+
once(namespace: string, event: string, listener: ListenerFunction): void;
|
|
1478
|
+
emit(namespace: string, event: string, ...args: any[]): boolean;
|
|
1479
|
+
removeAllListeners(namespace: string): void;
|
|
1480
|
+
removeAllListeners(namespace: string, event: string): void;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1311
1483
|
declare class AppEventsHandler {
|
|
1312
1484
|
readonly commandkit: CommandKit;
|
|
1313
1485
|
private loadedEvents;
|
|
@@ -1471,6 +1643,7 @@ declare class DefaultLocalizationStrategy implements LocalizationStrategy {
|
|
|
1471
1643
|
private translations;
|
|
1472
1644
|
constructor(commandkit: CommandKit);
|
|
1473
1645
|
locateTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
1646
|
+
private generateLocaleTypes;
|
|
1474
1647
|
getTranslationStrict(scope: string, locale: Locale): Promise<Translation>;
|
|
1475
1648
|
getTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
1476
1649
|
translate(request: LocalizationTranslationRequest): Promise<TranslationResult>;
|
|
@@ -1548,140 +1721,13 @@ declare abstract class RuntimePlugin<T extends PluginOptions = PluginOptions> ex
|
|
|
1548
1721
|
executeCommand(ctx: CommandKitPluginRuntime, source: Interaction | Message$1, command: PreparedAppCommandExecution, execute: () => Promise<any>): Promise<boolean>;
|
|
1549
1722
|
}
|
|
1550
1723
|
|
|
1551
|
-
declare class MemoryCache extends CacheProvider {
|
|
1552
|
-
#private;
|
|
1553
|
-
get<T>(key: string): Promise<CacheEntry<T> | undefined>;
|
|
1554
|
-
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
1555
|
-
exists(key: string): Promise<boolean>;
|
|
1556
|
-
delete(key: string): Promise<void>;
|
|
1557
|
-
clear(): Promise<void>;
|
|
1558
|
-
expire(key: string, ttl: number): Promise<void>;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
/**
|
|
1562
|
-
* Context for managing cache operations within an async scope
|
|
1563
|
-
*/
|
|
1564
|
-
interface CacheContext {
|
|
1565
|
-
params: {
|
|
1566
|
-
/** Custom name for the cache entry */
|
|
1567
|
-
name?: string;
|
|
1568
|
-
/** Time-to-live in milliseconds */
|
|
1569
|
-
ttl?: number;
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
|
-
/**
|
|
1573
|
-
* Represents an async function that can be cached
|
|
1574
|
-
* @template R - Array of argument types
|
|
1575
|
-
* @template T - Return type
|
|
1576
|
-
*/
|
|
1577
|
-
type AsyncFunction<R extends any[] = any[], T = any> = (...args: R) => Promise<T>;
|
|
1578
|
-
/**
|
|
1579
|
-
* Configuration options for cache behavior
|
|
1580
|
-
*/
|
|
1581
|
-
interface CacheMetadata {
|
|
1582
|
-
/** Time-to-live duration in milliseconds or as a string (e.g., '1h', '5m') */
|
|
1583
|
-
ttl?: number | string;
|
|
1584
|
-
/** Custom name for the cache entry */
|
|
1585
|
-
name?: string;
|
|
1586
|
-
}
|
|
1587
|
-
/**
|
|
1588
|
-
* Internal cache implementation
|
|
1589
|
-
* @internal
|
|
1590
|
-
* @private
|
|
1591
|
-
* This is used directly by the compiler if the function is annotated with `"use cache"` directive.
|
|
1592
|
-
* @example
|
|
1593
|
-
* ```ts
|
|
1594
|
-
* async function myCachedFunction() {
|
|
1595
|
-
* "use cache";
|
|
1596
|
-
* // can use cacheTag() and cacheLife() here to customize cache behavior
|
|
1597
|
-
* return await db.query('SELECT * FROM users');
|
|
1598
|
-
* }
|
|
1599
|
-
* ```
|
|
1600
|
-
*/
|
|
1601
|
-
declare function useCache<R extends any[], F extends AsyncFunction<R>>(fn: F, id?: string, params?: CacheMetadata): F;
|
|
1602
|
-
/**
|
|
1603
|
-
* Wraps an async function with caching capability
|
|
1604
|
-
* @template R - Array of argument types
|
|
1605
|
-
* @template F - Type of the async function
|
|
1606
|
-
* @param fn - The async function to cache
|
|
1607
|
-
* @param params - Optional cache configuration
|
|
1608
|
-
* @returns The wrapped function with caching behavior
|
|
1609
|
-
* @example
|
|
1610
|
-
* ```ts
|
|
1611
|
-
* const cachedFetch = cache(async (id: string) => {
|
|
1612
|
-
* return await db.findOne(id);
|
|
1613
|
-
* }, { ttl: '1h' });
|
|
1614
|
-
* ```
|
|
1615
|
-
*/
|
|
1616
|
-
declare function cache<R extends any[], F extends AsyncFunction<R>>(fn: F, params?: CacheMetadata): F;
|
|
1617
|
-
/**
|
|
1618
|
-
* Sets a custom identifier for the current cache operation
|
|
1619
|
-
* @param tag - The custom cache tag
|
|
1620
|
-
* @throws {Error} When called outside a cached function or without a tag
|
|
1621
|
-
* @example
|
|
1622
|
-
* ```ts
|
|
1623
|
-
* const fetchUser = cache(async (id: string) => {
|
|
1624
|
-
* cacheTag(`user:${id}`);
|
|
1625
|
-
* return await db.users.findOne(id);
|
|
1626
|
-
* });
|
|
1627
|
-
* ```
|
|
1628
|
-
*/
|
|
1629
|
-
declare function cacheTag(tag: string): void;
|
|
1630
|
-
/**
|
|
1631
|
-
* Sets the TTL for the current cache operation
|
|
1632
|
-
* @param ttl - Time-to-live in milliseconds or as a string (e.g., '1h', '5m')
|
|
1633
|
-
* @throws {Error} When called outside a cached function or with invalid TTL
|
|
1634
|
-
* @example
|
|
1635
|
-
* ```ts
|
|
1636
|
-
* const fetchData = cache(async () => {
|
|
1637
|
-
* cacheLife('30m');
|
|
1638
|
-
* return await expensiveOperation();
|
|
1639
|
-
* });
|
|
1640
|
-
* ```
|
|
1641
|
-
*/
|
|
1642
|
-
declare function cacheLife(ttl: number | string): void;
|
|
1643
|
-
/**
|
|
1644
|
-
* Removes a cached value by its tag
|
|
1645
|
-
* @param tag - The cache tag to invalidate
|
|
1646
|
-
* @throws {Error} When the cache key is not found
|
|
1647
|
-
* @example
|
|
1648
|
-
* ```ts
|
|
1649
|
-
* await invalidate('user:123');
|
|
1650
|
-
* ```
|
|
1651
|
-
*/
|
|
1652
|
-
declare function invalidate(tag: string): Promise<void>;
|
|
1653
|
-
/**
|
|
1654
|
-
* Forces a refresh of cached data by its tag (on-demand revalidation)
|
|
1655
|
-
* @template T - Type of the cached value
|
|
1656
|
-
* @param tag - The cache tag to revalidate
|
|
1657
|
-
* @param args - Arguments to pass to the cached function
|
|
1658
|
-
* @returns Fresh data from the cached function
|
|
1659
|
-
* @throws {Error} When the cache key or function is not found
|
|
1660
|
-
* @example
|
|
1661
|
-
* ```ts
|
|
1662
|
-
* const freshData = await revalidate('user:123');
|
|
1663
|
-
* ```
|
|
1664
|
-
*/
|
|
1665
|
-
declare function revalidate<T = unknown>(tag: string, ...args: any[]): Promise<T>;
|
|
1666
|
-
/**
|
|
1667
|
-
* Checks if a function is wrapped with cache functionality
|
|
1668
|
-
* @param fn - Function to check
|
|
1669
|
-
* @returns True if the function is cached
|
|
1670
|
-
* @example
|
|
1671
|
-
* ```ts
|
|
1672
|
-
* if (isCachedFunction(myFunction)) {
|
|
1673
|
-
* console.log('Function is cached');
|
|
1674
|
-
* }
|
|
1675
|
-
* ```
|
|
1676
|
-
*/
|
|
1677
|
-
declare function isCachedFunction(fn: GenericFunction): boolean;
|
|
1678
|
-
|
|
1679
1724
|
declare class CommandKitPluginRuntime extends EventTarget {
|
|
1680
1725
|
readonly commandkit: CommandKit;
|
|
1681
1726
|
private plugins;
|
|
1682
1727
|
private onClientLogin;
|
|
1683
1728
|
constructor(commandkit: CommandKit);
|
|
1684
1729
|
getPlugin(pluginName: string): RuntimePlugin | null;
|
|
1730
|
+
softRegisterPlugin(plugin: RuntimePlugin): Promise<void>;
|
|
1685
1731
|
registerPlugin(plugin: RuntimePlugin): Promise<void>;
|
|
1686
1732
|
unregisterPlugin(plugin: RuntimePlugin): Promise<void>;
|
|
1687
1733
|
unregisterAllPlugins(): Promise<void>;
|
|
@@ -1706,6 +1752,7 @@ declare class CommandKit extends EventEmitter {
|
|
|
1706
1752
|
readonly commandHandler: AppCommandHandler;
|
|
1707
1753
|
readonly eventHandler: AppEventsHandler;
|
|
1708
1754
|
readonly plugins: CommandKitPluginRuntime;
|
|
1755
|
+
readonly events: CommandKitEventsChannel;
|
|
1709
1756
|
static instance: CommandKit | undefined;
|
|
1710
1757
|
/**
|
|
1711
1758
|
* Create a new command and event handler with CommandKit.
|
|
@@ -1719,6 +1766,10 @@ declare class CommandKit extends EventEmitter {
|
|
|
1719
1766
|
* @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.
|
|
1720
1767
|
*/
|
|
1721
1768
|
start(token?: string | false): Promise<void>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Loads all the plugins.
|
|
1771
|
+
*/
|
|
1772
|
+
loadPlugins(): Promise<void>;
|
|
1722
1773
|
/**
|
|
1723
1774
|
* Whether or not the commandkit application has started.
|
|
1724
1775
|
*/
|
|
@@ -1952,4 +2003,4 @@ declare const version: string;
|
|
|
1952
2003
|
*/
|
|
1953
2004
|
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
1954
2005
|
|
|
1955
|
-
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 CommandObject, type CommandOptions, type CommandProps, CommandsRouter, type CommandsRouterOptions,
|
|
2006
|
+
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 CommandObject, type CommandOptions, type CommandProps, type CommandTree, CommandsRouter, type CommandsRouterOptions, 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 ParsedCommandData, type ParsedEvent, type ParsedMessageCommand, type ParsedMiddleware, type ParsedSubCommand, 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 };
|