commandkit 1.2.0-dev.20250825125304 → 1.2.0-dev.20250826015841
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/{EventWorkerContext-DiMpRt1P.d.ts → EventWorkerContext-BEezHh5-.d.ts} +2 -2
- package/dist/{EventWorkerContext-CSlD9rbx.js → EventWorkerContext-TZIKxVCu.js} +1 -1
- package/dist/{EventWorkerContext-CSlD9rbx.js.map → EventWorkerContext-TZIKxVCu.js.map} +1 -1
- package/dist/{MessageCommandParser-B_BEQ3p8.js → MessageCommandParser-TPEPhjvx.js} +2 -2
- package/dist/{MessageCommandParser-B_BEQ3p8.js.map → MessageCommandParser-TPEPhjvx.js.map} +1 -1
- package/dist/analytics/analytics-engine.d.ts +2 -2
- package/dist/analytics/analytics-engine.js +6 -6
- package/dist/analytics/analytics-provider.d.ts +2 -2
- package/dist/analytics/constants.js +1 -1
- package/dist/analytics/utils.js +6 -6
- package/dist/{analytics-engine-Ddw9axi4.d.ts → analytics-engine-Iu_1uJop.d.ts} +2 -17
- package/dist/app/commands/AppCommandRunner.d.ts +2 -2
- package/dist/app/commands/AppCommandRunner.js +6 -6
- package/dist/app/commands/Context.d.ts +2 -2
- package/dist/app/commands/Context.js +6 -6
- package/dist/app/commands/MessageCommandParser.js +2 -2
- package/dist/app/events/EventWorkerContext.d.ts +3 -3
- package/dist/app/events/EventWorkerContext.js +1 -1
- package/dist/app/handlers/AppCommandHandler.d.ts +2 -2
- package/dist/app/handlers/AppCommandHandler.js +6 -6
- package/dist/app/handlers/AppEventsHandler.d.ts +2 -2
- package/dist/app/handlers/AppEventsHandler.js +6 -6
- package/dist/app/index.d.ts +3 -3
- package/dist/app/index.js +8 -8
- package/dist/app/interrupt/signals.d.ts +2 -2
- package/dist/app/interrupt/signals.js +5 -5
- package/dist/app/middlewares/permissions.d.ts +2 -2
- package/dist/app/middlewares/permissions.js +6 -6
- package/dist/app/register/CommandRegistrar.d.ts +2 -2
- package/dist/app/register/CommandRegistrar.js +6 -6
- package/dist/{build-CoJqJ17n.js → build-Yhb1VjD0.js} +2 -2
- package/dist/build-Yhb1VjD0.js.map +1 -0
- package/dist/cli/build.d.ts +2 -2
- package/dist/cli/build.js +7 -7
- package/dist/cli/common.d.ts +2 -2
- package/dist/cli/development.js +8 -8
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/information.js +1 -1
- package/dist/cli/init.js +7 -7
- package/dist/cli/production.js +7 -7
- package/dist/{commandkit-CYJ8d2gj.js → commandkit-c0sAaK0G.js} +123 -133
- package/dist/commandkit-c0sAaK0G.js.map +1 -0
- package/dist/commandkit.d.ts +2 -2
- package/dist/commandkit.js +6 -6
- package/dist/components/index.js +6 -6
- package/dist/components/v1/button/Button.js +6 -6
- package/dist/components/v1/button/ButtonKit.js +6 -6
- package/dist/components/v1/modal/Modal.js +6 -6
- package/dist/components/v1/modal/ModalKit.js +6 -6
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +6 -6
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +6 -6
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +6 -6
- package/dist/components/v1/select-menu/SelectMenu.js +6 -6
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +6 -6
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +6 -6
- package/dist/config/config.d.ts +3 -3
- package/dist/config/config.js +6 -6
- package/dist/config/default.d.ts +2 -2
- package/dist/config/default.js +6 -6
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/loader.js +6 -6
- package/dist/config/types.d.ts +2 -2
- package/dist/config/utils.d.ts +2 -2
- package/dist/{config-C4nHXErw.d.ts → config-ClEaYnf1.d.ts} +2 -2
- package/dist/{constants-CUND8XkG.js → constants-DxfYtA6t.js} +1 -1
- package/dist/{constants-CUND8XkG.js.map → constants-DxfYtA6t.js.map} +1 -1
- package/dist/context/async-context.d.ts +2 -2
- package/dist/context/async-context.js +6 -6
- package/dist/context/environment.d.ts +2 -2
- package/dist/context/environment.js +6 -6
- package/dist/{error-codes-BzoEctmD.d.ts → error-codes-B4TyW4Ct.d.ts} +2 -2
- package/dist/{error-codes-C-ViHyu-.js → error-codes-Ds0bnPvT.js} +2 -2
- package/dist/error-codes-Ds0bnPvT.js.map +1 -0
- package/dist/events/CommandKitEventsChannel.d.ts +2 -2
- package/dist/{feature-flags-Co2WUAIe.js → feature-flags-Dxi9TI2e.js} +5 -5
- package/dist/{feature-flags-Co2WUAIe.js.map → feature-flags-Dxi9TI2e.js.map} +1 -1
- package/dist/flags/FlagProvider.d.ts +2 -2
- package/dist/flags/feature-flags.d.ts +2 -2
- package/dist/flags/feature-flags.js +7 -7
- package/dist/flags/store.d.ts +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/{init-CEuxl8qP.js → init-CrFvqdxZ.js} +2 -2
- package/dist/{init-CEuxl8qP.js.map → init-CrFvqdxZ.js.map} +1 -1
- package/dist/logger/DefaultLogger.js +6 -6
- package/dist/logger/Logger.js +6 -6
- package/dist/plugins/CompilerPlugin.d.ts +2 -2
- package/dist/plugins/PluginCommon.d.ts +2 -2
- package/dist/plugins/RuntimePlugin.d.ts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.js +6 -6
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +2 -2
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +6 -6
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +2 -2
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +6 -6
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +2 -2
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +6 -6
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +2 -2
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +6 -6
- package/dist/plugins/plugin-runtime/runtime.d.ts +2 -2
- package/dist/plugins/types.d.ts +2 -2
- package/dist/{signals-BQbEfy3X.d.ts → signals-SHg7J1U_.d.ts} +4 -7
- package/dist/{signals-DHdYrd-n.js → signals-r7qPAvOR.js} +12 -15
- package/dist/signals-r7qPAvOR.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/utils/dev-hooks.d.ts +2 -2
- package/dist/utils/dev-hooks.js +6 -6
- package/dist/utils/error-codes.d.ts +1 -1
- package/dist/utils/error-codes.js +1 -1
- package/dist/utils/utilities.js +6 -6
- package/dist/{version-B_bKw4jL.js → version-Dye7khwD.js} +2 -2
- package/dist/{version-B_bKw4jL.js.map → version-Dye7khwD.js.map} +1 -1
- package/dist/version.js +1 -1
- package/package.json +60 -59
- package/dist/build-CoJqJ17n.js.map +0 -1
- package/dist/commandkit-CYJ8d2gj.js.map +0 -1
- package/dist/error-codes-C-ViHyu-.js.map +0 -1
- package/dist/signals-DHdYrd-n.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
2
|
const require_colors = require('./colors-Cd4Oz-r-.js');
|
|
3
|
-
const require_error_codes = require('./error-codes-
|
|
3
|
+
const require_error_codes = require('./error-codes-Ds0bnPvT.js');
|
|
4
4
|
const require_element = require('./element-Bak9llw_.js');
|
|
5
5
|
const require_EventInterceptor = require('./EventInterceptor-CQ4PBpBJ.js');
|
|
6
6
|
const require_constants = require('./constants-B5_Ta7PR.js');
|
|
@@ -9,10 +9,10 @@ const require_RuntimePlugin = require('./RuntimePlugin-CBgBLXTG.js');
|
|
|
9
9
|
const require_utils = require('./utils-BnXM4eKk.js');
|
|
10
10
|
const require_resolve_file_url = require('./resolve-file-url-DHTQj2mU.js');
|
|
11
11
|
const require_types_package = require('./types-package-DrnIdWLg.js');
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const require_MessageCommandParser = require('./MessageCommandParser-
|
|
12
|
+
const require_constants$1 = require('./constants-DxfYtA6t.js');
|
|
13
|
+
const require_EventWorkerContext = require('./EventWorkerContext-TZIKxVCu.js');
|
|
14
|
+
const require_signals = require('./signals-r7qPAvOR.js');
|
|
15
|
+
const require_MessageCommandParser = require('./MessageCommandParser-TPEPhjvx.js');
|
|
16
16
|
const require_CommandsRouter = require('./CommandsRouter-tMAivEfv.js');
|
|
17
17
|
const require_EventsRouter = require('./EventsRouter-C_J0M3uO.js');
|
|
18
18
|
const require_common = require('./common-DNADUU3_.js');
|
|
@@ -66,6 +66,7 @@ function makeContextAwareFunction(env, fn, finalizer) {
|
|
|
66
66
|
return result;
|
|
67
67
|
} catch (e) {
|
|
68
68
|
if (!require_error_codes.isCommandKitError(e)) env.setExecutionError(e);
|
|
69
|
+
else throw e;
|
|
69
70
|
} finally {
|
|
70
71
|
if (typeof finalizer === "function") setImmediate(async () => {
|
|
71
72
|
try {
|
|
@@ -1290,8 +1291,10 @@ var DefaultLogger = class {
|
|
|
1290
1291
|
const prefix = this._getPrefix(level);
|
|
1291
1292
|
const context$1 = this._getContext();
|
|
1292
1293
|
const colorFn = TextColorMap[level];
|
|
1293
|
-
|
|
1294
|
-
|
|
1294
|
+
let processedMessage = message;
|
|
1295
|
+
if (message instanceof Error) processedMessage = `${message.message}\n${message.stack}`;
|
|
1296
|
+
if (context$1) this.logger.log(`${prefix}\n${context$1} ${require_colors.colors_default.dim(BoxChars.corner)}`, colorFn(processedMessage));
|
|
1297
|
+
else this.logger.log(`${prefix} ${require_colors.colors_default.dim(BoxChars.corner)}`, colorFn(processedMessage));
|
|
1295
1298
|
}
|
|
1296
1299
|
_logTemplate(level, strings, ...values) {
|
|
1297
1300
|
const prefix = this._getPrefix(level);
|
|
@@ -1300,10 +1303,15 @@ var DefaultLogger = class {
|
|
|
1300
1303
|
let result = "";
|
|
1301
1304
|
for (let i = 0; i < strings.length; i++) {
|
|
1302
1305
|
result += strings[i];
|
|
1303
|
-
if (i < values.length)
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1306
|
+
if (i < values.length) {
|
|
1307
|
+
const value = values[i];
|
|
1308
|
+
if (value instanceof Error) result += `${value.message}\n${value.stack}`;
|
|
1309
|
+
else if (value !== null && typeof value === "object") result += (0, util.inspect)(value, {
|
|
1310
|
+
colors: true,
|
|
1311
|
+
depth: 2
|
|
1312
|
+
});
|
|
1313
|
+
else result += value;
|
|
1314
|
+
}
|
|
1307
1315
|
}
|
|
1308
1316
|
if (context$1) this.logger.log(`${prefix}\n${context$1} ${require_colors.colors_default.dim(BoxChars.corner)}`, colorFn(result));
|
|
1309
1317
|
else this.logger.log(`${prefix} ${require_colors.colors_default.dim(BoxChars.corner)}`, colorFn(result));
|
|
@@ -1606,7 +1614,7 @@ var CompilerPluginRuntime = class {
|
|
|
1606
1614
|
await ((_plugin$activate = plugin.activate) === null || _plugin$activate === void 0 ? void 0 : _plugin$activate.call(plugin, this));
|
|
1607
1615
|
});
|
|
1608
1616
|
} catch (e) {
|
|
1609
|
-
|
|
1617
|
+
Logger.error`Plugin ${plugin.name} failed to activate with ${e}`;
|
|
1610
1618
|
}
|
|
1611
1619
|
this.initialized = true;
|
|
1612
1620
|
}
|
|
@@ -1625,7 +1633,7 @@ var CompilerPluginRuntime = class {
|
|
|
1625
1633
|
await ((_plugin$deactivate = plugin.deactivate) === null || _plugin$deactivate === void 0 ? void 0 : _plugin$deactivate.call(plugin, this));
|
|
1626
1634
|
});
|
|
1627
1635
|
} catch (e) {
|
|
1628
|
-
|
|
1636
|
+
Logger.error`Plugin ${plugin.name} failed to deactivate with ${e}`;
|
|
1629
1637
|
}
|
|
1630
1638
|
this.initialized = false;
|
|
1631
1639
|
}
|
|
@@ -2421,37 +2429,11 @@ var Context = class Context {
|
|
|
2421
2429
|
if (this.isMessage()) return this.config.messageCommandParser.getArgs();
|
|
2422
2430
|
return [];
|
|
2423
2431
|
}
|
|
2424
|
-
/**
|
|
2425
|
-
* Stops upcoming middleware or current command execution.
|
|
2426
|
-
* If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.
|
|
2427
|
-
* If this is called inside a command itself, it will skip all post-stage middlewares.
|
|
2428
|
-
* If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
|
|
2429
|
-
*/
|
|
2430
|
-
exit() {
|
|
2431
|
-
require_signals.exitMiddleware();
|
|
2432
|
-
}
|
|
2433
2432
|
};
|
|
2434
2433
|
/**
|
|
2435
2434
|
* Extended context class for middleware execution with additional control methods.
|
|
2436
2435
|
*/
|
|
2437
2436
|
var MiddlewareContext = class extends Context {
|
|
2438
|
-
/**
|
|
2439
|
-
* @private
|
|
2440
|
-
* @internal
|
|
2441
|
-
*/
|
|
2442
|
-
#cancel = false;
|
|
2443
|
-
/**
|
|
2444
|
-
* Whether the command execution was cancelled.
|
|
2445
|
-
*/
|
|
2446
|
-
get cancelled() {
|
|
2447
|
-
return this.#cancel;
|
|
2448
|
-
}
|
|
2449
|
-
/**
|
|
2450
|
-
* Cancels the command execution.
|
|
2451
|
-
*/
|
|
2452
|
-
cancel() {
|
|
2453
|
-
this.#cancel = true;
|
|
2454
|
-
}
|
|
2455
2437
|
/**
|
|
2456
2438
|
* Sets command runner function to wrap the command execution.
|
|
2457
2439
|
* @param fn The function to set.
|
|
@@ -2486,6 +2468,7 @@ var AppCommandRunner = class {
|
|
|
2486
2468
|
* Handles the complete command lifecycle including before/after middleware execution.
|
|
2487
2469
|
* @param prepared - The prepared command execution data
|
|
2488
2470
|
* @param source - The source interaction or message that triggered the command
|
|
2471
|
+
* @param options - The options for running the command
|
|
2489
2472
|
*/
|
|
2490
2473
|
async runCommand(prepared, source, options) {
|
|
2491
2474
|
const { commandkit: commandkit$1 } = this.handler;
|
|
@@ -2498,119 +2481,126 @@ var AppCommandRunner = class {
|
|
|
2498
2481
|
env.variables.set("currentCommandName", prepared.command.command.name);
|
|
2499
2482
|
env.variables.set("execHandlerKind", executionMode);
|
|
2500
2483
|
env.variables.set("customHandler", (options === null || options === void 0 ? void 0 : options.handler) ?? null);
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
try {
|
|
2518
|
-
await middleware.data.beforeExecute(
|
|
2484
|
+
try {
|
|
2485
|
+
const middlewareCtx = new MiddlewareContext(commandkit$1, {
|
|
2486
|
+
command: prepared.command,
|
|
2487
|
+
environment: env,
|
|
2488
|
+
executionMode,
|
|
2489
|
+
interaction: !(source instanceof discord_js.Message) ? source : null,
|
|
2490
|
+
message: source instanceof discord_js.Message ? source : null,
|
|
2491
|
+
forwarded: false,
|
|
2492
|
+
customArgs: { setCommandRunner: (fn) => {
|
|
2493
|
+
runCommand = fn;
|
|
2494
|
+
} },
|
|
2495
|
+
messageCommandParser: prepared.messageCommandParser
|
|
2496
|
+
});
|
|
2497
|
+
const beforeMiddlewares = prepared.middlewares.filter((m) => m.data.beforeExecute);
|
|
2498
|
+
let beforeMiddlewaresStopped = false;
|
|
2499
|
+
if (beforeMiddlewares.length) await provideContext(env, async () => {
|
|
2500
|
+
for (const middleware of beforeMiddlewares) try {
|
|
2501
|
+
await middleware.data.beforeExecute(middlewareCtx);
|
|
2519
2502
|
} catch (e) {
|
|
2520
|
-
if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.
|
|
2521
|
-
|
|
2522
|
-
|
|
2503
|
+
if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.StopMiddlewares)) {
|
|
2504
|
+
beforeMiddlewaresStopped = true;
|
|
2505
|
+
Logger.debug(`Middleware propagation stopped for command "${middlewareCtx.commandName}". stopMiddlewares() was called inside a beforeExecute function at "${middleware.middleware.relativePath}"`);
|
|
2506
|
+
break;
|
|
2523
2507
|
}
|
|
2524
2508
|
if (require_error_codes.isErrorType(e, [require_error_codes.CommandKitErrorCodes.ForwardedCommand, require_error_codes.CommandKitErrorCodes.InvalidCommandPrefix])) continue;
|
|
2525
2509
|
throw e;
|
|
2526
2510
|
}
|
|
2527
|
-
}
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2511
|
+
});
|
|
2512
|
+
let result;
|
|
2513
|
+
let stopMiddlewaresCalledInCmd = false;
|
|
2514
|
+
if (!beforeMiddlewaresStopped) {
|
|
2515
|
+
const targetData = prepared.command.data;
|
|
2516
|
+
const fn = targetData[(options === null || options === void 0 ? void 0 : options.handler) || executionMode];
|
|
2517
|
+
if (!fn) Logger.warn(`Command ${prepared.command.command.name} has no handler for ${executionMode}`);
|
|
2518
|
+
const analytics = commandkit$1.analytics;
|
|
2519
|
+
if (fn) try {
|
|
2520
|
+
const _executeCommand = makeContextAwareFunction(env, async () => {
|
|
2521
|
+
env.registerDeferredFunction(async (env$1) => {
|
|
2522
|
+
var _prepared$command2;
|
|
2523
|
+
env$1.markEnd();
|
|
2524
|
+
const error = env$1.getExecutionError();
|
|
2525
|
+
const marker = env$1.getMarker();
|
|
2526
|
+
const time = `${env$1.getExecutionTime().toFixed(2)}ms`;
|
|
2527
|
+
if (error) {
|
|
2528
|
+
var _prepared$command;
|
|
2529
|
+
Logger.error`[${marker} - ${time}] Error executing command: ${error}`;
|
|
2530
|
+
const commandName$1 = ((_prepared$command = prepared.command) === null || _prepared$command === void 0 || (_prepared$command = _prepared$command.data) === null || _prepared$command === void 0 || (_prepared$command = _prepared$command.command) === null || _prepared$command === void 0 ? void 0 : _prepared$command.name) ?? prepared.command.command.name;
|
|
2531
|
+
await analytics.track({
|
|
2532
|
+
name: require_constants$1.AnalyticsEvents.COMMAND_EXECUTION,
|
|
2533
|
+
id: commandName$1,
|
|
2534
|
+
data: {
|
|
2535
|
+
error: true,
|
|
2536
|
+
executionTime: env$1.getExecutionTime().toFixed(2),
|
|
2537
|
+
type: executionMode,
|
|
2538
|
+
command: commandName$1
|
|
2539
|
+
}
|
|
2540
|
+
});
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
Logger.info(`[${marker} - ${time}] Command executed successfully`);
|
|
2544
|
+
const commandName = ((_prepared$command2 = prepared.command) === null || _prepared$command2 === void 0 || (_prepared$command2 = _prepared$command2.data) === null || _prepared$command2 === void 0 || (_prepared$command2 = _prepared$command2.command) === null || _prepared$command2 === void 0 ? void 0 : _prepared$command2.name) ?? prepared.command.command.name;
|
|
2547
2545
|
await analytics.track({
|
|
2548
2546
|
name: require_constants$1.AnalyticsEvents.COMMAND_EXECUTION,
|
|
2549
|
-
id: commandName
|
|
2547
|
+
id: commandName,
|
|
2550
2548
|
data: {
|
|
2551
|
-
error:
|
|
2549
|
+
error: false,
|
|
2552
2550
|
executionTime: env$1.getExecutionTime().toFixed(2),
|
|
2553
2551
|
type: executionMode,
|
|
2554
|
-
command: commandName
|
|
2552
|
+
command: commandName
|
|
2555
2553
|
}
|
|
2556
2554
|
});
|
|
2557
|
-
return;
|
|
2558
|
-
}
|
|
2559
|
-
Logger.info(`[${marker} - ${time}] Command executed successfully`);
|
|
2560
|
-
const commandName = ((_prepared$command2 = prepared.command) === null || _prepared$command2 === void 0 || (_prepared$command2 = _prepared$command2.data) === null || _prepared$command2 === void 0 || (_prepared$command2 = _prepared$command2.command) === null || _prepared$command2 === void 0 ? void 0 : _prepared$command2.name) ?? prepared.command.command.name;
|
|
2561
|
-
await analytics.track({
|
|
2562
|
-
name: require_constants$1.AnalyticsEvents.COMMAND_EXECUTION,
|
|
2563
|
-
id: commandName,
|
|
2564
|
-
data: {
|
|
2565
|
-
error: false,
|
|
2566
|
-
executionTime: env$1.getExecutionTime().toFixed(2),
|
|
2567
|
-
type: executionMode,
|
|
2568
|
-
command: commandName
|
|
2569
|
-
}
|
|
2570
2555
|
});
|
|
2556
|
+
return fn(middlewareCtx.clone());
|
|
2557
|
+
}, this.#finalizer.bind(this));
|
|
2558
|
+
const executeCommand = runCommand != null ? runCommand(_executeCommand) : _executeCommand;
|
|
2559
|
+
env.markStart(prepared.command.data.command.name);
|
|
2560
|
+
const res = await commandkit$1.plugins.execute(async (ctx, plugin) => {
|
|
2561
|
+
return plugin.executeCommand(ctx, env, source, prepared, executeCommand);
|
|
2571
2562
|
});
|
|
2572
|
-
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.ExitMiddleware)) middlewaresCanceled = true;
|
|
2582
|
-
if (!require_error_codes.isErrorType(e, [require_error_codes.CommandKitErrorCodes.ForwardedCommand, require_error_codes.CommandKitErrorCodes.ExitMiddleware])) {
|
|
2583
|
-
if (shouldThrowOnError) throw e;
|
|
2584
|
-
Logger.error(e);
|
|
2563
|
+
if (!res) result = await executeCommand();
|
|
2564
|
+
} catch (e) {
|
|
2565
|
+
if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.StopMiddlewares)) {
|
|
2566
|
+
stopMiddlewaresCalledInCmd = true;
|
|
2567
|
+
Logger.debug(`Middleware propagation stopped for command "${middlewareCtx.commandName}". stopMiddlewares() was called by the command itself`);
|
|
2568
|
+
} else if (!require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.ForwardedCommand)) {
|
|
2569
|
+
if (shouldThrowOnError) throw e;
|
|
2570
|
+
Logger.error`${e}`;
|
|
2571
|
+
}
|
|
2585
2572
|
}
|
|
2586
|
-
}
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
try {
|
|
2595
|
-
await middleware.data.afterExecute(ctx);
|
|
2573
|
+
} else result = {
|
|
2574
|
+
error: true,
|
|
2575
|
+
message: "Command execution was cancelled by a beforeExecute middleware."
|
|
2576
|
+
};
|
|
2577
|
+
const afterMiddlewares = prepared.middlewares.filter((m) => m.data.afterExecute);
|
|
2578
|
+
if (!beforeMiddlewaresStopped && !stopMiddlewaresCalledInCmd && afterMiddlewares.length) await provideContext(env, async () => {
|
|
2579
|
+
for (const middleware of afterMiddlewares) try {
|
|
2580
|
+
await middleware.data.afterExecute(middlewareCtx);
|
|
2596
2581
|
} catch (e) {
|
|
2597
|
-
if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.
|
|
2582
|
+
if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.StopMiddlewares)) {
|
|
2583
|
+
Logger.debug(`Middleware propagation stopped for command "${middlewareCtx.commandName}". stopMiddlewares() was called inside an afterExecute function at "${middleware.middleware.relativePath}"`);
|
|
2584
|
+
break;
|
|
2585
|
+
}
|
|
2598
2586
|
throw e;
|
|
2599
2587
|
}
|
|
2600
|
-
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2588
|
+
});
|
|
2589
|
+
return result;
|
|
2590
|
+
} finally {
|
|
2591
|
+
await this.#finalizer(env, false);
|
|
2592
|
+
}
|
|
2603
2593
|
}
|
|
2604
2594
|
/**
|
|
2605
2595
|
* @private
|
|
2606
2596
|
* @internal
|
|
2607
2597
|
* Finalizes command execution by running deferred functions and plugin cleanup.
|
|
2608
2598
|
*/
|
|
2609
|
-
async #finalizer() {
|
|
2610
|
-
|
|
2599
|
+
async #finalizer(env, runPlugins = true) {
|
|
2600
|
+
env ??= useEnvironment();
|
|
2611
2601
|
await env.runDeferredFunctions();
|
|
2612
2602
|
env.clearAllDeferredFunctions();
|
|
2613
|
-
await this.handler.commandkit.plugins.execute(async (ctx, plugin) => {
|
|
2603
|
+
if (runPlugins) await this.handler.commandkit.plugins.execute(async (ctx, plugin) => {
|
|
2614
2604
|
await plugin.onAfterCommand(ctx, env);
|
|
2615
2605
|
});
|
|
2616
2606
|
}
|
|
@@ -2820,7 +2810,7 @@ async function beforeExecute(ctx) {
|
|
|
2820
2810
|
} catch (error) {
|
|
2821
2811
|
Logger.error`Could not send 'Server-only command' DM to user ${(interaction === null || interaction === void 0 ? void 0 : interaction.user.id) ?? (message === null || message === void 0 ? void 0 : message.author.id)} for command ${command.command.name}: ${error}`;
|
|
2822
2812
|
}
|
|
2823
|
-
|
|
2813
|
+
require_signals.stopMiddlewares();
|
|
2824
2814
|
}
|
|
2825
2815
|
const userPermissions = (interaction === null || interaction === void 0 ? void 0 : interaction.memberPermissions) ?? (message === null || message === void 0 || (_message$member = message.member) === null || _message$member === void 0 ? void 0 : _message$member.permissions);
|
|
2826
2816
|
let userPermissionsRequired = ((_command$metadata = command.metadata) === null || _command$metadata === void 0 ? void 0 : _command$metadata.userPermissions) ?? [];
|
|
@@ -2870,7 +2860,7 @@ async function beforeExecute(ctx) {
|
|
|
2870
2860
|
} catch (error) {
|
|
2871
2861
|
Logger.error`Could not send 'Not enough permissions' reply to user ${(interaction === null || interaction === void 0 ? void 0 : interaction.user.id) ?? (message === null || message === void 0 ? void 0 : message.author.id)} for command ${command.command.name}: ${error}`;
|
|
2872
2862
|
}
|
|
2873
|
-
|
|
2863
|
+
require_signals.stopMiddlewares();
|
|
2874
2864
|
}
|
|
2875
2865
|
|
|
2876
2866
|
//#endregion
|
|
@@ -3082,7 +3072,7 @@ var AppCommandHandler = class {
|
|
|
3082
3072
|
var _loadedCommand$metada, _loadedCommand$metada2, _json$options;
|
|
3083
3073
|
const loadedCommand$1 = this.findCommandByName(command);
|
|
3084
3074
|
if (!loadedCommand$1) {
|
|
3085
|
-
if (require_constants.COMMANDKIT_IS_DEV && this.commandkit.config.showUnknownPrefixCommandsWarning) Logger.error
|
|
3075
|
+
if (require_constants.COMMANDKIT_IS_DEV && this.commandkit.config.showUnknownPrefixCommandsWarning) Logger.error`Prefix command "${command}" was not found.\nNote: This warning is only shown in development mode as an alert to help you find the command. If you wish to remove this warning, set \`showUnknownPrefixCommandsWarning\` to \`false\` in your commandkit config.`;
|
|
3086
3076
|
return null;
|
|
3087
3077
|
}
|
|
3088
3078
|
if (source.guildId && ((_loadedCommand$metada = loadedCommand$1.metadata) === null || _loadedCommand$metada === void 0 || (_loadedCommand$metada = _loadedCommand$metada.guilds) === null || _loadedCommand$metada === void 0 ? void 0 : _loadedCommand$metada.length) && !((_loadedCommand$metada2 = loadedCommand$1.metadata) === null || _loadedCommand$metada2 === void 0 ? void 0 : _loadedCommand$metada2.guilds.includes(source.guildId))) return null;
|
|
@@ -3098,7 +3088,7 @@ var AppCommandHandler = class {
|
|
|
3098
3088
|
cmdName = parts[0];
|
|
3099
3089
|
} catch (e) {
|
|
3100
3090
|
if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.InvalidCommandPrefix)) return null;
|
|
3101
|
-
Logger.error
|
|
3091
|
+
Logger.error`${e}`;
|
|
3102
3092
|
return null;
|
|
3103
3093
|
}
|
|
3104
3094
|
} else {
|
|
@@ -3383,7 +3373,7 @@ var AppEventsHandler = class {
|
|
|
3383
3373
|
const listeners = [];
|
|
3384
3374
|
for (const listener of event.listeners) {
|
|
3385
3375
|
const handler = await import(require_resolve_file_url.toFileURL(listener, true));
|
|
3386
|
-
if (!handler.default || typeof handler.default !== "function") Logger.error
|
|
3376
|
+
if (!handler.default || typeof handler.default !== "function") Logger.error`Event handler for ${event.event}${event.namespace ? ` of namespace ${event.namespace}` : ""} does not have a default export or is not a function`;
|
|
3387
3377
|
listeners.push({
|
|
3388
3378
|
handler: handler.default,
|
|
3389
3379
|
once: !!handler.once
|
|
@@ -3915,7 +3905,7 @@ var CommandKit = class CommandKit extends node_events.default {
|
|
|
3915
3905
|
registerDevHooks(this);
|
|
3916
3906
|
await require_types_package.generateTypesPackage();
|
|
3917
3907
|
} catch (e) {
|
|
3918
|
-
if (process.env.COMMANDKIT_DEBUG_TYPEGEN) Logger.error
|
|
3908
|
+
if (process.env.COMMANDKIT_DEBUG_TYPEGEN) Logger.error`${e}`;
|
|
3919
3909
|
}
|
|
3920
3910
|
await this.loadPlugins();
|
|
3921
3911
|
await this.#init();
|
|
@@ -4472,4 +4462,4 @@ Object.defineProperty(exports, 'useEnvironment', {
|
|
|
4472
4462
|
return useEnvironment;
|
|
4473
4463
|
}
|
|
4474
4464
|
});
|
|
4475
|
-
//# sourceMappingURL=commandkit-
|
|
4465
|
+
//# sourceMappingURL=commandkit-c0sAaK0G.js.map
|