commandkit 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cache.cjs +2 -0
- package/cache.d.ts +1 -0
- package/dist/{ActionRow-Bt9qi0Mb.d.ts → ActionRow-DSh9roc5.d.ts} +2 -3
- package/dist/{Button-DxJLcZIU.d.ts → Button-BPsE5ju0.d.ts} +5 -6
- package/dist/{ButtonKit-BfcyvWfj.d.ts → ButtonKit-CNPmVg3h.d.ts} +2 -3
- package/dist/{ChannelSelectMenuKit-DYkudikb.d.ts → ChannelSelectMenuKit-CcOdaLQ6.d.ts} +3 -4
- package/dist/CommandTree-qu-8oAEV.d.ts +55 -0
- package/dist/CommandsRouter-Co225Ae5.d.ts +242 -0
- package/dist/{EventInterceptor-D9JKMcfi.d.ts → EventInterceptor-wg378vJp.d.ts} +1 -2
- package/dist/{EventsRouter-EuuSu6NH.d.ts → EventsRouter-Bt63ZuEF.d.ts} +21 -2
- package/dist/{MentionableSelectMenuKit-Mu4xqP6B.d.ts → MentionableSelectMenuKit-8_Nkgn_a.d.ts} +3 -4
- package/dist/{MessageCommandParser-DPCbHXCS.d.ts → MessageCommandParser-BYbxHOSK.d.ts} +7 -2
- package/dist/{Modal-v9rrcMl-.d.ts → Modal-DbWK6VmV.d.ts} +5 -6
- package/dist/{ModalKit-XJSM65SV.d.ts → ModalKit-CnmUVpw-.d.ts} +2 -3
- package/dist/{RoleSelectMenuKit-CCjcp3HY.d.ts → RoleSelectMenuKit-Bei7DHqD.d.ts} +3 -4
- package/dist/{SelectMenu-CY0vvoSu.d.ts → SelectMenu-Bce_PClo.d.ts} +8 -9
- package/dist/{StringSelectMenuKit-G5nBTicX.d.ts → StringSelectMenuKit-CBeB9HqT.d.ts} +3 -4
- package/dist/TreeArtifact-D6FZ5SVd.d.ts +27 -0
- package/dist/{UserSelectMenuKit-D3SO_fXA.d.ts → UserSelectMenuKit-DZmeZ_Tp.d.ts} +3 -4
- package/dist/analytics/analytics-engine.d.ts +1 -1
- package/dist/analytics/analytics-engine.js +1 -1
- package/dist/analytics/analytics-provider.d.ts +1 -1
- package/dist/analytics/constants.js +0 -1
- package/dist/analytics/constants.js.map +1 -1
- package/dist/analytics/utils.js +1 -1
- package/dist/{analytics-engine-DnRsHBId.d.ts → analytics-engine-Bz1p7ud3.d.ts} +178 -30
- package/dist/app/commands/AppCommandRunner.d.ts +1 -1
- package/dist/app/commands/AppCommandRunner.js +1 -1
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/commands/Context.js +1 -1
- package/dist/app/commands/MessageCommandParser.d.ts +1 -1
- package/dist/app/commands/MessageCommandParser.js +79 -71
- package/dist/app/commands/MessageCommandParser.js.map +1 -1
- package/dist/app/commands/helpers.d.ts +1 -1
- package/dist/app/commands/helpers.js +0 -1
- package/dist/app/commands/helpers.js.map +1 -1
- package/dist/app/events/EventWorkerContext.d.ts +3 -3
- package/dist/app/events/EventWorkerContext.js +0 -1
- package/dist/app/events/EventWorkerContext.js.map +1 -1
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
- package/dist/app/handlers/AppCommandHandler.js +1 -1
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.js +1 -1
- package/dist/app/index.d.ts +5 -5
- package/dist/app/index.js +1 -1
- package/dist/app/interrupt/signals.d.ts +1 -1
- package/dist/app/interrupt/signals.js.map +1 -1
- package/dist/app/middlewares/permissions.d.ts +1 -2
- package/dist/app/middlewares/permissions.js +1 -1
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.js +1 -1
- package/dist/app/router/CommandTree.d.ts +2 -0
- package/dist/app/router/CommandTree.js +1 -0
- package/dist/app/router/CommandsRouter.d.ts +2 -2
- package/dist/app/router/CommandsRouter.js +445 -24
- package/dist/app/router/CommandsRouter.js.map +1 -1
- package/dist/app/router/EventsRouter.d.ts +2 -2
- package/dist/app/router/EventsRouter.js +56 -3
- package/dist/app/router/EventsRouter.js.map +1 -1
- package/dist/app/router/TreeArtifact.d.ts +2 -0
- package/dist/app/router/TreeArtifact.js +87 -0
- package/dist/app/router/TreeArtifact.js.map +1 -0
- package/dist/app/router/index.d.ts +6 -3
- package/dist/app/router/index.js +8 -1
- package/dist/checkbox-DoR0Pcxm.d.ts +27 -0
- package/dist/cli/app-process.d.ts +2 -3
- package/dist/cli/app-process.js +15 -4
- package/dist/cli/app-process.js.map +1 -1
- package/dist/cli/build.d.ts +4 -9
- package/dist/cli/build.js +33 -5
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/common.d.ts +3 -6
- package/dist/cli/common.js +2 -2
- package/dist/cli/common.js.map +1 -1
- package/dist/cli/development.d.ts +5 -6
- package/dist/cli/development.js +12 -12
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/generators.js +0 -1
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js +5 -5
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +1 -3
- package/dist/cli/init.js +37 -12
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/production.d.ts +1 -3
- package/dist/cli/production.js +4 -4
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +0 -1
- package/dist/cli/type-checker.js.map +1 -1
- package/dist/cli/utils.d.ts +0 -1
- package/dist/cli/utils.js.map +1 -1
- package/dist/{commandkit-Bh7C1_c7.js → commandkit-DNbfLwyR.js} +786 -200
- package/dist/commandkit-DNbfLwyR.js.map +1 -0
- package/dist/commandkit.d.ts +1 -1
- package/dist/commandkit.js +1 -1
- package/dist/{common-CCvvgnxi.d.ts → common-CIbPzguv.d.ts} +2 -3
- package/dist/components/common/EventInterceptor.d.ts +1 -1
- package/dist/components/common/EventInterceptor.js +1 -0
- package/dist/components/common/EventInterceptor.js.map +1 -1
- package/dist/components/common/element.d.ts +1 -1
- package/dist/components/common/element.js +1 -1
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/display/common.d.ts +0 -1
- package/dist/components/display/common.js +1 -1
- package/dist/components/display/container.d.ts +1 -1
- package/dist/components/display/container.js +1 -1
- package/dist/components/display/file.d.ts +1 -1
- package/dist/components/display/file.js +0 -1
- package/dist/components/display/file.js.map +1 -1
- package/dist/components/display/index.d.ts +9 -8
- package/dist/components/display/index.js +1 -1
- package/dist/components/display/label.d.ts +1 -1
- package/dist/components/display/label.js +1 -1
- package/dist/components/display/media-gallery.d.ts +1 -1
- package/dist/components/display/media-gallery.js +1 -1
- package/dist/components/display/poll.d.ts +1 -1
- package/dist/components/display/poll.js +4 -10
- package/dist/components/display/poll.js.map +1 -1
- package/dist/components/display/section.d.ts +1 -1
- package/dist/components/display/section.js +1 -1
- package/dist/components/display/separator.d.ts +1 -1
- package/dist/components/display/separator.js +0 -1
- package/dist/components/display/separator.js.map +1 -1
- package/dist/components/display/text-display.d.ts +1 -1
- package/dist/components/display/text-display.js +0 -1
- package/dist/components/display/text-display.js.map +1 -1
- package/dist/components/index.d.ts +26 -23
- package/dist/components/index.js +6 -1
- package/dist/components/interactive/action-row/ActionRow.d.ts +1 -1
- package/dist/components/interactive/action-row/ActionRow.js +0 -1
- package/dist/components/interactive/action-row/ActionRow.js.map +1 -1
- package/dist/components/interactive/button/Button.d.ts +1 -1
- package/dist/components/interactive/button/Button.js +1 -1
- package/dist/components/interactive/button/ButtonKit.d.ts +1 -1
- package/dist/components/interactive/button/ButtonKit.js +1 -1
- package/dist/components/interactive/checkbox/checkbox.d.ts +2 -0
- package/dist/components/interactive/checkbox/checkbox.js +6 -0
- package/dist/components/interactive/modal/Modal.d.ts +1 -1
- package/dist/components/interactive/modal/Modal.js +1 -1
- package/dist/components/interactive/modal/ModalKit.d.ts +1 -1
- package/dist/components/interactive/modal/ModalKit.js +1 -1
- package/dist/components/interactive/radio/radio.d.ts +2 -0
- package/dist/components/interactive/radio/radio.js +5 -0
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/SelectMenu.d.ts +1 -1
- package/dist/components/interactive/select-menu/SelectMenu.js +1 -1
- package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/common.d.ts +1 -1
- package/dist/config/config.d.ts +1 -2
- package/dist/config/config.js +1 -1
- package/dist/config/default.d.ts +1 -2
- package/dist/config/default.js +1 -1
- package/dist/config/loader.d.ts +1 -2
- package/dist/config/loader.js +1 -1
- package/dist/config/types.d.ts +2 -2
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/utils.js.map +1 -1
- package/dist/{constants-DqtJY0t-.d.ts → constants-B7AfnOFa.d.ts} +1 -1
- package/dist/{constants-DwxpkIeH.d.ts → constants-kWgE3L9F.d.ts} +15 -2
- package/dist/{container-CYojOA9d.d.ts → container-NVgblXmw.d.ts} +1 -2
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/async-context.js +1 -1
- package/dist/context/environment.d.ts +1 -1
- package/dist/context/environment.js +1 -1
- package/dist/{element-DeLvTMfZ.d.ts → element-BMZYAAQ-.d.ts} +3 -4
- package/dist/events/CommandKitEventsChannel.d.ts +1 -1
- package/dist/events/CommandKitEventsChannel.js +3 -2
- package/dist/events/CommandKitEventsChannel.js.map +1 -1
- package/dist/{file-DLO1zEcH.d.ts → file-DYAmr697.d.ts} +1 -2
- package/dist/flags/FlagProvider.d.ts +1 -1
- package/dist/flags/FlagProvider.js +1 -0
- package/dist/flags/FlagProvider.js.map +1 -1
- package/dist/flags/feature-flags.d.ts +1 -1
- package/dist/flags/feature-flags.js +1 -1
- package/dist/flags/store.d.ts +1 -1
- package/dist/flags/store.js +0 -1
- package/dist/flags/store.js.map +1 -1
- package/dist/{helpers-zmC44Mcu.d.ts → helpers-vlnRvNJv.d.ts} +1 -2
- package/dist/index-CAFaKBs_.d.ts +8 -0
- package/dist/index-COt7nfC9.d.ts +2 -0
- package/dist/index-DvqHpiuh.d.ts +16 -0
- package/dist/index.d.ts +37 -31
- package/dist/index.js +14 -2
- package/dist/kv/constants.d.ts +1 -1
- package/dist/kv/constants.js.map +1 -1
- package/dist/kv/dotprops.js.map +1 -1
- package/dist/kv/kv.d.ts +0 -1
- package/dist/kv/kv.js +1 -1
- package/dist/kv/kv.js.map +1 -1
- package/dist/kv/serde.d.ts +1 -2
- package/dist/kv/serde.js +27 -27
- package/dist/kv/serde.js.map +1 -1
- package/dist/{label-DqGRqodo.d.ts → label-DClaYktn.d.ts} +1 -2
- package/dist/logger/DefaultLogger.d.ts +0 -1
- package/dist/logger/DefaultLogger.js +1 -1
- package/dist/logger/Logger.d.ts +0 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/NoopLogger.d.ts +0 -1
- package/dist/logger/NoopLogger.js.map +1 -1
- package/dist/{media-gallery-Ca8es-eB.d.ts → media-gallery-z2Snzz-u.d.ts} +1 -2
- package/dist/plugins/CompilerPlugin.d.ts +1 -1
- package/dist/plugins/CompilerPlugin.js +2 -2
- package/dist/plugins/CompilerPlugin.js.map +1 -1
- package/dist/plugins/PluginCommon.d.ts +1 -1
- package/dist/plugins/PluginCommon.js +1 -1
- package/dist/plugins/PluginCommon.js.map +1 -1
- package/dist/plugins/RuntimePlugin.d.ts +1 -1
- package/dist/plugins/RuntimePlugin.js +2 -2
- package/dist/plugins/RuntimePlugin.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -2
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/{poll-DQ6DX_Tt.d.ts → poll-D2QDStsw.d.ts} +4 -14
- package/dist/radio-CJH_N4lq.d.ts +20 -0
- package/dist/{section-Q8nwx_-q.d.ts → section-DrFBT5b-.d.ts} +1 -2
- package/dist/{separator-B8P-kdIK.d.ts → separator-BVm3w6yd.d.ts} +1 -2
- package/dist/{signals-CBXwugBW.d.ts → signals-DRMDrCOn.d.ts} +1 -1
- package/dist/{text-display-CL9C2yMc.d.ts → text-display-BG0nNqy3.d.ts} +1 -2
- package/dist/{types-DZy7U-Ld.d.ts → types-ur7SvktF.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/colors.d.ts +1 -3
- package/dist/utils/colors.js +0 -1
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +19 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/utils/dev-hooks.js +1 -1
- package/dist/utils/error-codes.js +15 -0
- package/dist/utils/error-codes.js.map +1 -1
- package/dist/utils/resolve-file-url.js +2 -2
- package/dist/utils/resolve-file-url.js.map +1 -1
- package/dist/utils/types-package.d.ts +6 -2
- package/dist/utils/types-package.js +31 -38
- package/dist/utils/types-package.js.map +1 -1
- package/dist/utils/useful-stuff/async-queue.js.map +1 -1
- package/dist/utils/useful-stuff/mutex.js.map +1 -1
- package/dist/utils/useful-stuff/ratelimiter.js +4 -1
- package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
- package/dist/utils/useful-stuff/semaphore.js.map +1 -1
- package/dist/utils/utilities.js +1 -1
- package/dist/utils/warning.d.ts +1 -5
- package/dist/utils/warning.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +17 -17
- package/dist/CommandsRouter-DiNoF0dq.d.ts +0 -145
- package/dist/commandkit-Bh7C1_c7.js.map +0 -1
- package/dist/index-BIsCUWAs.d.ts +0 -1
- package/dist/index-CwHYpK-f.d.ts +0 -1
- package/dist/index-DHrsNvX1.d.ts +0 -1
- /package/dist/{chunk-BE-pF4vm.js → rolldown-runtime-C_NdSu1c.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as IdentifyEvent, i as AnalyticsProvider, r as AnalyticsEvent } from "../analytics-engine-
|
|
1
|
+
import { a as IdentifyEvent, i as AnalyticsProvider, r as AnalyticsEvent } from "../analytics-engine-Bz1p7ud3.js";
|
|
2
2
|
export { AnalyticsEvent, AnalyticsProvider, IdentifyEvent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":[
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":[],"mappings":""}
|
package/dist/analytics/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require('../commandkit-
|
|
2
|
+
const require_commandkit = require('../commandkit-DNbfLwyR.js');
|
|
3
3
|
|
|
4
4
|
exports.getDoNotTrack = require_commandkit.getDoNotTrack;
|
|
5
5
|
exports.noAnalytics = require_commandkit.noAnalytics;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { t as EventInterceptor } from "./EventInterceptor-
|
|
2
|
-
import { a as Fragment, c as createElement } from "./element-
|
|
3
|
-
import { t as MaybeArray } from "./types-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { o as
|
|
1
|
+
import { t as EventInterceptor } from "./EventInterceptor-wg378vJp.js";
|
|
2
|
+
import { a as Fragment, c as createElement } from "./element-BMZYAAQ-.js";
|
|
3
|
+
import { t as MaybeArray } from "./types-ur7SvktF.js";
|
|
4
|
+
import "./index-DvqHpiuh.js";
|
|
5
|
+
import { r as MessageCommandParser, t as MessageCommandOptions } from "./MessageCommandParser-BYbxHOSK.js";
|
|
6
|
+
import "./helpers-vlnRvNJv.js";
|
|
7
|
+
import { i as Middleware, n as CommandsRouter, o as RouterFileChangeType, t as Command } from "./CommandsRouter-Co225Ae5.js";
|
|
8
|
+
import { a as ParsedEvent, n as EventsRouterFileChangeType, t as EventsRouter } from "./EventsRouter-Bt63ZuEF.js";
|
|
9
|
+
import "./index-COt7nfC9.js";
|
|
10
|
+
import { o as HMREventChangeType, s as HMREventType } from "./constants-kWgE3L9F.js";
|
|
8
11
|
import EventEmitter from "node:events";
|
|
9
12
|
import { AutocompleteInteraction, Awaitable, CacheType, ChatInputCommandInteraction, Client, ClientEvents, Collection, Constructable, ContextMenuCommandBuilder, ContextMenuCommandInteraction, Guild, Interaction, Locale, Message, MessageContextMenuCommandInteraction, PermissionsString, RESTPostAPIApplicationCommandsJSONBody, SlashCommandBuilder, TextBasedChannel, UserContextMenuCommandInteraction } from "discord.js";
|
|
10
13
|
import { DirectiveTransformerOptions } from "directive-to-hof";
|
|
11
14
|
import { InlineConfig } from "tsdown";
|
|
12
|
-
|
|
13
15
|
//#region src/types.d.ts
|
|
14
|
-
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
16
|
+
type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
|
15
17
|
/**
|
|
16
18
|
* Options for instantiating a CommandKit handler.
|
|
17
19
|
*/
|
|
@@ -352,6 +354,10 @@ declare class MiddlewareContext<T extends CommandExecutionMode = CommandExecutio
|
|
|
352
354
|
}
|
|
353
355
|
//#endregion
|
|
354
356
|
//#region src/app/register/CommandRegistrar.d.ts
|
|
357
|
+
type RegistrationCommandData = CommandData & {
|
|
358
|
+
__metadata?: CommandMetadata;
|
|
359
|
+
__applyId(id: string): void;
|
|
360
|
+
};
|
|
355
361
|
/**
|
|
356
362
|
* Event object passed to plugins before command registration.
|
|
357
363
|
*/
|
|
@@ -375,12 +381,33 @@ declare class CommandRegistrar {
|
|
|
375
381
|
*/
|
|
376
382
|
constructor(commandkit: CommandKit);
|
|
377
383
|
/**
|
|
378
|
-
* Gets the commands data.
|
|
384
|
+
* Gets the commands data, consuming pre-generated context menu entries when available.
|
|
385
|
+
*/
|
|
386
|
+
getCommandsData(): RegistrationCommandData[];
|
|
387
|
+
/**
|
|
388
|
+
* Gets flat command data, consuming pre-generated context menu entries when available.
|
|
389
|
+
*/
|
|
390
|
+
private getFlatCommandsData;
|
|
391
|
+
/**
|
|
392
|
+
* Gets hierarchical chat-input command payloads compiled from cached tree nodes.
|
|
393
|
+
*/
|
|
394
|
+
private getHierarchicalCommandsData;
|
|
395
|
+
/**
|
|
396
|
+
* Removes internal runtime-only fields before Discord registration data is emitted.
|
|
397
|
+
*/
|
|
398
|
+
private sanitizeCommandData;
|
|
399
|
+
/**
|
|
400
|
+
* Builds a top-level Discord payload for a hierarchical command root.
|
|
379
401
|
*/
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
402
|
+
private buildHierarchicalRootPayload;
|
|
403
|
+
/**
|
|
404
|
+
* Builds a nested subcommand or subcommand-group option from a hierarchical node.
|
|
405
|
+
*/
|
|
406
|
+
private buildHierarchicalOption;
|
|
407
|
+
/**
|
|
408
|
+
* Collects normalized guild scopes for all chat-input leaves within a hierarchical subtree.
|
|
409
|
+
*/
|
|
410
|
+
private collectHierarchicalGuildScopes;
|
|
384
411
|
/**
|
|
385
412
|
* Registers loaded commands.
|
|
386
413
|
*/
|
|
@@ -388,17 +415,11 @@ declare class CommandRegistrar {
|
|
|
388
415
|
/**
|
|
389
416
|
* Updates the global commands.
|
|
390
417
|
*/
|
|
391
|
-
updateGlobalCommands(commands:
|
|
392
|
-
__metadata?: CommandMetadata;
|
|
393
|
-
__applyId(id: string): void;
|
|
394
|
-
})[]): Promise<void>;
|
|
418
|
+
updateGlobalCommands(commands: RegistrationCommandData[]): Promise<void>;
|
|
395
419
|
/**
|
|
396
420
|
* Updates the guild commands.
|
|
397
421
|
*/
|
|
398
|
-
updateGuildCommands(commands:
|
|
399
|
-
__metadata?: CommandMetadata;
|
|
400
|
-
__applyId(id: string): void;
|
|
401
|
-
})[]): Promise<void>;
|
|
422
|
+
updateGuildCommands(commands: RegistrationCommandData[]): Promise<void>;
|
|
402
423
|
}
|
|
403
424
|
//#endregion
|
|
404
425
|
//#region src/context/environment.d.ts
|
|
@@ -743,10 +764,20 @@ interface LoadedCommand {
|
|
|
743
764
|
*/
|
|
744
765
|
data: AppCommand;
|
|
745
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Global registry used to infer strongly-typed command identifiers.
|
|
769
|
+
* This namespace is augmented by generated `commandkit/types` declarations.
|
|
770
|
+
*/
|
|
771
|
+
declare global {
|
|
772
|
+
namespace CommandKitTypes {
|
|
773
|
+
interface Registry {}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
type CommandTypeDataRegistryKeys = Exclude<keyof CommandKitTypes.Registry, '__commandkit_wide__'>;
|
|
746
777
|
/**
|
|
747
778
|
* Type representing command data identifier.
|
|
748
779
|
*/
|
|
749
|
-
type CommandTypeData = string
|
|
780
|
+
type CommandTypeData = [CommandTypeDataRegistryKeys] extends [never] ? string : Extract<CommandTypeDataRegistryKeys, string>;
|
|
750
781
|
/**
|
|
751
782
|
* Type for commands that can be resolved by the handler.
|
|
752
783
|
*/
|
|
@@ -809,6 +840,20 @@ declare class AppCommandHandler {
|
|
|
809
840
|
* @internal
|
|
810
841
|
*/
|
|
811
842
|
private loadedCommands;
|
|
843
|
+
/**
|
|
844
|
+
* Executable runtime commands indexed by canonical route key.
|
|
845
|
+
* This includes flat commands and hierarchical executable leaves.
|
|
846
|
+
* @private
|
|
847
|
+
* @internal
|
|
848
|
+
*/
|
|
849
|
+
private runtimeRouteIndex;
|
|
850
|
+
/**
|
|
851
|
+
* Loaded hierarchical command nodes keyed by tree node id.
|
|
852
|
+
* Container nodes are cached here for registration compilation.
|
|
853
|
+
* @private
|
|
854
|
+
* @internal
|
|
855
|
+
*/
|
|
856
|
+
private hierarchicalNodes;
|
|
812
857
|
/**
|
|
813
858
|
* @private
|
|
814
859
|
* @internal
|
|
@@ -850,14 +895,39 @@ declare class AppCommandHandler {
|
|
|
850
895
|
*/
|
|
851
896
|
printBanner(): void;
|
|
852
897
|
/**
|
|
853
|
-
* Gets an array of all loaded commands.
|
|
898
|
+
* Gets an array of all loaded commands, including pre-generated context menu entries.
|
|
854
899
|
* @returns Array of loaded commands
|
|
855
900
|
*/
|
|
856
901
|
getCommandsArray(): LoadedCommand[];
|
|
902
|
+
/**
|
|
903
|
+
* Gets all executable runtime routes, including hierarchical leaves.
|
|
904
|
+
* @returns Array of route-indexed commands
|
|
905
|
+
*/
|
|
906
|
+
getRuntimeCommandsArray(): LoadedCommand[];
|
|
907
|
+
/**
|
|
908
|
+
* Gets loaded hierarchical command nodes, including non-executable containers.
|
|
909
|
+
* @returns Array of hierarchical node definitions
|
|
910
|
+
*/
|
|
911
|
+
getHierarchicalNodesArray(): LoadedCommand[];
|
|
857
912
|
/**
|
|
858
913
|
* Registers event handlers for Discord interactions and messages.
|
|
859
914
|
*/
|
|
860
915
|
registerCommandHandler(): void;
|
|
916
|
+
/**
|
|
917
|
+
* @private
|
|
918
|
+
* @internal
|
|
919
|
+
*/
|
|
920
|
+
private normalizeRouteKey;
|
|
921
|
+
/**
|
|
922
|
+
* @private
|
|
923
|
+
* @internal
|
|
924
|
+
*/
|
|
925
|
+
private buildInteractionRouteKey;
|
|
926
|
+
/**
|
|
927
|
+
* @private
|
|
928
|
+
* @internal
|
|
929
|
+
*/
|
|
930
|
+
private buildMessageRouteKey;
|
|
861
931
|
/**
|
|
862
932
|
* Prepares a command for execution by resolving the command and its middleware.
|
|
863
933
|
* @param source - The interaction or message that triggered the command
|
|
@@ -872,11 +942,23 @@ declare class AppCommandHandler {
|
|
|
872
942
|
* @returns The loaded command or null if not found
|
|
873
943
|
*/
|
|
874
944
|
private findCommandByName;
|
|
945
|
+
/**
|
|
946
|
+
* Finds a command by its canonical route key.
|
|
947
|
+
* @param route - The command route or command name
|
|
948
|
+
* @param allowFlatAliasFallback - Whether to check flat aliases if the route key was not found
|
|
949
|
+
* @returns The loaded command or null if not found
|
|
950
|
+
*/
|
|
951
|
+
private findCommandByRoute;
|
|
952
|
+
/**
|
|
953
|
+
* @private
|
|
954
|
+
* @internal
|
|
955
|
+
*/
|
|
956
|
+
private getRouteKeyFor;
|
|
875
957
|
resolveMessageCommandName(name: string): string;
|
|
876
958
|
/**
|
|
877
959
|
* Reloads all commands and middleware from scratch.
|
|
878
960
|
*/
|
|
879
|
-
reloadCommands(): Promise<void>;
|
|
961
|
+
reloadCommands(path?: string, changeType?: RouterFileChangeType): Promise<void>;
|
|
880
962
|
/**
|
|
881
963
|
* Adds external middleware data to be loaded.
|
|
882
964
|
* @param data - Array of middleware data to add
|
|
@@ -906,11 +988,33 @@ declare class AppCommandHandler {
|
|
|
906
988
|
* @internal
|
|
907
989
|
*/
|
|
908
990
|
private loadMiddleware;
|
|
991
|
+
/**
|
|
992
|
+
* @private
|
|
993
|
+
* @internal
|
|
994
|
+
*/
|
|
995
|
+
private shouldIndexAsRuntimeRoute;
|
|
996
|
+
/**
|
|
997
|
+
* @private
|
|
998
|
+
* @internal
|
|
999
|
+
*/
|
|
1000
|
+
private registerRuntimeRoute;
|
|
1001
|
+
/**
|
|
1002
|
+
* @private
|
|
1003
|
+
* @internal
|
|
1004
|
+
*/
|
|
1005
|
+
private processCommandFile;
|
|
909
1006
|
/**
|
|
910
1007
|
* @private
|
|
911
1008
|
* @internal
|
|
912
1009
|
*/
|
|
913
1010
|
private loadCommand;
|
|
1011
|
+
/**
|
|
1012
|
+
* Loads a hierarchical command node into the hierarchical cache.
|
|
1013
|
+
* Executable leaves are also added to the runtime route index.
|
|
1014
|
+
* @private
|
|
1015
|
+
* @internal
|
|
1016
|
+
*/
|
|
1017
|
+
private loadHierarchicalNode;
|
|
914
1018
|
/**
|
|
915
1019
|
* Gets the metadata for a command.
|
|
916
1020
|
* @param command - The command name to get metadata for
|
|
@@ -918,6 +1022,12 @@ declare class AppCommandHandler {
|
|
|
918
1022
|
* @returns The command metadata or null if not found
|
|
919
1023
|
*/
|
|
920
1024
|
getMetadataFor(command: string, hint?: 'user' | 'message'): CommandMetadata | null;
|
|
1025
|
+
/**
|
|
1026
|
+
* Generates context menu commands for the loaded command.
|
|
1027
|
+
* @private
|
|
1028
|
+
* @internal
|
|
1029
|
+
*/
|
|
1030
|
+
private generateContextMenuCommands;
|
|
921
1031
|
}
|
|
922
1032
|
//#endregion
|
|
923
1033
|
//#region src/events/CommandKitEventsChannel.d.ts
|
|
@@ -1010,6 +1120,7 @@ interface LoadedEvent {
|
|
|
1010
1120
|
event: ParsedEvent;
|
|
1011
1121
|
listeners: EventListener[];
|
|
1012
1122
|
mainListener?: EventListener;
|
|
1123
|
+
onceListener?: EventListener;
|
|
1013
1124
|
executedOnceListeners?: Set<ListenerFunction>;
|
|
1014
1125
|
}
|
|
1015
1126
|
/**
|
|
@@ -1045,11 +1156,16 @@ declare class AppEventsHandler {
|
|
|
1045
1156
|
/**
|
|
1046
1157
|
* Reloads all events by unregistering existing ones and loading them again.
|
|
1047
1158
|
*/
|
|
1048
|
-
reloadEvents(): Promise<void>;
|
|
1159
|
+
reloadEvents(path?: string, changeType?: EventsRouterFileChangeType): Promise<void>;
|
|
1049
1160
|
/**
|
|
1050
1161
|
* Loads all events from the events router and registers them with Discord.js client.
|
|
1051
1162
|
*/
|
|
1052
1163
|
loadEvents(): Promise<void>;
|
|
1164
|
+
/**
|
|
1165
|
+
* @private
|
|
1166
|
+
* @internal
|
|
1167
|
+
*/
|
|
1168
|
+
private loadEventsFromTree;
|
|
1053
1169
|
/**
|
|
1054
1170
|
* Unregisters all event listeners and clears loaded events.
|
|
1055
1171
|
*/
|
|
@@ -1077,6 +1193,10 @@ interface IpcMessageCommand {
|
|
|
1077
1193
|
* The path associated with the HMR event.
|
|
1078
1194
|
*/
|
|
1079
1195
|
path: string;
|
|
1196
|
+
/**
|
|
1197
|
+
* The original filesystem change type that triggered this HMR event.
|
|
1198
|
+
*/
|
|
1199
|
+
changeType?: HMREventChangeType;
|
|
1080
1200
|
/**
|
|
1081
1201
|
* An optional identifier for the HMR event, used for acknowledgment.
|
|
1082
1202
|
*/
|
|
@@ -1094,6 +1214,10 @@ interface CommandKitHMREvent {
|
|
|
1094
1214
|
* The path associated with the HMR event.
|
|
1095
1215
|
*/
|
|
1096
1216
|
path: string;
|
|
1217
|
+
/**
|
|
1218
|
+
* The original filesystem change type that triggered this HMR event.
|
|
1219
|
+
*/
|
|
1220
|
+
changeType?: HMREventChangeType;
|
|
1097
1221
|
/**
|
|
1098
1222
|
* Accepts the HMR event, indicating that it has been handled.
|
|
1099
1223
|
* This prevents further processing of the event.
|
|
@@ -1849,6 +1973,10 @@ declare function flag<Returns = boolean, Entity = Record<any, any>>(options: Fea
|
|
|
1849
1973
|
declare class FlagStore extends Collection<string, FeatureFlag<any, any>> {}
|
|
1850
1974
|
//#endregion
|
|
1851
1975
|
//#region src/config/types.d.ts
|
|
1976
|
+
/**
|
|
1977
|
+
* The JavaScript runtime to use for the development server.
|
|
1978
|
+
*/
|
|
1979
|
+
type CommandKitJsRuntime = 'node' | 'bun' | 'deno' | 'auto';
|
|
1852
1980
|
interface CommandKitCompilerOptions {
|
|
1853
1981
|
/**
|
|
1854
1982
|
* The macro compiler options to use with CommandKit.
|
|
@@ -1965,17 +2093,37 @@ interface CommandKitConfig {
|
|
|
1965
2093
|
* @default true
|
|
1966
2094
|
*/
|
|
1967
2095
|
jsxDefaultOptionalComponents?: boolean;
|
|
2096
|
+
/**
|
|
2097
|
+
* Experimental features configuration. These features are not stable and may be removed or changed without a major version bump. Use with caution.
|
|
2098
|
+
*/
|
|
2099
|
+
experimental?: {
|
|
2100
|
+
/**
|
|
2101
|
+
* The runtime to use for the development server. This is an experimental feature and may be removed or changed without a major version bump. Use with caution.
|
|
2102
|
+
* @default null
|
|
2103
|
+
*/
|
|
2104
|
+
devServerRuntime?: CommandKitJsRuntime | null;
|
|
2105
|
+
/**
|
|
2106
|
+
* Whether to emit and hydrate a pre-generated commands/events artifact in production builds.
|
|
2107
|
+
* @default false
|
|
2108
|
+
*/
|
|
2109
|
+
pregenerateCommands?: boolean;
|
|
2110
|
+
/**
|
|
2111
|
+
* Whether to use incremental router reconciliation in development HMR.
|
|
2112
|
+
* @default false
|
|
2113
|
+
*/
|
|
2114
|
+
incrementalRouter?: boolean;
|
|
2115
|
+
};
|
|
1968
2116
|
}
|
|
1969
2117
|
//#endregion
|
|
1970
2118
|
//#region src/config/utils.d.ts
|
|
1971
2119
|
/**
|
|
1972
2120
|
* @private
|
|
1973
2121
|
*/
|
|
1974
|
-
type DeepRequired<T, OptionalKeys extends keyof T = never> = { [P in keyof T]-?: P extends OptionalKeys ? Partial<T[P]> : DeepRequired<T[P]
|
|
2122
|
+
type DeepRequired<T, OptionalKeys extends keyof T = never> = { [P in keyof T]-?: P extends OptionalKeys ? Partial<T[P]> : DeepRequired<T[P]>; };
|
|
1975
2123
|
/**
|
|
1976
2124
|
* @private
|
|
1977
2125
|
*/
|
|
1978
|
-
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]
|
|
2126
|
+
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; };
|
|
1979
2127
|
/**
|
|
1980
2128
|
* @private
|
|
1981
2129
|
* @example
|
|
@@ -2274,5 +2422,5 @@ declare class AnalyticsEngine {
|
|
|
2274
2422
|
track(event: AnalyticsEvent): Promise<void>;
|
|
2275
2423
|
}
|
|
2276
2424
|
//#endregion
|
|
2277
|
-
export {
|
|
2278
|
-
//# sourceMappingURL=analytics-engine-
|
|
2425
|
+
export { RuntimePlugin as $, InteractionCommandMiddlewareContext as $t, MaybePromise as A, isCommandWorkerContext as At, isPlugin as B, CommandRegistrar as Bt, DecideFunction as C, AppCommandRunner as Ct, FeatureFlagDefinition as D, exitContext as Dt, FeatureFlag as E, GenericFunction as Et, JsonFlagProvider as F, CommandKitEnvironment as Ft, CompilerPlugin as G, AutocompleteCommandMiddlewareContext as Gt, CompilerPluginRuntime as H, AnyCommandExecute as Ht, CommandKitPluginRuntime as I, CommandKitEnvironmentInternalData as It, isCompilerPlugin as J, CommandContextOptions as Jt, PluginTransformParameters as K, ChatInputCommand as Kt, PluginCommon as L, CommandKitEnvironmentType as Lt, setFlagProvider as M, provideContext as Mt, FlagConfiguration as N, useEnvironment as Nt, FlagRunner as O, getCommandKit as Ot, FlagProvider as P, useStore as Pt, TemplateHandler as Q, InteractionCommandContext as Qt, PluginOptions as R, after as Rt, CustomEvaluationFunction as S, RunCommand as St, EventFlagContext as T, AsyncFunction as Tt, CommonDirectiveTransformer as U, AutocompleteCommand as Ut, CommonPluginRuntime as V, PreRegisterCommandsEvent as Vt, CommonDirectiveTransformerOptions as W, AutocompleteCommandContext as Wt, CommandKitPlugin as X, Context as Xt, CommandKitEventDispatch as Y, CommandExecutionMode as Yt, MaybeFalsey as Z, ContextParameters as Zt, CommandKitConfig as _, EventHandler as _n, CommandTypeData as _t, IdentifyEvent as a, MessageContextMenuCommandMiddlewareContext as an, AppEventsHandlerLoadedData as at, CommandFlagContext as b, PreparedAppCommandExecution as bt, CommandKitConfiguration as c, SlashCommandMiddlewareContext as cn, CommandKitEventsChannel as ct, onBootstrap as d, UserContextMenuCommandMiddlewareContext as dn, AppCommandHandler as dt, MessageCommand as en, isRuntimePlugin as et, DeepPartial as f, CommandContext as fn, AppCommandNative as ft, CommandKitCompilerOptions as g, CommandMetadataFunction as gn, CommandDataSchemaValue as gt, mergeDeep as h, CommandMetadata as hn, CommandDataSchemaKey as ht, AnalyticsProvider as i, MessageContextMenuCommandContext as in, AppEventsHandler as it, flag as j, makeContextAwareFunction as jt, IdentifyFunction as k, getContext as kt, commandkit as l, UserContextMenuCommand as ln, ListenerFunction as lt, ResolvedCommandKitConfig as m, CommandKitOptions as mn, CommandDataSchema as mt, FilterFunction as n, MessageCommandMiddlewareContext as nn, IpcMessageCommand as nt, BootstrapFunction as o, MiddlewareContext as on, EventListener as ot, DeepRequired as p, CommandData as pn, CommandBuilderLike as pt, TransformedResult as q, ChatInputCommandContext as qt, AnalyticsEvent as r, MessageContextMenuCommand as rn, registerDevHooks as rt, CommandKit as s, MiddlewareContextArgs as sn, LoadedEvent as st, AnalyticsEngine as t, MessageCommandContext as tn, CommandKitHMREvent as tt, onApplicationBootstrap as u, UserContextMenuCommandContext as un, AppCommand as ut, CommandKitJsRuntime as v, CustomAppCommandProps as vt, EvaluationContext as w, RunCommandOptions as wt, CustomEvaluationContext as x, ResolvableCommand as xt, FlagStore as y, LoadedCommand as yt, PluginType as z, cancelAfter as zt };
|
|
2426
|
+
//# sourceMappingURL=analytics-engine-Bz1p7ud3.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Ct as
|
|
1
|
+
import { Ct as AppCommandRunner, wt as RunCommandOptions } from "../../analytics-engine-Bz1p7ud3.js";
|
|
2
2
|
export { AppCommandRunner, RunCommandOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require('../../commandkit-
|
|
2
|
+
const require_commandkit = require('../../commandkit-DNbfLwyR.js');
|
|
3
3
|
|
|
4
4
|
exports.AppCommandRunner = require_commandkit.AppCommandRunner;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $t as InteractionCommandMiddlewareContext, Gt as AutocompleteCommandMiddlewareContext, Ht as AnyCommandExecute, Jt as CommandContextOptions, Kt as ChatInputCommand, Qt as InteractionCommandContext, Ut as AutocompleteCommand, Wt as AutocompleteCommandContext, Xt as Context, Yt as CommandExecutionMode, Zt as ContextParameters, an as MessageContextMenuCommandMiddlewareContext, cn as SlashCommandMiddlewareContext, dn as UserContextMenuCommandMiddlewareContext, en as MessageCommand, in as MessageContextMenuCommandContext, ln as UserContextMenuCommand, nn as MessageCommandMiddlewareContext, on as MiddlewareContext, qt as ChatInputCommandContext, rn as MessageContextMenuCommand, sn as MiddlewareContextArgs, tn as MessageCommandContext, un as UserContextMenuCommandContext } from "../../analytics-engine-Bz1p7ud3.js";
|
|
2
2
|
export { AnyCommandExecute, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandContextOptions, CommandExecutionMode, Context, ContextParameters, InteractionCommandContext, InteractionCommandMiddlewareContext, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require('../../commandkit-
|
|
2
|
+
const require_commandkit = require('../../commandkit-DNbfLwyR.js');
|
|
3
3
|
|
|
4
4
|
exports.CommandExecutionMode = require_commandkit.CommandExecutionMode;
|
|
5
5
|
exports.Context = require_commandkit.Context;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ParsedMessageCommand, n as MessageCommandOptionsSchema, r as MessageCommandParser, t as MessageCommandOptions } from "../../MessageCommandParser-
|
|
1
|
+
import { i as ParsedMessageCommand, n as MessageCommandOptionsSchema, r as MessageCommandParser, t as MessageCommandOptions } from "../../MessageCommandParser-BYbxHOSK.js";
|
|
2
2
|
export { MessageCommandOptions, MessageCommandOptionsSchema, MessageCommandParser, ParsedMessageCommand };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../../chunk-BE-pF4vm.js');
|
|
3
2
|
const require_utils_error_codes = require('../../utils/error-codes.js');
|
|
4
3
|
let discord_js = require("discord.js");
|
|
5
4
|
|
|
@@ -8,6 +7,9 @@ let discord_js = require("discord.js");
|
|
|
8
7
|
* Parses message content into structured command data with options and subcommands.
|
|
9
8
|
*/
|
|
10
9
|
var MessageCommandParser = class {
|
|
10
|
+
message;
|
|
11
|
+
prefix;
|
|
12
|
+
schema;
|
|
11
13
|
/**
|
|
12
14
|
* @private
|
|
13
15
|
* @internal
|
|
@@ -66,6 +68,13 @@ var MessageCommandParser = class {
|
|
|
66
68
|
return this.parse().command;
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
71
|
+
* Gets the full command route as an array of segments.
|
|
72
|
+
* @returns Array of command segments
|
|
73
|
+
*/
|
|
74
|
+
getFullRoute() {
|
|
75
|
+
return this.parse().fullRoute;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
69
78
|
* Gets the subcommand name if present.
|
|
70
79
|
* @returns The subcommand name or undefined
|
|
71
80
|
*/
|
|
@@ -95,11 +104,7 @@ var MessageCommandParser = class {
|
|
|
95
104
|
* @returns The complete command string
|
|
96
105
|
*/
|
|
97
106
|
getFullCommand() {
|
|
98
|
-
return
|
|
99
|
-
this.getCommand(),
|
|
100
|
-
this.getSubcommandGroup(),
|
|
101
|
-
this.getSubcommand()
|
|
102
|
-
].filter((v) => v).join(" ");
|
|
107
|
+
return this.getFullRoute().join(" ");
|
|
103
108
|
}
|
|
104
109
|
/**
|
|
105
110
|
* Parses the message content into structured command data.
|
|
@@ -110,79 +115,81 @@ var MessageCommandParser = class {
|
|
|
110
115
|
const content = this.message.content;
|
|
111
116
|
const prefix = this.getPrefix();
|
|
112
117
|
if (!prefix) throw require_utils_error_codes.createCommandKitError(require_utils_error_codes.CommandKitErrorCodes.InvalidCommandPrefix);
|
|
113
|
-
const
|
|
114
|
-
|
|
118
|
+
const body = content.slice(prefix.length).trim();
|
|
119
|
+
if (!body) throw require_utils_error_codes.createCommandKitError(require_utils_error_codes.CommandKitErrorCodes.InvalidCommandPrefix);
|
|
120
|
+
const parts = body.split(" ");
|
|
121
|
+
const commandToken = parts.shift();
|
|
115
122
|
this.#args = parts;
|
|
123
|
+
let command = "";
|
|
116
124
|
let subcommandGroup;
|
|
117
125
|
let subcommand;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
const fullRoute = (commandToken === null || commandToken === void 0 ? void 0 : commandToken.split(":")) ?? [];
|
|
127
|
+
if (fullRoute.length) {
|
|
128
|
+
command = fullRoute[0];
|
|
129
|
+
if (fullRoute.length === 2) subcommand = fullRoute[1];
|
|
130
|
+
else if (fullRoute.length >= 3) {
|
|
131
|
+
subcommandGroup = fullRoute[1];
|
|
132
|
+
subcommand = fullRoute[fullRoute.length - 1];
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
|
-
const schema = this.schema(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
const schema = this.schema(fullRoute.join(" ").trim());
|
|
136
|
+
const options = parts.map((part) => {
|
|
137
|
+
try {
|
|
138
|
+
const [name, value] = part.split(":");
|
|
139
|
+
if (!(name in schema)) return null;
|
|
140
|
+
switch (schema[name]) {
|
|
141
|
+
case discord_js.ApplicationCommandOptionType.Boolean: return {
|
|
142
|
+
name,
|
|
143
|
+
value: value === "true"
|
|
144
|
+
};
|
|
145
|
+
case discord_js.ApplicationCommandOptionType.Integer: return {
|
|
146
|
+
name,
|
|
147
|
+
value: parseInt(value, 10)
|
|
148
|
+
};
|
|
149
|
+
case discord_js.ApplicationCommandOptionType.Number: return {
|
|
150
|
+
name,
|
|
151
|
+
value: parseFloat(value)
|
|
152
|
+
};
|
|
153
|
+
case discord_js.ApplicationCommandOptionType.String: return {
|
|
154
|
+
name,
|
|
155
|
+
value
|
|
156
|
+
};
|
|
157
|
+
case discord_js.ApplicationCommandOptionType.User: return {
|
|
158
|
+
name,
|
|
159
|
+
value: this.message.mentions.users.find((u) => {
|
|
160
|
+
return u.id === value.replace(/[<@!>]/g, "");
|
|
161
|
+
})
|
|
162
|
+
};
|
|
163
|
+
case discord_js.ApplicationCommandOptionType.Channel: return {
|
|
164
|
+
name,
|
|
165
|
+
value: this.message.mentions.channels.find((c) => {
|
|
166
|
+
return c.id === value.replace(/[<#>]/g, "");
|
|
167
|
+
})
|
|
168
|
+
};
|
|
169
|
+
case discord_js.ApplicationCommandOptionType.Role: return {
|
|
170
|
+
name,
|
|
171
|
+
value: this.message.mentions.roles.find((r) => {
|
|
172
|
+
return r.id === value.replace(/[<@&>]/g, "");
|
|
173
|
+
})
|
|
174
|
+
};
|
|
175
|
+
case discord_js.ApplicationCommandOptionType.Attachment: return {
|
|
176
|
+
name,
|
|
177
|
+
value: this.message.attachments.find((a) => {
|
|
178
|
+
return a.name === value;
|
|
179
|
+
})
|
|
180
|
+
};
|
|
181
|
+
default: return null;
|
|
182
|
+
}
|
|
183
|
+
} catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}).filter((v) => v !== null);
|
|
131
187
|
this.#parsed = {
|
|
132
188
|
command,
|
|
133
|
-
options
|
|
134
|
-
try {
|
|
135
|
-
const [name, value] = part.split(":");
|
|
136
|
-
if (!(name in schema)) return null;
|
|
137
|
-
switch (schema[name]) {
|
|
138
|
-
case discord_js.ApplicationCommandOptionType.Boolean: return {
|
|
139
|
-
name,
|
|
140
|
-
value: value === "true"
|
|
141
|
-
};
|
|
142
|
-
case discord_js.ApplicationCommandOptionType.Integer: return {
|
|
143
|
-
name,
|
|
144
|
-
value: parseInt(value, 10)
|
|
145
|
-
};
|
|
146
|
-
case discord_js.ApplicationCommandOptionType.Number: return {
|
|
147
|
-
name,
|
|
148
|
-
value: parseFloat(value)
|
|
149
|
-
};
|
|
150
|
-
case discord_js.ApplicationCommandOptionType.String: return {
|
|
151
|
-
name,
|
|
152
|
-
value
|
|
153
|
-
};
|
|
154
|
-
case discord_js.ApplicationCommandOptionType.User: return {
|
|
155
|
-
name,
|
|
156
|
-
value: this.message.mentions.users.find((u) => {
|
|
157
|
-
return u.id === value.replace(/[<@!>]/g, "");
|
|
158
|
-
})
|
|
159
|
-
};
|
|
160
|
-
case discord_js.ApplicationCommandOptionType.Channel: return {
|
|
161
|
-
name,
|
|
162
|
-
value: this.message.mentions.channels.find((c) => {
|
|
163
|
-
return c.id === value.replace(/[<#>]/g, "");
|
|
164
|
-
})
|
|
165
|
-
};
|
|
166
|
-
case discord_js.ApplicationCommandOptionType.Role: return {
|
|
167
|
-
name,
|
|
168
|
-
value: this.message.mentions.roles.find((r) => {
|
|
169
|
-
return r.id === value.replace(/[<@&>]/g, "");
|
|
170
|
-
})
|
|
171
|
-
};
|
|
172
|
-
case discord_js.ApplicationCommandOptionType.Attachment: return {
|
|
173
|
-
name,
|
|
174
|
-
value: this.message.attachments.find((a) => {
|
|
175
|
-
return a.name === value;
|
|
176
|
-
})
|
|
177
|
-
};
|
|
178
|
-
default: return null;
|
|
179
|
-
}
|
|
180
|
-
} catch {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
}).filter((v) => v !== null),
|
|
189
|
+
options,
|
|
184
190
|
subcommand,
|
|
185
|
-
subcommandGroup
|
|
191
|
+
subcommandGroup,
|
|
192
|
+
fullRoute
|
|
186
193
|
};
|
|
187
194
|
return this.#parsed;
|
|
188
195
|
}
|
|
@@ -191,6 +198,7 @@ var MessageCommandParser = class {
|
|
|
191
198
|
* Provides typed access to message command options with methods similar to Discord.js interaction options.
|
|
192
199
|
*/
|
|
193
200
|
var MessageCommandOptions = class {
|
|
201
|
+
parser;
|
|
194
202
|
/**
|
|
195
203
|
* Creates a new message command options instance.
|
|
196
204
|
* @param parser - The message command parser instance
|