commandkit 1.2.0-rc.13 → 1.2.0-rc.15
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 +42 -23
- package/dist/{ActionRow-B-CGmjDp.d.ts → ActionRow-Bt9qi0Mb.d.ts} +2 -2
- package/dist/{Button-C-GPeFA3.d.ts → Button-DxJLcZIU.d.ts} +5 -5
- package/dist/{ButtonKit-DKu0VAe4.d.ts → ButtonKit-BfcyvWfj.d.ts} +35 -35
- package/dist/{ChannelSelectMenuKit-HQZ4hH5s.d.ts → ChannelSelectMenuKit-DYkudikb.d.ts} +33 -33
- package/dist/{CommandsRouter-C7dZEepB.d.ts → CommandsRouter-DiNoF0dq.d.ts} +48 -48
- package/dist/{EventInterceptor-CZmWpS08.d.ts → EventInterceptor-D9JKMcfi.d.ts} +39 -39
- package/dist/{EventsRouter-DZ37r54v.d.ts → EventsRouter-EuuSu6NH.d.ts} +34 -34
- package/dist/{MentionableSelectMenuKit-7URDUM3-.d.ts → MentionableSelectMenuKit-Mu4xqP6B.d.ts} +33 -33
- package/dist/MessageCommandParser-DPCbHXCS.d.ts +194 -0
- package/dist/{Modal-CZT9MZsy.d.ts → Modal-v9rrcMl-.d.ts} +7 -7
- package/dist/{ModalKit-BWXI3Z26.d.ts → ModalKit-XJSM65SV.d.ts} +32 -32
- package/dist/{RoleSelectMenuKit-BY-JJ18w.d.ts → RoleSelectMenuKit-CCjcp3HY.d.ts} +33 -33
- package/dist/{SelectMenu-q_b3Mjv9.d.ts → SelectMenu-CY0vvoSu.d.ts} +15 -11
- package/dist/{StringSelectMenuKit-lVhUMc3g.d.ts → StringSelectMenuKit-G5nBTicX.d.ts} +33 -33
- package/dist/{UserSelectMenuKit-CCj4Fpkr.d.ts → UserSelectMenuKit-D3SO_fXA.d.ts} +33 -33
- package/dist/analytics/analytics-engine.d.ts +1 -1
- package/dist/analytics/analytics-engine.js +2 -24
- package/dist/analytics/analytics-provider.d.ts +1 -1
- package/dist/analytics/analytics-provider.js +1 -0
- package/dist/analytics/constants.js +26 -3
- package/dist/analytics/constants.js.map +1 -0
- package/dist/analytics/utils.js +2 -24
- package/dist/{analytics-engine-WQhXmx3H.d.ts → analytics-engine-DnRsHBId.d.ts} +846 -841
- package/dist/app/commands/AppCommandRunner.d.ts +1 -1
- package/dist/app/commands/AppCommandRunner.js +2 -24
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/commands/Context.js +2 -24
- package/dist/app/commands/MessageCommandParser.d.ts +1 -1
- package/dist/app/commands/MessageCommandParser.js +261 -3
- package/dist/app/commands/MessageCommandParser.js.map +1 -0
- package/dist/app/commands/helpers.d.ts +1 -1
- package/dist/app/commands/helpers.js +25 -3
- package/dist/app/commands/helpers.js.map +1 -0
- package/dist/app/events/EventWorkerContext.d.ts +2 -2
- package/dist/app/events/EventWorkerContext.js +48 -5
- package/dist/app/events/EventWorkerContext.js.map +1 -0
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
- package/dist/app/handlers/AppCommandHandler.js +2 -24
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.js +2 -24
- package/dist/app/index.d.ts +4 -4
- package/dist/app/index.js +13 -32
- package/dist/app/interrupt/signals.d.ts +1 -1
- package/dist/app/interrupt/signals.js +54 -6
- package/dist/app/interrupt/signals.js.map +1 -0
- package/dist/app/middlewares/permissions.d.ts +1 -1
- package/dist/app/middlewares/permissions.js +2 -24
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.js +2 -24
- package/dist/app/router/CommandsRouter.d.ts +1 -1
- package/dist/app/router/CommandsRouter.js +210 -2
- package/dist/app/router/CommandsRouter.js.map +1 -0
- package/dist/app/router/EventsRouter.d.ts +1 -1
- package/dist/app/router/EventsRouter.js +128 -2
- package/dist/app/router/EventsRouter.js.map +1 -0
- package/dist/app/router/index.d.ts +2 -2
- package/dist/app/router/index.js +5 -5
- package/dist/{chunk-kSYXY2_d.js → chunk-BE-pF4vm.js} +1 -1
- package/dist/cli/app-process.d.ts +2 -2
- package/dist/cli/app-process.js +6 -8
- package/dist/cli/app-process.js.map +1 -1
- package/dist/cli/build.d.ts +2 -2
- package/dist/cli/build.js +15 -35
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/common.d.ts +5 -5
- package/dist/cli/common.js +182 -12
- package/dist/cli/common.js.map +1 -0
- package/dist/cli/development.d.ts +3 -3
- package/dist/cli/development.js +38 -59
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js +73 -9
- package/dist/cli/env.js.map +1 -0
- package/dist/cli/generators.js +10 -10
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js +8 -7
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +2 -2
- package/dist/cli/init.js +14 -33
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/production.d.ts +2 -2
- package/dist/cli/production.js +11 -33
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +83 -6
- package/dist/cli/type-checker.js.map +1 -0
- package/dist/cli/utils.js +1 -0
- package/dist/cli/utils.js.map +1 -1
- package/dist/{commandkit-SIjTLD2R.js → commandkit--k6yDJEr.js} +3157 -2699
- package/dist/commandkit--k6yDJEr.js.map +1 -0
- package/dist/commandkit.d.ts +1 -1
- package/dist/commandkit.js +2 -24
- package/dist/{common-DnwCYit8.d.ts → common-CCvvgnxi.d.ts} +2 -2
- package/dist/components/common/EventInterceptor.d.ts +1 -1
- package/dist/components/common/EventInterceptor.js +137 -2
- package/dist/components/common/EventInterceptor.js.map +1 -0
- package/dist/components/common/element.d.ts +2 -2
- package/dist/components/common/element.js +10 -8
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/common/types.js +1 -0
- package/dist/components/display/common.js +3 -2
- package/dist/components/display/container.d.ts +1 -1
- package/dist/components/display/container.js +3 -2
- package/dist/components/display/file.d.ts +1 -1
- package/dist/components/display/file.js +23 -2
- package/dist/components/display/file.js.map +1 -0
- package/dist/components/display/index.d.ts +8 -8
- package/dist/components/display/index.js +18 -21
- package/dist/components/display/label.d.ts +1 -1
- package/dist/components/display/label.js +3 -2
- package/dist/components/display/media-gallery.d.ts +1 -1
- package/dist/components/display/media-gallery.js +4 -3
- package/dist/components/display/poll.d.ts +1 -1
- package/dist/components/display/poll.js +85 -4
- package/dist/{poll-CFe8yvoJ.js.map → components/display/poll.js.map} +1 -1
- package/dist/components/display/section.d.ts +1 -1
- package/dist/components/display/section.js +4 -3
- package/dist/components/display/separator.d.ts +1 -1
- package/dist/components/display/separator.js +21 -2
- package/dist/components/display/separator.js.map +1 -0
- package/dist/components/display/text-display.d.ts +1 -1
- package/dist/components/display/text-display.js +26 -2
- package/dist/components/display/text-display.js.map +1 -0
- package/dist/components/index.d.ts +23 -23
- package/dist/components/index.js +28 -45
- package/dist/components/interactive/action-row/ActionRow.d.ts +1 -1
- package/dist/components/interactive/action-row/ActionRow.js +20 -2
- package/dist/{ActionRow-CSN_UKmM.js.map → 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 +2 -24
- package/dist/components/interactive/button/ButtonKit.d.ts +1 -1
- package/dist/components/interactive/button/ButtonKit.js +2 -24
- package/dist/components/interactive/modal/Modal.d.ts +1 -1
- package/dist/components/interactive/modal/Modal.js +2 -24
- package/dist/components/interactive/modal/ModalKit.d.ts +1 -1
- package/dist/components/interactive/modal/ModalKit.js +2 -24
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +2 -24
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +2 -24
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +2 -24
- package/dist/components/interactive/select-menu/SelectMenu.d.ts +1 -1
- package/dist/components/interactive/select-menu/SelectMenu.js +2 -24
- package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +2 -24
- package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +2 -24
- package/dist/components/interactive/select-menu/common.d.ts +1 -1
- package/dist/components/interactive/select-menu/common.js +1 -0
- package/dist/config/config.d.ts +1 -1
- package/dist/config/config.js +2 -24
- package/dist/config/default.d.ts +1 -1
- package/dist/config/default.js +2 -24
- package/dist/config/loader.d.ts +1 -1
- package/dist/config/loader.js +2 -24
- package/dist/config/types.d.ts +1 -1
- package/dist/config/types.js +1 -0
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/utils.js +29 -2
- package/dist/config/utils.js.map +1 -0
- package/dist/{constants-EpKcj0dH.d.ts → constants-DqtJY0t-.d.ts} +2 -2
- package/dist/{constants-CuYW0K10.d.ts → constants-DwxpkIeH.d.ts} +7 -7
- package/dist/{container-DYcb7zGw.d.ts → container-CYojOA9d.d.ts} +1 -1
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/async-context.js +2 -24
- package/dist/context/environment.d.ts +1 -1
- package/dist/context/environment.js +2 -24
- package/dist/{element-wQo0heGj.d.ts → element-DeLvTMfZ.d.ts} +5 -4
- package/dist/events/CommandKitEventsChannel.d.ts +1 -1
- package/dist/events/CommandKitEventsChannel.js +83 -2
- package/dist/events/CommandKitEventsChannel.js.map +1 -0
- package/dist/{file-CrV4lSnl.d.ts → file-DLO1zEcH.d.ts} +1 -1
- 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 +5 -165
- package/dist/flags/store.d.ts +1 -1
- package/dist/flags/store.js +13 -2
- package/dist/flags/store.js.map +1 -0
- package/dist/{helpers-AQPLVY35.d.ts → helpers-zmC44Mcu.d.ts} +1 -1
- package/dist/index.d.ts +31 -31
- package/dist/index.js +78 -97
- package/dist/kv/constants.d.ts +1 -1
- package/dist/kv/constants.js +22 -2
- package/dist/kv/constants.js.map +1 -0
- package/dist/kv/dotprops.js +1 -0
- package/dist/kv/dotprops.js.map +1 -1
- package/dist/kv/kv.d.ts +288 -288
- package/dist/kv/kv.js +2 -1
- package/dist/kv/kv.js.map +1 -1
- package/dist/kv/serde.d.ts +1 -1
- package/dist/kv/serde.js +29 -28
- package/dist/kv/serde.js.map +1 -1
- package/dist/{label-37kaNWMH.d.ts → label-DqGRqodo.d.ts} +3 -3
- package/dist/logger/DefaultLogger.d.ts +19 -19
- package/dist/logger/DefaultLogger.js +2 -24
- package/dist/logger/ILogger.d.ts +35 -35
- package/dist/logger/ILogger.js +1 -0
- package/dist/logger/Logger.d.ts +5 -5
- package/dist/logger/Logger.js +2 -24
- package/dist/logger/NoopLogger.d.ts +35 -35
- package/dist/logger/NoopLogger.js +1 -0
- package/dist/logger/NoopLogger.js.map +1 -1
- package/dist/{media-gallery-Ci3I4ElH.d.ts → media-gallery-Ca8es-eB.d.ts} +1 -1
- package/dist/plugins/CompilerPlugin.d.ts +1 -1
- package/dist/plugins/CompilerPlugin.js +33 -3
- package/dist/plugins/CompilerPlugin.js.map +1 -0
- package/dist/plugins/PluginCommon.d.ts +1 -1
- package/dist/plugins/PluginCommon.js +55 -4
- package/dist/plugins/PluginCommon.js.map +1 -0
- package/dist/plugins/RuntimePlugin.d.ts +1 -1
- package/dist/plugins/RuntimePlugin.js +124 -3
- package/dist/plugins/RuntimePlugin.js.map +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +8 -30
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +2 -24
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +2 -24
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +2 -24
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -24
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/runtime.js +1 -0
- package/dist/plugins/types.d.ts +1 -1
- package/dist/plugins/types.js +1 -0
- package/dist/{poll-Ddtapd6n.d.ts → poll-DQ6DX_Tt.d.ts} +8 -8
- package/dist/{section-DkUKULnB.d.ts → section-Q8nwx_-q.d.ts} +1 -1
- package/dist/{separator-CbXsIFCa.d.ts → separator-B8P-kdIK.d.ts} +1 -1
- package/dist/{signals-BbTgTc0i.d.ts → signals-CBXwugBW.d.ts} +1 -1
- package/dist/{text-display-D7j39VC-.d.ts → text-display-CL9C2yMc.d.ts} +1 -1
- package/dist/{types-BywA9d2Z.d.ts → types-DZy7U-Ld.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -0
- package/dist/utils/colors.js +9 -3
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +50 -8
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/utils/dev-hooks.js +2 -24
- package/dist/utils/error-codes.d.ts +10 -10
- package/dist/utils/error-codes.js +53 -5
- package/dist/utils/error-codes.js.map +1 -0
- package/dist/utils/resolve-file-url.js +18 -2
- package/dist/utils/resolve-file-url.js.map +1 -0
- package/dist/utils/types-package.js +61 -4
- package/dist/utils/types-package.js.map +1 -0
- package/dist/utils/useful-stuff/async-queue.d.ts +21 -21
- package/dist/utils/useful-stuff/async-queue.js +1 -0
- package/dist/utils/useful-stuff/async-queue.js.map +1 -1
- package/dist/utils/useful-stuff/mutex.d.ts +62 -62
- package/dist/utils/useful-stuff/mutex.js +1 -0
- package/dist/utils/useful-stuff/mutex.js.map +1 -1
- package/dist/utils/useful-stuff/ratelimiter.d.ts +56 -56
- package/dist/utils/useful-stuff/ratelimiter.js +1 -0
- package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
- package/dist/utils/useful-stuff/semaphore.d.ts +82 -82
- package/dist/utils/useful-stuff/semaphore.js +1 -0
- package/dist/utils/useful-stuff/semaphore.js.map +1 -1
- package/dist/utils/utilities.d.ts +5 -5
- package/dist/utils/utilities.js +2 -24
- package/dist/utils/warning.js +38 -4
- package/dist/utils/warning.js.map +1 -0
- package/dist/version.js +2 -1
- package/dist/version.js.map +1 -1
- package/package.json +12 -15
- package/dist/ActionRow-CSN_UKmM.js +0 -25
- package/dist/CommandKitEventsChannel-CnT5ymYe.js +0 -88
- package/dist/CommandKitEventsChannel-CnT5ymYe.js.map +0 -1
- package/dist/CommandsRouter-C_HLsrGX.js +0 -215
- package/dist/CommandsRouter-C_HLsrGX.js.map +0 -1
- package/dist/CompilerPlugin-CUsGAfgl.js +0 -43
- package/dist/CompilerPlugin-CUsGAfgl.js.map +0 -1
- package/dist/EventInterceptor-BWoEJMHZ.js +0 -142
- package/dist/EventInterceptor-BWoEJMHZ.js.map +0 -1
- package/dist/EventWorkerContext-Dfhgv329.js +0 -68
- package/dist/EventWorkerContext-Dfhgv329.js.map +0 -1
- package/dist/EventsRouter-DZYIha6m.js +0 -133
- package/dist/EventsRouter-DZYIha6m.js.map +0 -1
- package/dist/MessageCommandParser-Bs9fimmd.js +0 -271
- package/dist/MessageCommandParser-Bs9fimmd.js.map +0 -1
- package/dist/MessageCommandParser-q3dQcE5N.d.ts +0 -194
- package/dist/PluginCommon-BLxWww5u.js +0 -70
- package/dist/PluginCommon-BLxWww5u.js.map +0 -1
- package/dist/RuntimePlugin-CtobluSU.js +0 -134
- package/dist/RuntimePlugin-CtobluSU.js.map +0 -1
- package/dist/colors-Csc0X4QJ.js +0 -14
- package/dist/colors-Csc0X4QJ.js.map +0 -1
- package/dist/commandkit-SIjTLD2R.js.map +0 -1
- package/dist/common-C2jAjX4U.js +0 -0
- package/dist/common-CEordwf3.js +0 -17
- package/dist/common-CEordwf3.js.map +0 -1
- package/dist/common-DSRs_mfw.js +0 -222
- package/dist/common-DSRs_mfw.js.map +0 -1
- package/dist/constants-BFFK-hfP.js +0 -27
- package/dist/constants-BFFK-hfP.js.map +0 -1
- package/dist/constants-Cw8VjCVz.js +0 -36
- package/dist/constants-Cw8VjCVz.js.map +0 -1
- package/dist/constants-CxkFFZ7p.js +0 -85
- package/dist/constants-CxkFFZ7p.js.map +0 -1
- package/dist/container-DCPljKVH.js +0 -43
- package/dist/container-DCPljKVH.js.map +0 -1
- package/dist/display-WDb9wMCv.js +0 -0
- package/dist/element-DibzzA5L.js +0 -84
- package/dist/element-DibzzA5L.js.map +0 -1
- package/dist/env-CmspDhHy.js +0 -113
- package/dist/env-CmspDhHy.js.map +0 -1
- package/dist/error-codes-Ds0bnPvT.js +0 -73
- package/dist/error-codes-Ds0bnPvT.js.map +0 -1
- package/dist/file-Ca1kpEtE.js +0 -28
- package/dist/file-Ca1kpEtE.js.map +0 -1
- package/dist/flags/feature-flags.js.map +0 -1
- package/dist/helpers-Btx1FSZx.js +0 -35
- package/dist/helpers-Btx1FSZx.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/label-B6vXvwLM.js +0 -35
- package/dist/label-B6vXvwLM.js.map +0 -1
- package/dist/media-gallery-u3gjX7yD.js +0 -61
- package/dist/media-gallery-u3gjX7yD.js.map +0 -1
- package/dist/poll-CFe8yvoJ.js +0 -100
- package/dist/resolve-file-url-CdHqwWs3.js +0 -23
- package/dist/resolve-file-url-CdHqwWs3.js.map +0 -1
- package/dist/router-BvamdzoF.js +0 -0
- package/dist/runtime-Skt5NiOc.js +0 -0
- package/dist/section-BC8LF-B2.js +0 -59
- package/dist/section-BC8LF-B2.js.map +0 -1
- package/dist/separator-BUTiW7uz.js +0 -26
- package/dist/separator-BUTiW7uz.js.map +0 -1
- package/dist/signals-B8z1wJ6W.js +0 -74
- package/dist/signals-B8z1wJ6W.js.map +0 -1
- package/dist/store-D8r_hryO.js +0 -18
- package/dist/store-D8r_hryO.js.map +0 -1
- package/dist/text-display-DANahMN3.js +0 -31
- package/dist/text-display-DANahMN3.js.map +0 -1
- package/dist/type-checker-cVd3Hpnh.js +0 -88
- package/dist/type-checker-cVd3Hpnh.js.map +0 -1
- package/dist/types-Cdh4uaFR.js +0 -0
- package/dist/types-TC4g3w91.js +0 -0
- package/dist/types-package-CsTNfvv2.js +0 -71
- package/dist/types-package-CsTNfvv2.js.map +0 -1
- package/dist/utils-Br3eenD1.js +0 -34
- package/dist/utils-Br3eenD1.js.map +0 -1
- package/dist/warning-CszH8HeS.js +0 -53
- package/dist/warning-CszH8HeS.js.map +0 -1
- /package/dist/{index-BJfko-dP.d.ts → index-BIsCUWAs.d.ts} +0 -0
- /package/dist/{index-CCggO_hw.d.ts → index-CwHYpK-f.d.ts} +0 -0
- /package/dist/{index-CLjpoGi1.d.ts → index-DHrsNvX1.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventsRouter-DZYIha6m.js","names":[],"sources":["../src/app/router/EventsRouter.ts"],"sourcesContent":["import { Collection } from 'discord.js';\nimport { existsSync } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Configuration options for the EventsRouter\n * @interface EventsRouterOptions\n */\nexport interface EventsRouterOptions {\n /** Root directory path where event handlers are located */\n entrypoints: string[];\n}\n\n/**\n * Represents a parsed event with its handlers\n * @interface ParsedEvent\n */\nexport interface ParsedEvent {\n /** Name of the event derived from directory name */\n event: string;\n /** Absolute path to the event directory */\n path: string;\n /** Array of file paths to event listener handlers */\n listeners: string[];\n /** Namespace of the event */\n namespace: string | null;\n}\n\n/** Collection of event names to their parsed metadata */\nexport type EventsTree = Record<string, ParsedEvent>;\n\n/**\n * Router for discovering and managing event handler files in a directory structure.\n * Events are represented by directories, and handlers are files within those directories.\n */\nexport class EventsRouter {\n /** Internal storage of parsed events */\n private events = new Collection<string, ParsedEvent>();\n\n /**\n * Creates a new EventsRouter instance\n * @param options - Configuration options for the router\n * @throws Error if entrypoint is not provided\n */\n public constructor(private options: EventsRouterOptions) {\n if (options.entrypoints) {\n options.entrypoints = Array.from(new Set(options.entrypoints));\n }\n\n if (!options.entrypoints?.length) {\n throw new Error('Entrypoint directory must be provided');\n }\n }\n\n /**\n * Adds new entrypoints to the router\n * @param entrypoints - Array of new entrypoint paths\n */\n public addEntrypoints(entrypoints: string[]) {\n this.options.entrypoints = Array.from(\n new Set([...this.options.entrypoints, ...entrypoints]),\n );\n }\n\n /**\n * Find a parsed event by its name\n * @param event - Name of the event to find\n * @returns Parsed event metadata or null if not found\n */\n public match(event: string): ParsedEvent | null {\n return this.events.get(event) ?? null;\n }\n\n /**\n * Get the entrypoint directory path\n * @returns Entrypoint directory path\n */\n public get entrypoints(): string[] {\n return this.options.entrypoints;\n }\n\n /**\n * Checks if the entrypoint path is valid\n */\n public isValidPath() {\n return this.entrypoints.every((entrypoint) => existsSync(entrypoint));\n }\n\n /**\n * Clear all parsed events\n */\n public clear() {\n this.events.clear();\n }\n\n /**\n * Reload and re-scan the entrypoint directory for events\n * @returns Promise resolving to the updated events tree\n */\n public async reload() {\n this.clear();\n return this.scan();\n }\n\n /**\n * Scan the entrypoint directory for events and their handlers\n * @returns Promise resolving to the events tree\n */\n public async scan(): Promise<EventsTree> {\n for (const entrypoint of this.entrypoints) {\n const dirs = await readdir(entrypoint, { withFileTypes: true });\n\n for (const dir of dirs) {\n if (dir.isDirectory()) {\n const path = join(entrypoint, dir.name);\n await this.scanEvent(dir.name, path, null, [], true);\n }\n }\n }\n\n return Object.fromEntries(this.events);\n }\n\n /**\n * Convert the internal events Collection to a plain object\n * @returns Events tree as a plain object\n */\n public toJSON(): EventsTree {\n return Object.fromEntries(this.events);\n }\n\n /**\n * Recursively scan a directory for event handlers\n * @param event - Name of the event\n * @param path - Path to the event directory\n * @param listeners - Array to collect listener file paths\n * @returns Promise resolving to the parsed event metadata\n */\n private async scanEvent(\n event: string,\n path: string,\n _namespace: string | null = null,\n listeners: string[] = [],\n isRoot = false,\n ): Promise<void> {\n const files = await readdir(path, { withFileTypes: true });\n const isNamespace = isRoot && /^\\(.+\\)$/.test(event);\n\n // if event = (something) pattern then namespace is something\n const namespace = isNamespace ? event.slice(1, -1) : (_namespace ?? null);\n\n files.sort((a, b) => a.name.localeCompare(b.name));\n\n for (const file of files) {\n if (file.name.startsWith('_')) continue;\n\n if (file.isDirectory()) {\n const nextPath = join(path, file.name);\n await this.scanEvent(file.name, nextPath, namespace, listeners);\n continue;\n }\n\n if (file.isFile() && /\\.(m|c)?(j|t)sx?$/.test(file.name)) {\n listeners.push(join(file.parentPath, file.name));\n }\n }\n\n if (!isNamespace) {\n const existing = this.events.get(event);\n\n if (existing) {\n existing.listeners = Array.from(\n new Set([...existing.listeners, ...listeners]),\n );\n\n return;\n }\n\n this.events.set(event, { event, path, listeners, namespace });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAoCA,IAAa,eAAb,MAA0B;;CAExB,AAAQ,SAAS,IAAI,uBAAiC;;;;;;CAOtD,AAAO,YAAY,AAAQ,SAA8B;;EAA9B;AACzB,MAAI,QAAQ,YACV,SAAQ,cAAc,MAAM,KAAK,IAAI,IAAI,QAAQ,YAAY,CAAC;AAGhE,MAAI,0BAAC,QAAQ,yFAAa,QACxB,OAAM,IAAI,MAAM,wCAAwC;;;;;;CAQ5D,AAAO,eAAe,aAAuB;AAC3C,OAAK,QAAQ,cAAc,MAAM,KAC/B,IAAI,IAAI,CAAC,GAAG,KAAK,QAAQ,aAAa,GAAG,YAAY,CAAC,CACvD;;;;;;;CAQH,AAAO,MAAM,OAAmC;AAC9C,SAAO,KAAK,OAAO,IAAI,MAAM,IAAI;;;;;;CAOnC,IAAW,cAAwB;AACjC,SAAO,KAAK,QAAQ;;;;;CAMtB,AAAO,cAAc;AACnB,SAAO,KAAK,YAAY,OAAO,uCAA0B,WAAW,CAAC;;;;;CAMvE,AAAO,QAAQ;AACb,OAAK,OAAO,OAAO;;;;;;CAOrB,MAAa,SAAS;AACpB,OAAK,OAAO;AACZ,SAAO,KAAK,MAAM;;;;;;CAOpB,MAAa,OAA4B;AACvC,OAAK,MAAM,cAAc,KAAK,aAAa;GACzC,MAAM,OAAO,oCAAc,YAAY,EAAE,eAAe,MAAM,CAAC;AAE/D,QAAK,MAAM,OAAO,KAChB,KAAI,IAAI,aAAa,EAAE;IACrB,MAAM,2BAAY,YAAY,IAAI,KAAK;AACvC,UAAM,KAAK,UAAU,IAAI,MAAM,MAAM,MAAM,EAAE,EAAE,KAAK;;;AAK1D,SAAO,OAAO,YAAY,KAAK,OAAO;;;;;;CAOxC,AAAO,SAAqB;AAC1B,SAAO,OAAO,YAAY,KAAK,OAAO;;;;;;;;;CAUxC,MAAc,UACd,OACA,MACA,aAA4B,MAC5B,YAAsB,EAAE,EACxB,SAAS,OACO;EACd,MAAM,QAAQ,oCAAc,MAAM,EAAE,eAAe,MAAM,CAAC;EAC1D,MAAM,cAAc,UAAU,WAAW,KAAK,MAAM;EAGpD,MAAM,YAAY,cAAc,MAAM,MAAM,GAAG,GAAG,GAAG,cAAc;AAEnE,QAAM,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC;AAElD,OAAK,MAAM,QAAQ,OAAO;AACxB,OAAI,KAAK,KAAK,WAAW,IAAI,CAAE;AAE/B,OAAI,KAAK,aAAa,EAAE;IACtB,MAAM,+BAAgB,MAAM,KAAK,KAAK;AACtC,UAAM,KAAK,UAAU,KAAK,MAAM,UAAU,WAAW,UAAU;AAC/D;;AAGF,OAAI,KAAK,QAAQ,IAAI,oBAAoB,KAAK,KAAK,KAAK,CACtD,WAAU,yBAAU,KAAK,YAAY,KAAK,KAAK,CAAC;;AAIpD,MAAI,CAAC,aAAa;GAChB,MAAM,WAAW,KAAK,OAAO,IAAI,MAAM;AAEvC,OAAI,UAAU;AACZ,aAAS,YAAY,MAAM,KACzB,IAAI,IAAI,CAAC,GAAG,SAAS,WAAW,GAAG,UAAU,CAAC,CAC/C;AAED;;AAGF,QAAK,OAAO,IAAI,OAAO;IAAE;IAAO;IAAM;IAAW;IAAW,CAAC"}
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-kSYXY2_d.js');
|
|
2
|
-
const require_error_codes = require('./error-codes-Ds0bnPvT.js');
|
|
3
|
-
let discord_js = require("discord.js");
|
|
4
|
-
|
|
5
|
-
//#region src/app/commands/MessageCommandParser.ts
|
|
6
|
-
/**
|
|
7
|
-
* Parses message content into structured command data with options and subcommands.
|
|
8
|
-
*/
|
|
9
|
-
var MessageCommandParser = class {
|
|
10
|
-
/**
|
|
11
|
-
* @private
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
#parsed = null;
|
|
15
|
-
/**
|
|
16
|
-
* @private
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
#options = null;
|
|
20
|
-
/**
|
|
21
|
-
* @private
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
#args = [];
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new message command parser.
|
|
27
|
-
* @param message - The Discord message to parse
|
|
28
|
-
* @param prefix - Array of valid command prefixes or a regular expression
|
|
29
|
-
* @param schema - Function that returns the options schema for a command
|
|
30
|
-
*/
|
|
31
|
-
constructor(message, prefix, schema) {
|
|
32
|
-
this.message = message;
|
|
33
|
-
this.prefix = prefix;
|
|
34
|
-
this.schema = schema;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Gets the parsed command arguments.
|
|
38
|
-
* @returns Array of command arguments
|
|
39
|
-
*/
|
|
40
|
-
getArgs() {
|
|
41
|
-
this.parse();
|
|
42
|
-
return this.#args;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Gets the message command options object for easy access to typed option values.
|
|
46
|
-
*/
|
|
47
|
-
get options() {
|
|
48
|
-
if (!this.#options) this.#options = new MessageCommandOptions(this);
|
|
49
|
-
return this.#options;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Gets a specific option value by name.
|
|
53
|
-
* @param name - The option name
|
|
54
|
-
* @returns The option value or undefined if not found
|
|
55
|
-
*/
|
|
56
|
-
getOption(name) {
|
|
57
|
-
var _this$parse$options$f;
|
|
58
|
-
return (_this$parse$options$f = this.parse().options.find((o) => o.name === name)) === null || _this$parse$options$f === void 0 ? void 0 : _this$parse$options$f.value;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Gets the main command name.
|
|
62
|
-
* @returns The command name
|
|
63
|
-
*/
|
|
64
|
-
getCommand() {
|
|
65
|
-
return this.parse().command;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Gets the subcommand name if present.
|
|
69
|
-
* @returns The subcommand name or undefined
|
|
70
|
-
*/
|
|
71
|
-
getSubcommand() {
|
|
72
|
-
return this.parse().subcommand;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Gets the subcommand group name if present.
|
|
76
|
-
* @returns The subcommand group name or undefined
|
|
77
|
-
*/
|
|
78
|
-
getSubcommandGroup() {
|
|
79
|
-
return this.parse().subcommandGroup;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Gets the prefix used in the message.
|
|
83
|
-
* @returns The matched prefix or undefined
|
|
84
|
-
*/
|
|
85
|
-
getPrefix() {
|
|
86
|
-
if (this.prefix instanceof RegExp) {
|
|
87
|
-
const match = this.message.content.match(this.prefix);
|
|
88
|
-
return match === null || match === void 0 ? void 0 : match[0];
|
|
89
|
-
}
|
|
90
|
-
for (const p of this.prefix) if (this.message.content.startsWith(p)) return p;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Gets the full command including subcommand group and subcommand.
|
|
94
|
-
* @returns The complete command string
|
|
95
|
-
*/
|
|
96
|
-
getFullCommand() {
|
|
97
|
-
return [
|
|
98
|
-
this.getCommand(),
|
|
99
|
-
this.getSubcommandGroup(),
|
|
100
|
-
this.getSubcommand()
|
|
101
|
-
].filter((v) => v).join(" ");
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Parses the message content into structured command data.
|
|
105
|
-
* @returns The parsed command data
|
|
106
|
-
*/
|
|
107
|
-
parse() {
|
|
108
|
-
if (this.#parsed) return this.#parsed;
|
|
109
|
-
const content = this.message.content;
|
|
110
|
-
const prefix = this.getPrefix();
|
|
111
|
-
if (!prefix) throw require_error_codes.createCommandKitError(require_error_codes.CommandKitErrorCodes.InvalidCommandPrefix);
|
|
112
|
-
const parts = content.slice(prefix.length).trim().split(" ");
|
|
113
|
-
const command = parts.shift();
|
|
114
|
-
this.#args = parts;
|
|
115
|
-
let subcommandGroup;
|
|
116
|
-
let subcommand;
|
|
117
|
-
if (command === null || command === void 0 ? void 0 : command.includes(":")) {
|
|
118
|
-
const [, group, cmd] = command.split(":");
|
|
119
|
-
if (!cmd && group) subcommand = group;
|
|
120
|
-
else if (cmd && group) {
|
|
121
|
-
subcommandGroup = group;
|
|
122
|
-
subcommand = cmd;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const schema = this.schema([
|
|
126
|
-
command,
|
|
127
|
-
subcommandGroup,
|
|
128
|
-
subcommand
|
|
129
|
-
].filter(Boolean).join(" ").trim());
|
|
130
|
-
this.#parsed = {
|
|
131
|
-
command,
|
|
132
|
-
options: parts.map((part) => {
|
|
133
|
-
try {
|
|
134
|
-
const [name, value] = part.split(":");
|
|
135
|
-
if (!(name in schema)) return null;
|
|
136
|
-
switch (schema[name]) {
|
|
137
|
-
case discord_js.ApplicationCommandOptionType.Boolean: return {
|
|
138
|
-
name,
|
|
139
|
-
value: value === "true"
|
|
140
|
-
};
|
|
141
|
-
case discord_js.ApplicationCommandOptionType.Integer: return {
|
|
142
|
-
name,
|
|
143
|
-
value: parseInt(value, 10)
|
|
144
|
-
};
|
|
145
|
-
case discord_js.ApplicationCommandOptionType.Number: return {
|
|
146
|
-
name,
|
|
147
|
-
value: parseFloat(value)
|
|
148
|
-
};
|
|
149
|
-
case discord_js.ApplicationCommandOptionType.String: return {
|
|
150
|
-
name,
|
|
151
|
-
value
|
|
152
|
-
};
|
|
153
|
-
case discord_js.ApplicationCommandOptionType.User: return {
|
|
154
|
-
name,
|
|
155
|
-
value: this.message.mentions.users.find((u) => {
|
|
156
|
-
return u.id === value.replace(/[<@!>]/g, "");
|
|
157
|
-
})
|
|
158
|
-
};
|
|
159
|
-
case discord_js.ApplicationCommandOptionType.Channel: return {
|
|
160
|
-
name,
|
|
161
|
-
value: this.message.mentions.channels.find((c) => {
|
|
162
|
-
return c.id === value.replace(/[<#>]/g, "");
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
case discord_js.ApplicationCommandOptionType.Role: return {
|
|
166
|
-
name,
|
|
167
|
-
value: this.message.mentions.roles.find((r) => {
|
|
168
|
-
return r.id === value.replace(/[<@&>]/g, "");
|
|
169
|
-
})
|
|
170
|
-
};
|
|
171
|
-
case discord_js.ApplicationCommandOptionType.Attachment: return {
|
|
172
|
-
name,
|
|
173
|
-
value: this.message.attachments.find((a) => {
|
|
174
|
-
return a.name === value;
|
|
175
|
-
})
|
|
176
|
-
};
|
|
177
|
-
default: return null;
|
|
178
|
-
}
|
|
179
|
-
} catch {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
}).filter((v) => v !== null),
|
|
183
|
-
subcommand,
|
|
184
|
-
subcommandGroup
|
|
185
|
-
};
|
|
186
|
-
return this.#parsed;
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* Provides typed access to message command options with methods similar to Discord.js interaction options.
|
|
191
|
-
*/
|
|
192
|
-
var MessageCommandOptions = class {
|
|
193
|
-
/**
|
|
194
|
-
* Creates a new message command options instance.
|
|
195
|
-
* @param parser - The message command parser instance
|
|
196
|
-
*/
|
|
197
|
-
constructor(parser) {
|
|
198
|
-
this.parser = parser;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* @private
|
|
202
|
-
* @internal
|
|
203
|
-
*/
|
|
204
|
-
assertOption(name, required = false) {
|
|
205
|
-
const option = this.parser.getOption(name);
|
|
206
|
-
if (required && option === void 0) throw new Error(`Option "${name}" is required.`);
|
|
207
|
-
return option ?? null;
|
|
208
|
-
}
|
|
209
|
-
getMember(name, required = false) {
|
|
210
|
-
var _this$parser$message$;
|
|
211
|
-
const user = this.assertOption(name, required);
|
|
212
|
-
const member = (_this$parser$message$ = this.parser.message.guild) === null || _this$parser$message$ === void 0 ? void 0 : _this$parser$message$.members.cache.get(user === null || user === void 0 ? void 0 : user.id);
|
|
213
|
-
if (required && !member) throw new Error(`Member "${name}" is required.`);
|
|
214
|
-
return member ?? null;
|
|
215
|
-
}
|
|
216
|
-
getAttachment(name, required = false) {
|
|
217
|
-
return this.assertOption(name, required);
|
|
218
|
-
}
|
|
219
|
-
getBoolean(name, required = false) {
|
|
220
|
-
return this.assertOption(name, required);
|
|
221
|
-
}
|
|
222
|
-
getNumber(name, required = false) {
|
|
223
|
-
return this.assertOption(name, required);
|
|
224
|
-
}
|
|
225
|
-
getString(name, required = false) {
|
|
226
|
-
return this.assertOption(name, required);
|
|
227
|
-
}
|
|
228
|
-
getInteger(name, required = false) {
|
|
229
|
-
return this.assertOption(name, required);
|
|
230
|
-
}
|
|
231
|
-
getUser(name, required = false) {
|
|
232
|
-
return this.assertOption(name, required);
|
|
233
|
-
}
|
|
234
|
-
getChannel(name, required = false) {
|
|
235
|
-
return this.assertOption(name, required);
|
|
236
|
-
}
|
|
237
|
-
getRole(name, required = false) {
|
|
238
|
-
return this.assertOption(name, required);
|
|
239
|
-
}
|
|
240
|
-
getMentionable(name, required = false) {
|
|
241
|
-
const target = this.assertOption(name, required);
|
|
242
|
-
if (target instanceof discord_js.GuildMember || target instanceof discord_js.User || target instanceof discord_js.Role) return target;
|
|
243
|
-
if (required) throw new Error(`Mentionable "${name}" is required.`);
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
getSubcommand(required = false) {
|
|
247
|
-
const sub = this.parser.getSubcommand();
|
|
248
|
-
if (required && sub === void 0) throw new Error("Subcommand is required.");
|
|
249
|
-
return sub ?? null;
|
|
250
|
-
}
|
|
251
|
-
getSubcommandGroup(required = false) {
|
|
252
|
-
const sub = this.parser.getSubcommandGroup();
|
|
253
|
-
if (required && sub === void 0) throw new Error("Subcommand group is required.");
|
|
254
|
-
return sub ?? null;
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
//#endregion
|
|
259
|
-
Object.defineProperty(exports, 'MessageCommandOptions', {
|
|
260
|
-
enumerable: true,
|
|
261
|
-
get: function () {
|
|
262
|
-
return MessageCommandOptions;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
Object.defineProperty(exports, 'MessageCommandParser', {
|
|
266
|
-
enumerable: true,
|
|
267
|
-
get: function () {
|
|
268
|
-
return MessageCommandParser;
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
//# sourceMappingURL=MessageCommandParser-Bs9fimmd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageCommandParser-Bs9fimmd.js","names":[],"sources":["../src/app/commands/MessageCommandParser.ts"],"sourcesContent":["import { Channel } from 'diagnostics_channel';\nimport {\n Message,\n ApplicationCommandOptionType,\n GuildMember,\n Attachment,\n User,\n Role,\n CommandInteractionOption,\n} from 'discord.js';\nimport {\n CommandKitErrorCodes,\n createCommandKitError,\n} from '../../utils/error-codes';\n\n/**\n * Represents a parsed message command with its components.\n */\nexport interface ParsedMessageCommand {\n command: string;\n options: { name: string; value: unknown }[];\n subcommand?: string;\n subcommandGroup?: string;\n}\n\n/**\n * Schema defining the types of options for a message command.\n */\nexport type MessageCommandOptionsSchema = Record<\n string,\n ApplicationCommandOptionType\n>;\n\n/**\n * Parses message content into structured command data with options and subcommands.\n */\nexport class MessageCommandParser {\n /**\n * @private\n * @internal\n */\n #parsed: ParsedMessageCommand | null = null;\n\n /**\n * @private\n * @internal\n */\n #options: MessageCommandOptions | null = null;\n\n /**\n * @private\n * @internal\n */\n #args: string[] = [];\n\n /**\n * Creates a new message command parser.\n * @param message - The Discord message to parse\n * @param prefix - Array of valid command prefixes or a regular expression\n * @param schema - Function that returns the options schema for a command\n */\n public constructor(\n public message: Message,\n private prefix: string[] | RegExp,\n private schema: (command: string) => MessageCommandOptionsSchema,\n ) {}\n\n /**\n * Gets the parsed command arguments.\n * @returns Array of command arguments\n */\n public getArgs() {\n void this.parse();\n return this.#args;\n }\n\n /**\n * Gets the message command options object for easy access to typed option values.\n */\n public get options() {\n if (!this.#options) {\n this.#options = new MessageCommandOptions(this);\n }\n\n return this.#options;\n }\n\n /**\n * Gets a specific option value by name.\n * @param name - The option name\n * @returns The option value or undefined if not found\n */\n public getOption<T>(name: string): T | undefined {\n return this.parse().options.find((o) => o.name === name)?.value as T;\n }\n\n /**\n * Gets the main command name.\n * @returns The command name\n */\n public getCommand(): string {\n return this.parse().command;\n }\n\n /**\n * Gets the subcommand name if present.\n * @returns The subcommand name or undefined\n */\n public getSubcommand(): string | undefined {\n return this.parse().subcommand;\n }\n\n /**\n * Gets the subcommand group name if present.\n * @returns The subcommand group name or undefined\n */\n public getSubcommandGroup(): string | undefined {\n return this.parse().subcommandGroup;\n }\n\n /**\n * Gets the prefix used in the message.\n * @returns The matched prefix or undefined\n */\n public getPrefix() {\n if (this.prefix instanceof RegExp) {\n const match = this.message.content.match(this.prefix);\n return match?.[0];\n }\n\n for (const p of this.prefix) {\n if (this.message.content.startsWith(p)) {\n return p;\n }\n }\n }\n\n /**\n * Gets the full command including subcommand group and subcommand.\n * @returns The complete command string\n */\n public getFullCommand() {\n return [this.getCommand(), this.getSubcommandGroup(), this.getSubcommand()]\n .filter((v) => v)\n .join(' ');\n }\n\n /**\n * Parses the message content into structured command data.\n * @returns The parsed command data\n */\n public parse(): ParsedMessageCommand {\n if (this.#parsed) {\n return this.#parsed;\n }\n\n const content = this.message.content;\n\n const prefix = this.getPrefix();\n\n if (!prefix) {\n throw createCommandKitError(CommandKitErrorCodes.InvalidCommandPrefix);\n }\n\n const parts = content.slice(prefix.length).trim().split(' ');\n const command = parts.shift();\n\n this.#args = parts;\n\n let subcommandGroup: string | undefined;\n let subcommand: string | undefined;\n\n if (command?.includes(':')) {\n const [, group, cmd] = command.split(':');\n\n if (!cmd && group) {\n subcommand = group;\n } else if (cmd && group) {\n subcommandGroup = group;\n subcommand = cmd;\n }\n }\n\n const schema = this.schema(\n [command, subcommandGroup, subcommand].filter(Boolean).join(' ').trim(),\n );\n\n const options = parts\n .map((part) => {\n try {\n const [name, value] = part.split(':');\n\n if (!(name in schema)) return null;\n\n switch (schema[name]) {\n case ApplicationCommandOptionType.Boolean:\n return { name, value: value === 'true' };\n case ApplicationCommandOptionType.Integer:\n return { name, value: parseInt(value, 10) };\n case ApplicationCommandOptionType.Number:\n return { name, value: parseFloat(value) };\n case ApplicationCommandOptionType.String:\n return { name, value };\n case ApplicationCommandOptionType.User:\n return {\n name,\n value: this.message.mentions.users.find((u) => {\n return u.id === value.replace(/[<@!>]/g, '');\n }),\n };\n case ApplicationCommandOptionType.Channel:\n return {\n name,\n value: this.message.mentions.channels.find((c) => {\n return c.id === value.replace(/[<#>]/g, '');\n }),\n };\n case ApplicationCommandOptionType.Role:\n return {\n name,\n value: this.message.mentions.roles.find((r) => {\n return r.id === value.replace(/[<@&>]/g, '');\n }),\n };\n case ApplicationCommandOptionType.Attachment:\n return {\n name,\n value: this.message.attachments.find((a) => {\n return a.name === value;\n }),\n };\n default:\n return null;\n }\n } catch {\n // Invalid option\n return null;\n }\n })\n .filter((v) => v !== null);\n\n this.#parsed = {\n command: command!,\n options,\n subcommand,\n subcommandGroup,\n };\n\n return this.#parsed;\n }\n}\n\n/**\n * Provides typed access to message command options with methods similar to Discord.js interaction options.\n */\nexport class MessageCommandOptions {\n /**\n * Creates a new message command options instance.\n * @param parser - The message command parser instance\n */\n public constructor(private parser: MessageCommandParser) {}\n\n /**\n * @private\n * @internal\n */\n private assertOption<T>(name: string, required = false) {\n const option = this.parser.getOption<T>(name);\n\n if (required && option === undefined) {\n throw new Error(`Option \"${name}\" is required.`);\n }\n\n return option ?? null;\n }\n\n /**\n * Gets a guild member from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The guild member or null if not found\n */\n getMember(name: string): GuildMember | null;\n getMember(name: string, required: true): GuildMember;\n getMember(name: string, required = false) {\n const user = this.assertOption<User>(name, required);\n const member = this.parser.message.guild?.members.cache.get(user?.id!);\n\n if (required && !member) {\n throw new Error(`Member \"${name}\" is required.`);\n }\n\n return member ?? null;\n }\n\n /**\n * Gets an attachment from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The attachment or null if not found\n */\n getAttachment(name: string): Attachment | null;\n getAttachment(name: string, required: true): Attachment;\n getAttachment(name: string, required = false) {\n return this.assertOption<Attachment>(name, required);\n }\n\n /**\n * Gets a boolean value from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The boolean value or null if not found\n */\n getBoolean(name: string): boolean | null;\n getBoolean(name: string, required: true): boolean;\n getBoolean(name: string, required = false) {\n return this.assertOption<boolean>(name, required);\n }\n\n /**\n * Gets a number value from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The number value or null if not found\n */\n getNumber(name: string): number | null;\n getNumber(name: string, required: true): number;\n getNumber(name: string, required = false) {\n return this.assertOption<number>(name, required);\n }\n\n /**\n * Gets a string value from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The string value or null if not found\n */\n getString(name: string): string | null;\n getString(name: string, required: true): string;\n getString(name: string, required = false) {\n return this.assertOption<string>(name, required);\n }\n\n /**\n * Gets an integer value from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The integer value or null if not found\n */\n getInteger(name: string): number | null;\n getInteger(name: string, required: true): number;\n getInteger(name: string, required = false) {\n return this.assertOption<number>(name, required);\n }\n\n /**\n * Gets a user from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The user or null if not found\n */\n getUser(name: string): User | null;\n getUser(name: string, required: true): User;\n getUser(name: string, required = false) {\n return this.assertOption<User>(name, required);\n }\n\n /**\n * Gets a channel from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The channel or null if not found\n */\n getChannel(name: string): Channel | null;\n getChannel(name: string, required: true): Channel;\n getChannel(name: string, required = false) {\n return this.assertOption<Channel>(name, required);\n }\n\n /**\n * Gets a role from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The role or null if not found\n */\n getRole(name: string): Role | null;\n getRole(name: string, required: true): Role;\n getRole(name: string, required = false) {\n return this.assertOption<Role>(name, required);\n }\n\n /**\n * Gets a mentionable (user, member, or role) from the command options.\n * @param name - The option name\n * @param required - Whether the option is required\n * @returns The mentionable or null if not found\n */\n getMentionable(\n name: string,\n ): NonNullable<CommandInteractionOption['member' | 'role' | 'user']> | null;\n getMentionable(\n name: string,\n required: true,\n ): NonNullable<CommandInteractionOption['member' | 'role' | 'user']>;\n getMentionable(\n name: string,\n required = false,\n ): NonNullable<CommandInteractionOption['member' | 'role' | 'user']> | null {\n const target = this.assertOption(name, required);\n\n if (\n target instanceof GuildMember ||\n target instanceof User ||\n target instanceof Role\n ) {\n return target;\n }\n\n if (required) {\n throw new Error(`Mentionable \"${name}\" is required.`);\n }\n\n return null;\n }\n\n /**\n * Gets the subcommand name from the command.\n * @param required - Whether the subcommand is required\n * @returns The subcommand name or null if not found\n */\n getSubcommand(): string | null;\n getSubcommand(required: true): string;\n getSubcommand(required = false) {\n const sub = this.parser.getSubcommand();\n\n if (required && sub === undefined) {\n throw new Error('Subcommand is required.');\n }\n\n return sub ?? null;\n }\n\n /**\n * Gets the subcommand group name from the command.\n * @param required - Whether the subcommand group is required\n * @returns The subcommand group name or null if not found\n */\n getSubcommandGroup(): string | null;\n getSubcommandGroup(required: true): string;\n getSubcommandGroup(required = false) {\n const sub = this.parser.getSubcommandGroup();\n\n if (required && sub === undefined) {\n throw new Error('Subcommand group is required.');\n }\n\n return sub ?? null;\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { ApplicationCommandOptionType, Attachment, CommandInteractionOption, GuildMember, Message, Role, User } from "discord.js";
|
|
2
|
-
import { Channel } from "diagnostics_channel";
|
|
3
|
-
|
|
4
|
-
//#region src/app/commands/MessageCommandParser.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Represents a parsed message command with its components.
|
|
7
|
-
*/
|
|
8
|
-
interface ParsedMessageCommand {
|
|
9
|
-
command: string;
|
|
10
|
-
options: {
|
|
11
|
-
name: string;
|
|
12
|
-
value: unknown;
|
|
13
|
-
}[];
|
|
14
|
-
subcommand?: string;
|
|
15
|
-
subcommandGroup?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Schema defining the types of options for a message command.
|
|
19
|
-
*/
|
|
20
|
-
type MessageCommandOptionsSchema = Record<string, ApplicationCommandOptionType>;
|
|
21
|
-
/**
|
|
22
|
-
* Parses message content into structured command data with options and subcommands.
|
|
23
|
-
*/
|
|
24
|
-
declare class MessageCommandParser {
|
|
25
|
-
#private;
|
|
26
|
-
message: Message;
|
|
27
|
-
private prefix;
|
|
28
|
-
private schema;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a new message command parser.
|
|
31
|
-
* @param message - The Discord message to parse
|
|
32
|
-
* @param prefix - Array of valid command prefixes or a regular expression
|
|
33
|
-
* @param schema - Function that returns the options schema for a command
|
|
34
|
-
*/
|
|
35
|
-
constructor(message: Message, prefix: string[] | RegExp, schema: (command: string) => MessageCommandOptionsSchema);
|
|
36
|
-
/**
|
|
37
|
-
* Gets the parsed command arguments.
|
|
38
|
-
* @returns Array of command arguments
|
|
39
|
-
*/
|
|
40
|
-
getArgs(): string[];
|
|
41
|
-
/**
|
|
42
|
-
* Gets the message command options object for easy access to typed option values.
|
|
43
|
-
*/
|
|
44
|
-
get options(): MessageCommandOptions;
|
|
45
|
-
/**
|
|
46
|
-
* Gets a specific option value by name.
|
|
47
|
-
* @param name - The option name
|
|
48
|
-
* @returns The option value or undefined if not found
|
|
49
|
-
*/
|
|
50
|
-
getOption<T>(name: string): T | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Gets the main command name.
|
|
53
|
-
* @returns The command name
|
|
54
|
-
*/
|
|
55
|
-
getCommand(): string;
|
|
56
|
-
/**
|
|
57
|
-
* Gets the subcommand name if present.
|
|
58
|
-
* @returns The subcommand name or undefined
|
|
59
|
-
*/
|
|
60
|
-
getSubcommand(): string | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Gets the subcommand group name if present.
|
|
63
|
-
* @returns The subcommand group name or undefined
|
|
64
|
-
*/
|
|
65
|
-
getSubcommandGroup(): string | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Gets the prefix used in the message.
|
|
68
|
-
* @returns The matched prefix or undefined
|
|
69
|
-
*/
|
|
70
|
-
getPrefix(): string | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Gets the full command including subcommand group and subcommand.
|
|
73
|
-
* @returns The complete command string
|
|
74
|
-
*/
|
|
75
|
-
getFullCommand(): string;
|
|
76
|
-
/**
|
|
77
|
-
* Parses the message content into structured command data.
|
|
78
|
-
* @returns The parsed command data
|
|
79
|
-
*/
|
|
80
|
-
parse(): ParsedMessageCommand;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Provides typed access to message command options with methods similar to Discord.js interaction options.
|
|
84
|
-
*/
|
|
85
|
-
declare class MessageCommandOptions {
|
|
86
|
-
private parser;
|
|
87
|
-
/**
|
|
88
|
-
* Creates a new message command options instance.
|
|
89
|
-
* @param parser - The message command parser instance
|
|
90
|
-
*/
|
|
91
|
-
constructor(parser: MessageCommandParser);
|
|
92
|
-
/**
|
|
93
|
-
* @private
|
|
94
|
-
* @internal
|
|
95
|
-
*/
|
|
96
|
-
private assertOption;
|
|
97
|
-
/**
|
|
98
|
-
* Gets a guild member from the command options.
|
|
99
|
-
* @param name - The option name
|
|
100
|
-
* @param required - Whether the option is required
|
|
101
|
-
* @returns The guild member or null if not found
|
|
102
|
-
*/
|
|
103
|
-
getMember(name: string): GuildMember | null;
|
|
104
|
-
getMember(name: string, required: true): GuildMember;
|
|
105
|
-
/**
|
|
106
|
-
* Gets an attachment from the command options.
|
|
107
|
-
* @param name - The option name
|
|
108
|
-
* @param required - Whether the option is required
|
|
109
|
-
* @returns The attachment or null if not found
|
|
110
|
-
*/
|
|
111
|
-
getAttachment(name: string): Attachment | null;
|
|
112
|
-
getAttachment(name: string, required: true): Attachment;
|
|
113
|
-
/**
|
|
114
|
-
* Gets a boolean value from the command options.
|
|
115
|
-
* @param name - The option name
|
|
116
|
-
* @param required - Whether the option is required
|
|
117
|
-
* @returns The boolean value or null if not found
|
|
118
|
-
*/
|
|
119
|
-
getBoolean(name: string): boolean | null;
|
|
120
|
-
getBoolean(name: string, required: true): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Gets a number value from the command options.
|
|
123
|
-
* @param name - The option name
|
|
124
|
-
* @param required - Whether the option is required
|
|
125
|
-
* @returns The number value or null if not found
|
|
126
|
-
*/
|
|
127
|
-
getNumber(name: string): number | null;
|
|
128
|
-
getNumber(name: string, required: true): number;
|
|
129
|
-
/**
|
|
130
|
-
* Gets a string value from the command options.
|
|
131
|
-
* @param name - The option name
|
|
132
|
-
* @param required - Whether the option is required
|
|
133
|
-
* @returns The string value or null if not found
|
|
134
|
-
*/
|
|
135
|
-
getString(name: string): string | null;
|
|
136
|
-
getString(name: string, required: true): string;
|
|
137
|
-
/**
|
|
138
|
-
* Gets an integer value from the command options.
|
|
139
|
-
* @param name - The option name
|
|
140
|
-
* @param required - Whether the option is required
|
|
141
|
-
* @returns The integer value or null if not found
|
|
142
|
-
*/
|
|
143
|
-
getInteger(name: string): number | null;
|
|
144
|
-
getInteger(name: string, required: true): number;
|
|
145
|
-
/**
|
|
146
|
-
* Gets a user from the command options.
|
|
147
|
-
* @param name - The option name
|
|
148
|
-
* @param required - Whether the option is required
|
|
149
|
-
* @returns The user or null if not found
|
|
150
|
-
*/
|
|
151
|
-
getUser(name: string): User | null;
|
|
152
|
-
getUser(name: string, required: true): User;
|
|
153
|
-
/**
|
|
154
|
-
* Gets a channel from the command options.
|
|
155
|
-
* @param name - The option name
|
|
156
|
-
* @param required - Whether the option is required
|
|
157
|
-
* @returns The channel or null if not found
|
|
158
|
-
*/
|
|
159
|
-
getChannel(name: string): Channel | null;
|
|
160
|
-
getChannel(name: string, required: true): Channel;
|
|
161
|
-
/**
|
|
162
|
-
* Gets a role from the command options.
|
|
163
|
-
* @param name - The option name
|
|
164
|
-
* @param required - Whether the option is required
|
|
165
|
-
* @returns The role or null if not found
|
|
166
|
-
*/
|
|
167
|
-
getRole(name: string): Role | null;
|
|
168
|
-
getRole(name: string, required: true): Role;
|
|
169
|
-
/**
|
|
170
|
-
* Gets a mentionable (user, member, or role) from the command options.
|
|
171
|
-
* @param name - The option name
|
|
172
|
-
* @param required - Whether the option is required
|
|
173
|
-
* @returns The mentionable or null if not found
|
|
174
|
-
*/
|
|
175
|
-
getMentionable(name: string): NonNullable<CommandInteractionOption['member' | 'role' | 'user']> | null;
|
|
176
|
-
getMentionable(name: string, required: true): NonNullable<CommandInteractionOption['member' | 'role' | 'user']>;
|
|
177
|
-
/**
|
|
178
|
-
* Gets the subcommand name from the command.
|
|
179
|
-
* @param required - Whether the subcommand is required
|
|
180
|
-
* @returns The subcommand name or null if not found
|
|
181
|
-
*/
|
|
182
|
-
getSubcommand(): string | null;
|
|
183
|
-
getSubcommand(required: true): string;
|
|
184
|
-
/**
|
|
185
|
-
* Gets the subcommand group name from the command.
|
|
186
|
-
* @param required - Whether the subcommand group is required
|
|
187
|
-
* @returns The subcommand group name or null if not found
|
|
188
|
-
*/
|
|
189
|
-
getSubcommandGroup(): string | null;
|
|
190
|
-
getSubcommandGroup(required: true): string;
|
|
191
|
-
}
|
|
192
|
-
//#endregion
|
|
193
|
-
export { ParsedMessageCommand as i, MessageCommandOptionsSchema as n, MessageCommandParser as r, MessageCommandOptions as t };
|
|
194
|
-
//# sourceMappingURL=MessageCommandParser-q3dQcE5N.d.ts.map
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-kSYXY2_d.js');
|
|
2
|
-
let node_crypto = require("node:crypto");
|
|
3
|
-
|
|
4
|
-
//#region src/plugins/PluginCommon.ts
|
|
5
|
-
/**
|
|
6
|
-
* Enum representing the type of plugin.
|
|
7
|
-
* - Compiler: A plugin that runs at compile time.
|
|
8
|
-
* - Runtime: A plugin that runs at runtime.
|
|
9
|
-
*/
|
|
10
|
-
let PluginType = /* @__PURE__ */ function(PluginType) {
|
|
11
|
-
PluginType["Compiler"] = "compiler";
|
|
12
|
-
PluginType["Runtime"] = "runtime";
|
|
13
|
-
return PluginType;
|
|
14
|
-
}({});
|
|
15
|
-
/**
|
|
16
|
-
* Base class for CommandKit plugins.
|
|
17
|
-
*/
|
|
18
|
-
var PluginCommon = class {
|
|
19
|
-
/**
|
|
20
|
-
* Unique identifier for the plugin instance.
|
|
21
|
-
*/
|
|
22
|
-
id = (0, node_crypto.randomUUID)();
|
|
23
|
-
/**
|
|
24
|
-
* The time when the plugin was loaded, in milliseconds since the Unix epoch.
|
|
25
|
-
*/
|
|
26
|
-
loadedAt = Date.now();
|
|
27
|
-
/**
|
|
28
|
-
* Creates a new instance of the plugin.
|
|
29
|
-
*/
|
|
30
|
-
constructor(options) {
|
|
31
|
-
this.options = options;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Called when this plugin is activated
|
|
35
|
-
*/
|
|
36
|
-
async activate(ctx) {}
|
|
37
|
-
/**
|
|
38
|
-
* Called when this plugin is deactivated
|
|
39
|
-
*/
|
|
40
|
-
async deactivate(ctx) {}
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Whether the given object is a CommandKit plugin.
|
|
44
|
-
* @param plugin The object to check.
|
|
45
|
-
* @returns Boolean indicating whether the object is a plugin.
|
|
46
|
-
*/
|
|
47
|
-
function isPlugin(plugin) {
|
|
48
|
-
return plugin instanceof PluginCommon;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
Object.defineProperty(exports, 'PluginCommon', {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return PluginCommon;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(exports, 'PluginType', {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
get: function () {
|
|
61
|
-
return PluginType;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(exports, 'isPlugin', {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: function () {
|
|
67
|
-
return isPlugin;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=PluginCommon-BLxWww5u.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginCommon-BLxWww5u.js","names":[],"sources":["../src/plugins/PluginCommon.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { CommonPluginRuntime } from './plugin-runtime/runtime';\n\n/**\n * The options for a CommandKit plugin.\n */\nexport type PluginOptions = Record<string, any>;\n\n/**\n * Enum representing the type of plugin.\n * - Compiler: A plugin that runs at compile time.\n * - Runtime: A plugin that runs at runtime.\n */\nexport enum PluginType {\n Compiler = 'compiler',\n Runtime = 'runtime',\n}\n\n/**\n * Base class for CommandKit plugins.\n */\nexport abstract class PluginCommon<\n T extends PluginOptions = PluginOptions,\n C extends CommonPluginRuntime = CommonPluginRuntime,\n> {\n /**\n * The type of the plugin, either Compiler or Runtime.\n */\n public abstract readonly type: PluginType;\n /**\n * Unique identifier for the plugin instance.\n */\n public readonly id = randomUUID();\n /**\n * The time when the plugin was loaded, in milliseconds since the Unix epoch.\n */\n public readonly loadedAt = Date.now();\n /**\n * The name of the plugin.\n */\n public abstract readonly name: string;\n\n /**\n * Creates a new instance of the plugin.\n */\n public constructor(protected readonly options: T) {}\n\n /**\n * Called when this plugin is activated\n */\n public async activate(ctx: C): Promise<void> {}\n\n /**\n * Called when this plugin is deactivated\n */\n public async deactivate(ctx: C): Promise<void> {}\n}\n\n/**\n * Whether the given object is a CommandKit plugin.\n * @param plugin The object to check.\n * @returns Boolean indicating whether the object is a plugin.\n */\nexport function isPlugin(\n plugin: unknown,\n): plugin is PluginCommon<PluginOptions> {\n return plugin instanceof PluginCommon;\n}\n"],"mappings":";;;;;;;;;AAaA,IAAY,kDAAL;AACL;AACA;;;;;;AAMF,IAAsB,eAAtB,MAGA;;;;CAQE,AAAgB,kCAAiB;;;;CAIjC,AAAgB,WAAW,KAAK,KAAK;;;;CASrC,AAAO,YAAY,AAAmB,SAAY;EAAZ;;;;;CAKtC,MAAa,SAAS,KAAuB;;;;CAK7C,MAAa,WAAW,KAAuB;;;;;;;AAQjD,SAAgB,SAChB,QACwC;AACtC,QAAO,kBAAkB"}
|