commandkit 1.2.0-rc.6 → 1.2.0-rc.7

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.
Files changed (206) hide show
  1. package/dist/{ActionRow-CmTHbo2t.js → ActionRow-CbdGFWMT.js} +3 -2
  2. package/dist/{ActionRow-CmTHbo2t.js.map → ActionRow-CbdGFWMT.js.map} +1 -1
  3. package/dist/{CommandKitEventsChannel-Bgw0XCOl.js → CommandKitEventsChannel-B5vbINtP.js} +3 -2
  4. package/dist/{CommandKitEventsChannel-Bgw0XCOl.js.map → CommandKitEventsChannel-B5vbINtP.js.map} +1 -1
  5. package/dist/{CommandsRouter-tMAivEfv.js → CommandsRouter-DZAeB2v_.js} +10 -7
  6. package/dist/{CommandsRouter-tMAivEfv.js.map → CommandsRouter-DZAeB2v_.js.map} +1 -1
  7. package/dist/{CompilerPlugin-CjoZAAR8.js → CompilerPlugin-M8r3yNAl.js} +2 -2
  8. package/dist/{CompilerPlugin-CjoZAAR8.js.map → CompilerPlugin-M8r3yNAl.js.map} +1 -1
  9. package/dist/{EventInterceptor-CQ4PBpBJ.js → EventInterceptor-CQEXyUTp.js} +3 -5
  10. package/dist/{EventInterceptor-CQ4PBpBJ.js.map → EventInterceptor-CQEXyUTp.js.map} +1 -1
  11. package/dist/{EventWorkerContext-TZIKxVCu.js → EventWorkerContext-Dq29tieI.js} +3 -2
  12. package/dist/{EventWorkerContext-TZIKxVCu.js.map → EventWorkerContext-Dq29tieI.js.map} +1 -1
  13. package/dist/{EventWorkerContext-D9frVhVe.d.ts → EventWorkerContext-xgEc2N2T.d.ts} +2 -2
  14. package/dist/{EventsRouter-C_J0M3uO.js → EventsRouter-Dzpm7ubq.js} +9 -5
  15. package/dist/{EventsRouter-C_J0M3uO.js.map → EventsRouter-Dzpm7ubq.js.map} +1 -1
  16. package/dist/{MessageCommandParser-TPEPhjvx.js → MessageCommandParser-CEuO6Ex3.js} +3 -2
  17. package/dist/{MessageCommandParser-TPEPhjvx.js.map → MessageCommandParser-CEuO6Ex3.js.map} +1 -1
  18. package/dist/{PluginCommon-Di1xIa8d.js → PluginCommon-Cvl5yYM_.js} +3 -2
  19. package/dist/{PluginCommon-Di1xIa8d.js.map → PluginCommon-Cvl5yYM_.js.map} +1 -1
  20. package/dist/{RuntimePlugin-eTdFJwGd.js → RuntimePlugin-BUecuBIU.js} +2 -2
  21. package/dist/{RuntimePlugin-eTdFJwGd.js.map → RuntimePlugin-BUecuBIU.js.map} +1 -1
  22. package/dist/analytics/analytics-engine.d.ts +1 -1
  23. package/dist/analytics/analytics-engine.js +24 -24
  24. package/dist/analytics/analytics-provider.d.ts +1 -1
  25. package/dist/analytics/constants.js +1 -1
  26. package/dist/analytics/utils.js +24 -24
  27. package/dist/{analytics-engine-CtMbeudW.d.ts → analytics-engine-6_M8tCeD.d.ts} +16 -4
  28. package/dist/app/commands/AppCommandRunner.d.ts +1 -1
  29. package/dist/app/commands/AppCommandRunner.js +24 -24
  30. package/dist/app/commands/Context.d.ts +1 -1
  31. package/dist/app/commands/Context.js +24 -24
  32. package/dist/app/commands/MessageCommandParser.js +1 -1
  33. package/dist/app/commands/helpers.js +1 -1
  34. package/dist/app/events/EventWorkerContext.d.ts +2 -2
  35. package/dist/app/events/EventWorkerContext.js +1 -1
  36. package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
  37. package/dist/app/handlers/AppCommandHandler.js +24 -24
  38. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  39. package/dist/app/handlers/AppEventsHandler.js +24 -24
  40. package/dist/app/index.d.ts +1 -1
  41. package/dist/app/index.js +25 -25
  42. package/dist/app/interrupt/signals.js +2 -2
  43. package/dist/app/middlewares/permissions.d.ts +1 -1
  44. package/dist/app/middlewares/permissions.js +24 -24
  45. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  46. package/dist/app/register/CommandRegistrar.js +24 -24
  47. package/dist/app/router/CommandsRouter.js +1 -1
  48. package/dist/app/router/EventsRouter.js +1 -1
  49. package/dist/app/router/index.js +2 -2
  50. package/dist/{app-process-CjMovpoZ.js → app-process-u2DXakNv.js} +8 -5
  51. package/dist/{app-process-CjMovpoZ.js.map → app-process-u2DXakNv.js.map} +1 -1
  52. package/dist/{build-oC6ke8bF.js → build-e6PlVFfe.js} +15 -11
  53. package/dist/{build-oC6ke8bF.js.map → build-e6PlVFfe.js.map} +1 -1
  54. package/dist/cli/app-process.js +4 -4
  55. package/dist/cli/build.d.ts +1 -1
  56. package/dist/cli/build.js +26 -26
  57. package/dist/cli/common.d.ts +1 -1
  58. package/dist/cli/common.js +3 -3
  59. package/dist/cli/development.js +39 -39
  60. package/dist/cli/development.js.map +1 -1
  61. package/dist/cli/generators.js +9 -6
  62. package/dist/cli/generators.js.map +1 -1
  63. package/dist/cli/information.js +14 -19
  64. package/dist/cli/information.js.map +1 -1
  65. package/dist/cli/init.js +25 -25
  66. package/dist/cli/production.js +29 -28
  67. package/dist/cli/production.js.map +1 -1
  68. package/dist/cli/type-checker.js +4 -4
  69. package/dist/{colors-Cd4Oz-r-.js → colors-DL3ucTiT.js} +3 -2
  70. package/dist/{colors-Cd4Oz-r-.js.map → colors-DL3ucTiT.js.map} +1 -1
  71. package/dist/{commandkit-vWHgiaKd.js → commandkit-Dy4V-Rk2.js} +136 -148
  72. package/dist/commandkit-Dy4V-Rk2.js.map +1 -0
  73. package/dist/commandkit.d.ts +1 -1
  74. package/dist/commandkit.js +24 -24
  75. package/dist/{common-DNADUU3_.js → common-DVM_onKu.js} +15 -15
  76. package/dist/{common-DNADUU3_.js.map → common-DVM_onKu.js.map} +1 -1
  77. package/dist/common-vnMIelAE.js.map +1 -1
  78. package/dist/components/common/EventInterceptor.js +1 -1
  79. package/dist/components/index.js +24 -24
  80. package/dist/components/v1/action-row/ActionRow.js +1 -1
  81. package/dist/components/v1/button/Button.js +24 -24
  82. package/dist/components/v1/button/ButtonKit.js +24 -24
  83. package/dist/components/v1/modal/Modal.js +24 -24
  84. package/dist/components/v1/modal/ModalKit.js +24 -24
  85. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +24 -24
  86. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +24 -24
  87. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +24 -24
  88. package/dist/components/v1/select-menu/SelectMenu.js +24 -24
  89. package/dist/components/v1/select-menu/StringSelectMenuKit.js +24 -24
  90. package/dist/components/v1/select-menu/UserSelectMenuKit.js +24 -24
  91. package/dist/components/v2/container.js +1 -1
  92. package/dist/components/v2/file.js +1 -1
  93. package/dist/components/v2/index.js +6 -6
  94. package/dist/components/v2/media-gallery.js +1 -1
  95. package/dist/components/v2/section.js +1 -1
  96. package/dist/components/v2/separator.js +1 -1
  97. package/dist/components/v2/text-display.js +1 -1
  98. package/dist/config/config.d.ts +2 -2
  99. package/dist/config/config.js +24 -24
  100. package/dist/config/default.d.ts +1 -1
  101. package/dist/config/default.js +24 -24
  102. package/dist/config/loader.d.ts +1 -1
  103. package/dist/config/loader.js +24 -24
  104. package/dist/config/types.d.ts +1 -1
  105. package/dist/config/utils.d.ts +1 -1
  106. package/dist/{config-E42bG1RK.d.ts → config-nD7V_D7G.d.ts} +2 -2
  107. package/dist/constants-B5_Ta7PR.js.map +1 -1
  108. package/dist/{constants-DxfYtA6t.js → constants-BOOGN85p.js} +3 -2
  109. package/dist/{constants-DxfYtA6t.js.map → constants-BOOGN85p.js.map} +1 -1
  110. package/dist/{container-z621KfH5.js → container-C6GtfAPW.js} +3 -2
  111. package/dist/{container-z621KfH5.js.map → container-C6GtfAPW.js.map} +1 -1
  112. package/dist/context/async-context.d.ts +2 -2
  113. package/dist/context/async-context.js +26 -25
  114. package/dist/context/environment.d.ts +1 -1
  115. package/dist/context/environment.js +24 -24
  116. package/dist/{dotprops-C_4L7RPD.js → dotprops-tnhpnszJ.js} +2 -2
  117. package/dist/{dotprops-C_4L7RPD.js.map → dotprops-tnhpnszJ.js.map} +1 -1
  118. package/dist/element-Bak9llw_.js.map +1 -1
  119. package/dist/env-_68PRRoA.js.map +1 -1
  120. package/dist/error-codes-Ds0bnPvT.js.map +1 -1
  121. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  122. package/dist/events/CommandKitEventsChannel.js +1 -1
  123. package/dist/{feature-flags-Ug0I9mfF.js → feature-flags-3TQSPAVn.js} +10 -15
  124. package/dist/{feature-flags-Ug0I9mfF.js.map → feature-flags-3TQSPAVn.js.map} +1 -1
  125. package/dist/{file-DVZC0QXI.js → file-DVOELoNv.js} +3 -2
  126. package/dist/{file-DVZC0QXI.js.map → file-DVOELoNv.js.map} +1 -1
  127. package/dist/flags/FlagProvider.d.ts +1 -1
  128. package/dist/flags/FlagProvider.js.map +1 -1
  129. package/dist/flags/feature-flags.d.ts +1 -1
  130. package/dist/flags/feature-flags.js +25 -25
  131. package/dist/flags/store.d.ts +1 -1
  132. package/dist/flags/store.js +1 -1
  133. package/dist/{helpers-BUlN3lIz.js → helpers-CiuN7y5B.js} +3 -2
  134. package/dist/{helpers-BUlN3lIz.js.map → helpers-CiuN7y5B.js.map} +1 -1
  135. package/dist/index.d.ts +4 -4
  136. package/dist/index.js +31 -29
  137. package/dist/index.js.map +1 -1
  138. package/dist/{init-BTnqvIWt.js → init-Bo01I_h_.js} +11 -8
  139. package/dist/{init-BTnqvIWt.js.map → init-Bo01I_h_.js.map} +1 -1
  140. package/dist/kv/dotprops.js +1 -1
  141. package/dist/kv/kv.js +8 -10
  142. package/dist/kv/kv.js.map +1 -1
  143. package/dist/kv/serde.js +1 -1
  144. package/dist/logger/DefaultLogger.js +24 -24
  145. package/dist/logger/Logger.js +24 -24
  146. package/dist/{media-gallery-CIKypjbJ.js → media-gallery-zDtJ3kxb.js} +3 -2
  147. package/dist/{media-gallery-CIKypjbJ.js.map → media-gallery-zDtJ3kxb.js.map} +1 -1
  148. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  149. package/dist/plugins/CompilerPlugin.js +2 -2
  150. package/dist/plugins/PluginCommon.d.ts +1 -1
  151. package/dist/plugins/PluginCommon.js +1 -1
  152. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  153. package/dist/plugins/RuntimePlugin.js +2 -2
  154. package/dist/plugins/index.d.ts +1 -1
  155. package/dist/plugins/index.js +24 -24
  156. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  157. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +24 -24
  158. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  159. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +24 -24
  160. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  161. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +24 -24
  162. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
  163. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +24 -24
  164. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  165. package/dist/plugins/types.d.ts +1 -1
  166. package/dist/{resolve-file-url-DYjaxg_S.js → resolve-file-url-ChIyw-Vf.js} +4 -4
  167. package/dist/{resolve-file-url-DYjaxg_S.js.map → resolve-file-url-ChIyw-Vf.js.map} +1 -1
  168. package/dist/{section-CuYr0Inu.js → section-DlvrDoJK.js} +4 -4
  169. package/dist/{section-CuYr0Inu.js.map → section-DlvrDoJK.js.map} +1 -1
  170. package/dist/{separator-DLdWBjSN.js → separator-DL6QH5H1.js} +4 -4
  171. package/dist/{separator-DLdWBjSN.js.map → separator-DL6QH5H1.js.map} +1 -1
  172. package/dist/{serde-CHySNpFr.js → serde-Cc8iUa9J.js} +2 -2
  173. package/dist/{serde-CHySNpFr.js.map → serde-Cc8iUa9J.js.map} +1 -1
  174. package/dist/{signals-r7qPAvOR.js → signals-ChFMD7mB.js} +2 -2
  175. package/dist/{signals-r7qPAvOR.js.map → signals-ChFMD7mB.js.map} +1 -1
  176. package/dist/{store-CiqLHedg.js → store-Hcgz7DSt.js} +3 -2
  177. package/dist/{store-CiqLHedg.js.map → store-Hcgz7DSt.js.map} +1 -1
  178. package/dist/{text-display--p2-BoUa.js → text-display-DbMumig_.js} +3 -2
  179. package/dist/{text-display--p2-BoUa.js.map → text-display-DbMumig_.js.map} +1 -1
  180. package/dist/{type-checker-1Iu1jJcy.js → type-checker-M1NIIoWL.js} +7 -5
  181. package/dist/{type-checker-1Iu1jJcy.js.map → type-checker-M1NIIoWL.js.map} +1 -1
  182. package/dist/{types-package-DrnIdWLg.js → types-package-BWArjyBF.js} +7 -4
  183. package/dist/{types-package-DrnIdWLg.js.map → types-package-BWArjyBF.js.map} +1 -1
  184. package/dist/types.d.ts +1 -1
  185. package/dist/utils/colors.js +1 -1
  186. package/dist/utils/dev-hooks.d.ts +1 -1
  187. package/dist/utils/dev-hooks.js +24 -24
  188. package/dist/utils/resolve-file-url.js +1 -1
  189. package/dist/utils/types-package.js +1 -1
  190. package/dist/utils/useful-stuff/async-queue.js.map +1 -1
  191. package/dist/utils/useful-stuff/mutex.js +1 -2
  192. package/dist/utils/useful-stuff/mutex.js.map +1 -1
  193. package/dist/utils/useful-stuff/ratelimiter.js +2 -4
  194. package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
  195. package/dist/utils/useful-stuff/semaphore.js +2 -4
  196. package/dist/utils/useful-stuff/semaphore.js.map +1 -1
  197. package/dist/utils/utilities.js +24 -24
  198. package/dist/utils/warn-unstable.js.map +1 -1
  199. package/dist/utils-DCSnVAZ6.js.map +1 -1
  200. package/dist/utils-KsNof0Xz.js.map +1 -1
  201. package/dist/{version-D0XWDQ4f.js → version-CphQqt4J.js} +2 -2
  202. package/dist/{version-D0XWDQ4f.js.map → version-CphQqt4J.js.map} +1 -1
  203. package/dist/version.js +1 -1
  204. package/hooks.cjs +2 -0
  205. package/package.json +2 -2
  206. package/dist/commandkit-vWHgiaKd.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const discord_js = require_chunk.__toESM(require("discord.js"));
2
+ let discord_js = require("discord.js");
3
+ discord_js = require_chunk.__toESM(discord_js);
3
4
 
4
5
  //#region src/components/v1/action-row/ActionRow.ts
5
6
  /**
@@ -22,4 +23,4 @@ Object.defineProperty(exports, 'ActionRow', {
22
23
  return ActionRow;
23
24
  }
24
25
  });
25
- //# sourceMappingURL=ActionRow-CmTHbo2t.js.map
26
+ //# sourceMappingURL=ActionRow-CbdGFWMT.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionRow-CmTHbo2t.js","names":[],"sources":["../src/components/v1/action-row/ActionRow.ts"],"sourcesContent":["import { ActionRowBuilder } from 'discord.js';\nimport { AnyCommandKitElement, CommandKitElement } from '../../common/element';\n\n/**\n * The properties for the action row component.\n */\nexport interface ActionRowProps {\n children?: AnyCommandKitElement[] | AnyCommandKitElement;\n}\n\n/**\n * The action row component.\n * @param props The action row properties.\n * @returns The commandkit element.\n * @example <ActionRow><Button label=\"Click me\" style={ButtonStyle.Primary} customId=\"click_me\" /></ActionRow>\n */\nexport function ActionRow(\n props: ActionRowProps,\n): CommandKitElement<'action-row'> {\n const row = new ActionRowBuilder();\n\n if (Array.isArray(props.children)) {\n // @ts-ignore\n row.setComponents(...props.children);\n } else if (props.children) {\n // @ts-ignore\n row.setComponents(props.children);\n }\n\n return row;\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,UAChB,OACkC;CAChC,MAAM,MAAM,IAAI;AAEhB,KAAI,MAAM,QAAQ,MAAM,UAEtB,KAAI,cAAc,GAAG,MAAM;UAClB,MAAM,SAEf,KAAI,cAAc,MAAM;AAG1B,QAAO"}
1
+ {"version":3,"file":"ActionRow-CbdGFWMT.js","names":[],"sources":["../src/components/v1/action-row/ActionRow.ts"],"sourcesContent":["import { ActionRowBuilder } from 'discord.js';\nimport { AnyCommandKitElement, CommandKitElement } from '../../common/element';\n\n/**\n * The properties for the action row component.\n */\nexport interface ActionRowProps {\n children?: AnyCommandKitElement[] | AnyCommandKitElement;\n}\n\n/**\n * The action row component.\n * @param props The action row properties.\n * @returns The commandkit element.\n * @example <ActionRow><Button label=\"Click me\" style={ButtonStyle.Primary} customId=\"click_me\" /></ActionRow>\n */\nexport function ActionRow(\n props: ActionRowProps,\n): CommandKitElement<'action-row'> {\n const row = new ActionRowBuilder();\n\n if (Array.isArray(props.children)) {\n // @ts-ignore\n row.setComponents(...props.children);\n } else if (props.children) {\n // @ts-ignore\n row.setComponents(props.children);\n }\n\n return row;\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,UAChB,OACkC;CAChC,MAAM,MAAM,IAAI,6BAAkB;AAElC,KAAI,MAAM,QAAQ,MAAM,SAAS,CAE/B,KAAI,cAAc,GAAG,MAAM,SAAS;UAC3B,MAAM,SAEf,KAAI,cAAc,MAAM,SAAS;AAGnC,QAAO"}
@@ -1,5 +1,6 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const node_events = require_chunk.__toESM(require("node:events"));
2
+ let node_events = require("node:events");
3
+ node_events = require_chunk.__toESM(node_events);
3
4
 
4
5
  //#region src/events/CommandKitEventsChannel.ts
5
6
  /**
@@ -84,4 +85,4 @@ Object.defineProperty(exports, 'CommandKitEventsChannel', {
84
85
  return CommandKitEventsChannel;
85
86
  }
86
87
  });
87
- //# sourceMappingURL=CommandKitEventsChannel-Bgw0XCOl.js.map
88
+ //# sourceMappingURL=CommandKitEventsChannel-B5vbINtP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandKitEventsChannel-Bgw0XCOl.js","names":[],"sources":["../src/events/CommandKitEventsChannel.ts"],"sourcesContent":["import EventEmitter from 'node:events';\nimport type { CommandKit } from '../commandkit';\nimport type { AsyncFunction, GenericFunction } from '../context/async-context';\n\n/**\n * The function type for event listeners.\n */\nexport type ListenerFunction = GenericFunction | AsyncFunction;\n\n/**\n * Represents a channel for emitting and listening to events in CommandKit.\n * This class provides methods to manage event listeners and emit events\n * within a specific namespace.\n */\nexport class CommandKitEventsChannel {\n private emitter = new EventEmitter();\n\n /**\n * Creates a new instance of CommandKitEventsChannel.\n * @param commandkit The CommandKit instance that this channel belongs to.\n */\n public constructor(public readonly commandkit: CommandKit) {}\n\n /**\n * Creates a namespaced event channel. This allows you to manage events\n * within a specific namespace, preventing conflicts with other event channels.\n * This is useful for organizing events related to different parts of your application.\n * @param namespace The namespace for the event channel.\n * @returns An object containing methods for managing events within the namespace.\n * @example commandkit.events.to('customNamespace').emit('eventName', data);\n */\n public to(namespace: string) {\n return {\n on: this.on.bind(this, namespace),\n off: this.off.bind(this, namespace),\n once: this.once.bind(this, namespace),\n emit: this.emit.bind(this, namespace),\n removeAllListeners: this.removeAllListeners.bind(this, namespace),\n };\n }\n\n /**\n * Register an event listener for a specific event within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to listen for.\n * @param listener The function to call when the event is emitted.\n */\n public on(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.on(`${namespace}:${event}`, listener);\n }\n\n /**\n * Unregister an event listener for a specific event within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to stop listening for.\n * @param listener The function that was registered as the listener.\n */\n public off(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.off(`${namespace}:${event}`, listener);\n }\n\n /**\n * Register an event listener that will be called only once for a specific event\n * within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to listen for.\n * @param listener The function to call when the event is emitted.\n */\n public once(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.once(`${namespace}:${event}`, listener);\n }\n\n /**\n * Emit an event within the specified namespace, calling all registered listeners.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to emit.\n * @param args The arguments to pass to the listeners.\n * @returns A boolean indicating whether any listeners were called.\n */\n public emit(namespace: string, event: string, ...args: any[]) {\n return this.emitter.emit(`${namespace}:${event}`, ...args);\n }\n\n /**\n * Remove all listeners for a specific event or all events within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to remove listeners for. If not provided, all listeners for all events in the namespace will be removed.\n */\n public removeAllListeners(namespace: string): void;\n public removeAllListeners(namespace: string, event: string): void;\n public removeAllListeners(namespace: string, event?: string): void {\n if (event) {\n this.emitter.removeAllListeners(`${namespace}:${event}`);\n } else {\n this.emitter.removeAllListeners(namespace);\n }\n }\n}\n"],"mappings":";;;;;;;;;AAcA,IAAa,0BAAb,MAAqC;CACnC,AAAQ,UAAU,IAAI;;;;;CAMtB,AAAO,YAAY,AAAgB,YAAwB;EAAxB;;;;;;;;;;CAUnC,AAAO,GAAG,WAAmB;AAC3B,SAAO;GACL,IAAI,KAAK,GAAG,KAAK,MAAM;GACvB,KAAK,KAAK,IAAI,KAAK,MAAM;GACzB,MAAM,KAAK,KAAK,KAAK,MAAM;GAC3B,MAAM,KAAK,KAAK,KAAK,MAAM;GAC3B,oBAAoB,KAAK,mBAAmB,KAAK,MAAM;;;;;;;;;CAU3D,AAAO,GAAG,WAAmB,OAAe,UAA4B;AACtE,OAAK,QAAQ,GAAG,GAAG,UAAU,GAAG,SAAS;;;;;;;;CAS3C,AAAO,IAAI,WAAmB,OAAe,UAA4B;AACvE,OAAK,QAAQ,IAAI,GAAG,UAAU,GAAG,SAAS;;;;;;;;;CAU5C,AAAO,KAAK,WAAmB,OAAe,UAA4B;AACxE,OAAK,QAAQ,KAAK,GAAG,UAAU,GAAG,SAAS;;;;;;;;;CAU7C,AAAO,KAAK,WAAmB,OAAe,GAAG,MAAa;AAC5D,SAAO,KAAK,QAAQ,KAAK,GAAG,UAAU,GAAG,SAAS,GAAG;;CAUvD,AAAO,mBAAmB,WAAmB,OAAsB;AACjE,MAAI,MACF,MAAK,QAAQ,mBAAmB,GAAG,UAAU,GAAG;MAEhD,MAAK,QAAQ,mBAAmB"}
1
+ {"version":3,"file":"CommandKitEventsChannel-B5vbINtP.js","names":[],"sources":["../src/events/CommandKitEventsChannel.ts"],"sourcesContent":["import EventEmitter from 'node:events';\nimport type { CommandKit } from '../commandkit';\nimport type { AsyncFunction, GenericFunction } from '../context/async-context';\n\n/**\n * The function type for event listeners.\n */\nexport type ListenerFunction = GenericFunction | AsyncFunction;\n\n/**\n * Represents a channel for emitting and listening to events in CommandKit.\n * This class provides methods to manage event listeners and emit events\n * within a specific namespace.\n */\nexport class CommandKitEventsChannel {\n private emitter = new EventEmitter();\n\n /**\n * Creates a new instance of CommandKitEventsChannel.\n * @param commandkit The CommandKit instance that this channel belongs to.\n */\n public constructor(public readonly commandkit: CommandKit) {}\n\n /**\n * Creates a namespaced event channel. This allows you to manage events\n * within a specific namespace, preventing conflicts with other event channels.\n * This is useful for organizing events related to different parts of your application.\n * @param namespace The namespace for the event channel.\n * @returns An object containing methods for managing events within the namespace.\n * @example commandkit.events.to('customNamespace').emit('eventName', data);\n */\n public to(namespace: string) {\n return {\n on: this.on.bind(this, namespace),\n off: this.off.bind(this, namespace),\n once: this.once.bind(this, namespace),\n emit: this.emit.bind(this, namespace),\n removeAllListeners: this.removeAllListeners.bind(this, namespace),\n };\n }\n\n /**\n * Register an event listener for a specific event within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to listen for.\n * @param listener The function to call when the event is emitted.\n */\n public on(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.on(`${namespace}:${event}`, listener);\n }\n\n /**\n * Unregister an event listener for a specific event within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to stop listening for.\n * @param listener The function that was registered as the listener.\n */\n public off(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.off(`${namespace}:${event}`, listener);\n }\n\n /**\n * Register an event listener that will be called only once for a specific event\n * within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to listen for.\n * @param listener The function to call when the event is emitted.\n */\n public once(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.once(`${namespace}:${event}`, listener);\n }\n\n /**\n * Emit an event within the specified namespace, calling all registered listeners.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to emit.\n * @param args The arguments to pass to the listeners.\n * @returns A boolean indicating whether any listeners were called.\n */\n public emit(namespace: string, event: string, ...args: any[]) {\n return this.emitter.emit(`${namespace}:${event}`, ...args);\n }\n\n /**\n * Remove all listeners for a specific event or all events within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to remove listeners for. If not provided, all listeners for all events in the namespace will be removed.\n */\n public removeAllListeners(namespace: string): void;\n public removeAllListeners(namespace: string, event: string): void;\n public removeAllListeners(namespace: string, event?: string): void {\n if (event) {\n this.emitter.removeAllListeners(`${namespace}:${event}`);\n } else {\n this.emitter.removeAllListeners(namespace);\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAcA,IAAa,0BAAb,MAAqC;CACnC,AAAQ,UAAU,IAAI,qBAAc;;;;;CAMpC,AAAO,YAAY,AAAgB,YAAwB;EAAxB;;;;;;;;;;CAUnC,AAAO,GAAG,WAAmB;AAC3B,SAAO;GACL,IAAI,KAAK,GAAG,KAAK,MAAM,UAAU;GACjC,KAAK,KAAK,IAAI,KAAK,MAAM,UAAU;GACnC,MAAM,KAAK,KAAK,KAAK,MAAM,UAAU;GACrC,MAAM,KAAK,KAAK,KAAK,MAAM,UAAU;GACrC,oBAAoB,KAAK,mBAAmB,KAAK,MAAM,UAAU;GAClE;;;;;;;;CASH,AAAO,GAAG,WAAmB,OAAe,UAA4B;AACtE,OAAK,QAAQ,GAAG,GAAG,UAAU,GAAG,SAAS,SAAS;;;;;;;;CASpD,AAAO,IAAI,WAAmB,OAAe,UAA4B;AACvE,OAAK,QAAQ,IAAI,GAAG,UAAU,GAAG,SAAS,SAAS;;;;;;;;;CAUrD,AAAO,KAAK,WAAmB,OAAe,UAA4B;AACxE,OAAK,QAAQ,KAAK,GAAG,UAAU,GAAG,SAAS,SAAS;;;;;;;;;CAUtD,AAAO,KAAK,WAAmB,OAAe,GAAG,MAAa;AAC5D,SAAO,KAAK,QAAQ,KAAK,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK;;CAU5D,AAAO,mBAAmB,WAAmB,OAAsB;AACjE,MAAI,MACF,MAAK,QAAQ,mBAAmB,GAAG,UAAU,GAAG,QAAQ;MAExD,MAAK,QAAQ,mBAAmB,UAAU"}
@@ -1,8 +1,12 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const discord_js = require_chunk.__toESM(require("discord.js"));
3
- const node_fs = require_chunk.__toESM(require("node:fs"));
4
- const node_path = require_chunk.__toESM(require("node:path"));
5
- const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
2
+ let discord_js = require("discord.js");
3
+ discord_js = require_chunk.__toESM(discord_js);
4
+ let node_fs = require("node:fs");
5
+ node_fs = require_chunk.__toESM(node_fs);
6
+ let node_path = require("node:path");
7
+ node_path = require_chunk.__toESM(node_path);
8
+ let node_fs_promises = require("node:fs/promises");
9
+ node_fs_promises = require_chunk.__toESM(node_fs_promises);
6
10
 
7
11
  //#region src/app/router/CommandsRouter.ts
8
12
  /**
@@ -202,8 +206,7 @@ var CommandsRouter = class {
202
206
  * @internal
203
207
  */
204
208
  replaceEntrypoint(path) {
205
- const normalized = (0, node_path.normalize)(path);
206
- return normalized.replace(this.options.entrypoint, "");
209
+ return (0, node_path.normalize)(path).replace(this.options.entrypoint, "");
207
210
  }
208
211
  };
209
212
 
@@ -214,4 +217,4 @@ Object.defineProperty(exports, 'CommandsRouter', {
214
217
  return CommandsRouter;
215
218
  }
216
219
  });
217
- //# sourceMappingURL=CommandsRouter-tMAivEfv.js.map
220
+ //# sourceMappingURL=CommandsRouter-DZAeB2v_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandsRouter-tMAivEfv.js","names":[],"sources":["../src/app/router/CommandsRouter.ts"],"sourcesContent":["import { Collection } from 'discord.js';\nimport { Dirent, existsSync } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { basename, extname, join, normalize } from 'node:path';\n\n/**\n * Represents a command with its metadata and middleware associations.\n */\nexport interface Command {\n id: string;\n name: string;\n path: string;\n relativePath: string;\n parentPath: string;\n middlewares: Array<string>;\n category: string | null;\n}\n\n/**\n * Represents a middleware with its metadata and scope.\n */\nexport interface Middleware {\n id: string;\n name: string;\n path: string;\n relativePath: string;\n parentPath: string;\n global: boolean;\n command: string | null;\n}\n\n/**\n * Data structure containing parsed commands and middleware.\n */\nexport interface ParsedCommandData {\n commands: Record<string, Command>;\n middlewares: Record<string, Middleware>;\n}\n\n/**\n * Configuration options for the commands router.\n */\nexport interface CommandsRouterOptions {\n entrypoint: string;\n}\n\n/**\n * @private\n * @internal\n */\nconst MIDDLEWARE_PATTERN = /^\\+middleware\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst COMMAND_MIDDLEWARE_PATTERN =\n /^\\+([^+().][^().]*)\\.middleware\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst GLOBAL_MIDDLEWARE_PATTERN = /^\\+global-middleware\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst COMMAND_PATTERN = /^([^+().][^().]*)\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst CATEGORY_PATTERN = /^\\(.+\\)$/;\n\n/**\n * Handles discovery and parsing of command and middleware files in the filesystem.\n */\nexport class CommandsRouter {\n /**\n * @private\n * @internal\n */\n private commands = new Collection<string, Command>();\n\n /**\n * @private\n * @internal\n */\n private middlewares = new Collection<string, Middleware>();\n\n /**\n * Creates a new CommandsRouter instance.\n * @param options - Configuration options for the router\n */\n public constructor(private readonly options: CommandsRouterOptions) {}\n\n /**\n * Populates the router with existing command and middleware data.\n * @param data - Parsed command data to populate with\n */\n public populate(data: ParsedCommandData) {\n for (const [id, command] of Object.entries(data.commands)) {\n this.commands.set(id, command);\n }\n\n for (const [id, middleware] of Object.entries(data.middlewares)) {\n this.middlewares.set(id, middleware);\n }\n }\n\n /**\n * Checks if the configured entrypoint path exists.\n * @returns True if the path exists\n */\n public isValidPath(): boolean {\n return existsSync(this.options.entrypoint);\n }\n\n /**\n * @private\n * @internal\n */\n private isCommand(name: string): boolean {\n return COMMAND_PATTERN.test(name);\n }\n\n /**\n * @private\n * @internal\n */\n private isMiddleware(name: string): boolean {\n return (\n MIDDLEWARE_PATTERN.test(name) ||\n GLOBAL_MIDDLEWARE_PATTERN.test(name) ||\n COMMAND_MIDDLEWARE_PATTERN.test(name)\n );\n }\n\n /**\n * @private\n * @internal\n */\n private isCategory(name: string): boolean {\n return CATEGORY_PATTERN.test(name);\n }\n\n /**\n * Clears all loaded commands and middleware.\n */\n public clear() {\n this.commands.clear();\n this.middlewares.clear();\n }\n\n /**\n * Scans the filesystem for commands and middleware files.\n * @returns Parsed command data\n */\n public async scan() {\n const entries = await readdir(this.options.entrypoint, {\n withFileTypes: true,\n });\n\n for (const entry of entries) {\n // ignore _ prefixed files\n if (entry.name.startsWith('_')) continue;\n\n const fullPath = join(this.options.entrypoint, entry.name);\n\n if (entry.isDirectory()) {\n const category = this.isCategory(entry.name)\n ? entry.name.slice(1, -1)\n : null;\n\n await this.traverse(fullPath, category);\n } else {\n await this.handle(entry);\n }\n }\n\n await this.applyMiddlewares();\n\n return this.toJSON();\n }\n\n /**\n * Gets the raw command and middleware collections.\n * @returns Object containing commands and middlewares collections\n */\n public getData() {\n return {\n commands: this.commands,\n middlewares: this.middlewares,\n };\n }\n\n /**\n * Converts the loaded data to a JSON-serializable format.\n * @returns Plain object with commands and middlewares\n */\n public toJSON() {\n return {\n commands: Object.fromEntries(this.commands.entries()),\n middlewares: Object.fromEntries(this.middlewares.entries()),\n };\n }\n\n /**\n * @private\n * @internal\n */\n private async traverse(path: string, category: string | null) {\n const entries = await readdir(path, {\n withFileTypes: true,\n });\n\n for (const entry of entries) {\n // ignore _ prefixed files\n if (entry.name.startsWith('_')) continue;\n\n if (entry.isFile()) {\n if (this.isCommand(entry.name) || this.isMiddleware(entry.name)) {\n await this.handle(entry, category);\n }\n } else if (\n entry.isDirectory() &&\n this.isCategory(entry.name) &&\n category\n ) {\n // nested category\n const nestedCategory = this.isCategory(entry.name)\n ? `${category}:${entry.name.slice(1, -1)}`\n : null;\n await this.traverse(join(path, entry.name), nestedCategory);\n }\n\n // TODO: handle subcommands\n }\n }\n\n /**\n * @private\n * @internal\n */\n private async handle(entry: Dirent, category: string | null = null) {\n const name = entry.name;\n const path = join(entry.parentPath, entry.name);\n\n if (this.isCommand(name)) {\n const command: Command = {\n id: crypto.randomUUID(),\n name: basename(path, extname(path)),\n path,\n category,\n parentPath: entry.parentPath,\n relativePath: this.replaceEntrypoint(path),\n middlewares: [],\n };\n\n this.commands.set(command.id, command);\n } else if (this.isMiddleware(name)) {\n const middleware: Middleware = {\n id: crypto.randomUUID(),\n name: basename(path, extname(path)),\n path,\n relativePath: this.replaceEntrypoint(path),\n parentPath: entry.parentPath,\n global: GLOBAL_MIDDLEWARE_PATTERN.test(name),\n command: COMMAND_MIDDLEWARE_PATTERN.test(name)\n ? name.match(COMMAND_MIDDLEWARE_PATTERN)?.[1] || null\n : null,\n };\n\n this.middlewares.set(middleware.id, middleware);\n }\n }\n\n /**\n * @private\n * @internal\n */\n private applyMiddlewares() {\n this.commands.forEach((command) => {\n const commandPath = command.parentPath;\n const allMiddlewares = Array.from(this.middlewares.values());\n\n const commandSpecificMiddlewares = allMiddlewares\n .filter((middleware) => middleware.command === command.name)\n .map((middleware) => middleware.id);\n\n const directorySpecificMiddlewares = allMiddlewares\n .filter(\n (middleware) =>\n !middleware.global &&\n !middleware.command &&\n middleware.parentPath === commandPath,\n )\n .map((middleware) => middleware.id);\n\n const globalMiddlewares = allMiddlewares\n .filter((middleware) => middleware.global)\n .map((middleware) => middleware.id);\n\n command.middlewares = [\n ...commandSpecificMiddlewares,\n ...directorySpecificMiddlewares,\n ...globalMiddlewares,\n ];\n });\n }\n\n /**\n * @private\n * @internal\n */\n private replaceEntrypoint(path: string) {\n const normalized = normalize(path);\n return normalized.replace(this.options.entrypoint, '');\n }\n}\n"],"mappings":";;;;;;;;;;;AAkDA,MAAM,qBAAqB;;;;;AAM3B,MAAM,6BACN;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GAEnD,MAAM,6BAA6B,eACnC,QAAQ,eAAe,WAAW,YAAY,QAAQ,MACtD,KAAK,eAAe,WAAW;GAE/B,MAAM,+BAA+B,eACrC,QACG,eACD,CAAC,WAAW,UACZ,CAAC,WAAW,WACZ,WAAW,eAAe,aAE5B,KAAK,eAAe,WAAW;GAE/B,MAAM,oBAAoB,eAC1B,QAAQ,eAAe,WAAW,QAClC,KAAK,eAAe,WAAW;AAE/B,WAAQ,cAAc;IACtB,GAAG;IACH,GAAG;IACH,GAAG;;;;;;;;CASP,AAAQ,kBAAkB,MAAc;EACtC,MAAM,sCAAuB;AAC7B,SAAO,WAAW,QAAQ,KAAK,QAAQ,YAAY"}
1
+ {"version":3,"file":"CommandsRouter-DZAeB2v_.js","names":[],"sources":["../src/app/router/CommandsRouter.ts"],"sourcesContent":["import { Collection } from 'discord.js';\nimport { Dirent, existsSync } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { basename, extname, join, normalize } from 'node:path';\n\n/**\n * Represents a command with its metadata and middleware associations.\n */\nexport interface Command {\n id: string;\n name: string;\n path: string;\n relativePath: string;\n parentPath: string;\n middlewares: Array<string>;\n category: string | null;\n}\n\n/**\n * Represents a middleware with its metadata and scope.\n */\nexport interface Middleware {\n id: string;\n name: string;\n path: string;\n relativePath: string;\n parentPath: string;\n global: boolean;\n command: string | null;\n}\n\n/**\n * Data structure containing parsed commands and middleware.\n */\nexport interface ParsedCommandData {\n commands: Record<string, Command>;\n middlewares: Record<string, Middleware>;\n}\n\n/**\n * Configuration options for the commands router.\n */\nexport interface CommandsRouterOptions {\n entrypoint: string;\n}\n\n/**\n * @private\n * @internal\n */\nconst MIDDLEWARE_PATTERN = /^\\+middleware\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst COMMAND_MIDDLEWARE_PATTERN =\n /^\\+([^+().][^().]*)\\.middleware\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst GLOBAL_MIDDLEWARE_PATTERN = /^\\+global-middleware\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst COMMAND_PATTERN = /^([^+().][^().]*)\\.(m|c)?(j|t)sx?$/;\n\n/**\n * @private\n * @internal\n */\nconst CATEGORY_PATTERN = /^\\(.+\\)$/;\n\n/**\n * Handles discovery and parsing of command and middleware files in the filesystem.\n */\nexport class CommandsRouter {\n /**\n * @private\n * @internal\n */\n private commands = new Collection<string, Command>();\n\n /**\n * @private\n * @internal\n */\n private middlewares = new Collection<string, Middleware>();\n\n /**\n * Creates a new CommandsRouter instance.\n * @param options - Configuration options for the router\n */\n public constructor(private readonly options: CommandsRouterOptions) {}\n\n /**\n * Populates the router with existing command and middleware data.\n * @param data - Parsed command data to populate with\n */\n public populate(data: ParsedCommandData) {\n for (const [id, command] of Object.entries(data.commands)) {\n this.commands.set(id, command);\n }\n\n for (const [id, middleware] of Object.entries(data.middlewares)) {\n this.middlewares.set(id, middleware);\n }\n }\n\n /**\n * Checks if the configured entrypoint path exists.\n * @returns True if the path exists\n */\n public isValidPath(): boolean {\n return existsSync(this.options.entrypoint);\n }\n\n /**\n * @private\n * @internal\n */\n private isCommand(name: string): boolean {\n return COMMAND_PATTERN.test(name);\n }\n\n /**\n * @private\n * @internal\n */\n private isMiddleware(name: string): boolean {\n return (\n MIDDLEWARE_PATTERN.test(name) ||\n GLOBAL_MIDDLEWARE_PATTERN.test(name) ||\n COMMAND_MIDDLEWARE_PATTERN.test(name)\n );\n }\n\n /**\n * @private\n * @internal\n */\n private isCategory(name: string): boolean {\n return CATEGORY_PATTERN.test(name);\n }\n\n /**\n * Clears all loaded commands and middleware.\n */\n public clear() {\n this.commands.clear();\n this.middlewares.clear();\n }\n\n /**\n * Scans the filesystem for commands and middleware files.\n * @returns Parsed command data\n */\n public async scan() {\n const entries = await readdir(this.options.entrypoint, {\n withFileTypes: true,\n });\n\n for (const entry of entries) {\n // ignore _ prefixed files\n if (entry.name.startsWith('_')) continue;\n\n const fullPath = join(this.options.entrypoint, entry.name);\n\n if (entry.isDirectory()) {\n const category = this.isCategory(entry.name)\n ? entry.name.slice(1, -1)\n : null;\n\n await this.traverse(fullPath, category);\n } else {\n await this.handle(entry);\n }\n }\n\n await this.applyMiddlewares();\n\n return this.toJSON();\n }\n\n /**\n * Gets the raw command and middleware collections.\n * @returns Object containing commands and middlewares collections\n */\n public getData() {\n return {\n commands: this.commands,\n middlewares: this.middlewares,\n };\n }\n\n /**\n * Converts the loaded data to a JSON-serializable format.\n * @returns Plain object with commands and middlewares\n */\n public toJSON() {\n return {\n commands: Object.fromEntries(this.commands.entries()),\n middlewares: Object.fromEntries(this.middlewares.entries()),\n };\n }\n\n /**\n * @private\n * @internal\n */\n private async traverse(path: string, category: string | null) {\n const entries = await readdir(path, {\n withFileTypes: true,\n });\n\n for (const entry of entries) {\n // ignore _ prefixed files\n if (entry.name.startsWith('_')) continue;\n\n if (entry.isFile()) {\n if (this.isCommand(entry.name) || this.isMiddleware(entry.name)) {\n await this.handle(entry, category);\n }\n } else if (\n entry.isDirectory() &&\n this.isCategory(entry.name) &&\n category\n ) {\n // nested category\n const nestedCategory = this.isCategory(entry.name)\n ? `${category}:${entry.name.slice(1, -1)}`\n : null;\n await this.traverse(join(path, entry.name), nestedCategory);\n }\n\n // TODO: handle subcommands\n }\n }\n\n /**\n * @private\n * @internal\n */\n private async handle(entry: Dirent, category: string | null = null) {\n const name = entry.name;\n const path = join(entry.parentPath, entry.name);\n\n if (this.isCommand(name)) {\n const command: Command = {\n id: crypto.randomUUID(),\n name: basename(path, extname(path)),\n path,\n category,\n parentPath: entry.parentPath,\n relativePath: this.replaceEntrypoint(path),\n middlewares: [],\n };\n\n this.commands.set(command.id, command);\n } else if (this.isMiddleware(name)) {\n const middleware: Middleware = {\n id: crypto.randomUUID(),\n name: basename(path, extname(path)),\n path,\n relativePath: this.replaceEntrypoint(path),\n parentPath: entry.parentPath,\n global: GLOBAL_MIDDLEWARE_PATTERN.test(name),\n command: COMMAND_MIDDLEWARE_PATTERN.test(name)\n ? name.match(COMMAND_MIDDLEWARE_PATTERN)?.[1] || null\n : null,\n };\n\n this.middlewares.set(middleware.id, middleware);\n }\n }\n\n /**\n * @private\n * @internal\n */\n private applyMiddlewares() {\n this.commands.forEach((command) => {\n const commandPath = command.parentPath;\n const allMiddlewares = Array.from(this.middlewares.values());\n\n const commandSpecificMiddlewares = allMiddlewares\n .filter((middleware) => middleware.command === command.name)\n .map((middleware) => middleware.id);\n\n const directorySpecificMiddlewares = allMiddlewares\n .filter(\n (middleware) =>\n !middleware.global &&\n !middleware.command &&\n middleware.parentPath === commandPath,\n )\n .map((middleware) => middleware.id);\n\n const globalMiddlewares = allMiddlewares\n .filter((middleware) => middleware.global)\n .map((middleware) => middleware.id);\n\n command.middlewares = [\n ...commandSpecificMiddlewares,\n ...directorySpecificMiddlewares,\n ...globalMiddlewares,\n ];\n });\n }\n\n /**\n * @private\n * @internal\n */\n private replaceEntrypoint(path: string) {\n const normalized = normalize(path);\n return normalized.replace(this.options.entrypoint, '');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAM,qBAAqB;;;;;AAM3B,MAAM,6BACN;;;;;AAMA,MAAM,4BAA4B;;;;;AAMlC,MAAM,kBAAkB;;;;;AAMxB,MAAM,mBAAmB;;;;AAKzB,IAAa,iBAAb,MAA4B;;;;;CAK1B,AAAQ,WAAW,IAAI,uBAA6B;;;;;CAMpD,AAAQ,cAAc,IAAI,uBAAgC;;;;;CAM1D,AAAO,YAAY,AAAiB,SAAgC;EAAhC;;;;;;CAMpC,AAAO,SAAS,MAAyB;AACvC,OAAK,MAAM,CAAC,IAAI,YAAY,OAAO,QAAQ,KAAK,SAAS,CACvD,MAAK,SAAS,IAAI,IAAI,QAAQ;AAGhC,OAAK,MAAM,CAAC,IAAI,eAAe,OAAO,QAAQ,KAAK,YAAY,CAC7D,MAAK,YAAY,IAAI,IAAI,WAAW;;;;;;CAQxC,AAAO,cAAuB;AAC5B,iCAAkB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ElC,MAAM,+BAA+B,eACrC,QACG,eACD,CAAC,WAAW,UACZ,CAAC,WAAW,WACZ,WAAW,eAAe,YAC3B,CACD,KAAK,eAAe,WAAW,GAAG;GAElC,MAAM,oBAAoB,eAC1B,QAAQ,eAAe,WAAW,OAAO,CACzC,KAAK,eAAe,WAAW,GAAG;AAElC,WAAQ,cAAc;IACtB,GAAG;IACH,GAAG;IACH,GAAG;IAAkB;IAErB;;;;;;CAOJ,AAAQ,kBAAkB,MAAc;AAEtC,kCAD6B,KAAK,CAChB,QAAQ,KAAK,QAAQ,YAAY,GAAG"}
@@ -1,4 +1,4 @@
1
- const require_PluginCommon = require('./PluginCommon-Di1xIa8d.js');
1
+ const require_PluginCommon = require('./PluginCommon-Cvl5yYM_.js');
2
2
 
3
3
  //#region src/plugins/CompilerPlugin.ts
4
4
  /**
@@ -40,4 +40,4 @@ Object.defineProperty(exports, 'isCompilerPlugin', {
40
40
  return isCompilerPlugin;
41
41
  }
42
42
  });
43
- //# sourceMappingURL=CompilerPlugin-CjoZAAR8.js.map
43
+ //# sourceMappingURL=CompilerPlugin-M8r3yNAl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompilerPlugin-CjoZAAR8.js","names":[],"sources":["../src/plugins/CompilerPlugin.ts"],"sourcesContent":["import {\n isPlugin,\n PluginCommon,\n PluginOptions,\n PluginType,\n} from './PluginCommon';\nimport { MaybeFalsey } from './types';\nimport { CompilerPluginRuntime } from './plugin-runtime/CompilerPluginRuntime';\n\n/**\n * The parameters for the transformation function of a compiler plugin.\n */\nexport interface PluginTransformParameters {\n /**\n * The code to be transformed.\n */\n code: string;\n /**\n * The filename of the code being transformed.\n */\n id: string;\n}\n\nexport interface TransformedResult {\n /**\n * The transformed code.\n */\n code?: string;\n /**\n * The source map for the transformed code, if applicable.\n */\n map?: string | null;\n}\n\n/**\n * CommandKit plugin that runs at compile time.\n */\nexport abstract class CompilerPlugin<\n T extends PluginOptions = PluginOptions,\n> extends PluginCommon<T, CompilerPluginRuntime> {\n /**\n * The type of the plugin, which is Compiler.\n */\n public readonly type = PluginType.Compiler;\n\n /**\n * Called when transformation is requested to this plugin\n * @param params The parameters for the transformation\n * @returns The transformed result\n */\n public async transform(\n params: PluginTransformParameters,\n ): Promise<MaybeFalsey<TransformedResult>> {\n return null;\n }\n}\n\n/**\n * Type guard to check if the given object is a CompilerPlugin.\n * @param plugin The object to check.\n * @returns Boolean indicating whether the object is a CompilerPlugin.\n */\nexport function isCompilerPlugin(plugin: unknown): plugin is CompilerPlugin {\n return (\n plugin instanceof CompilerPlugin ||\n (isPlugin(plugin) && plugin.type === PluginType.Compiler)\n );\n}\n"],"mappings":";;;;;;AAqCA,IAAsB,iBAAtB,cAEA,kCAAuC;;;;CAIrC,AAAgB,OAAO,gCAAW;;;;;;CAOlC,MAAa,UACb,QAC0C;AACxC,SAAO;;;;;;;;AASX,SAAgB,iBAAiB,QAA2C;AAC1E,QACE,kBAAkB,kBAClB,8BAAS,WAAW,OAAO,SAAS,gCAAW"}
1
+ {"version":3,"file":"CompilerPlugin-M8r3yNAl.js","names":[],"sources":["../src/plugins/CompilerPlugin.ts"],"sourcesContent":["import {\n isPlugin,\n PluginCommon,\n PluginOptions,\n PluginType,\n} from './PluginCommon';\nimport { MaybeFalsey } from './types';\nimport { CompilerPluginRuntime } from './plugin-runtime/CompilerPluginRuntime';\n\n/**\n * The parameters for the transformation function of a compiler plugin.\n */\nexport interface PluginTransformParameters {\n /**\n * The code to be transformed.\n */\n code: string;\n /**\n * The filename of the code being transformed.\n */\n id: string;\n}\n\nexport interface TransformedResult {\n /**\n * The transformed code.\n */\n code?: string;\n /**\n * The source map for the transformed code, if applicable.\n */\n map?: string | null;\n}\n\n/**\n * CommandKit plugin that runs at compile time.\n */\nexport abstract class CompilerPlugin<\n T extends PluginOptions = PluginOptions,\n> extends PluginCommon<T, CompilerPluginRuntime> {\n /**\n * The type of the plugin, which is Compiler.\n */\n public readonly type = PluginType.Compiler;\n\n /**\n * Called when transformation is requested to this plugin\n * @param params The parameters for the transformation\n * @returns The transformed result\n */\n public async transform(\n params: PluginTransformParameters,\n ): Promise<MaybeFalsey<TransformedResult>> {\n return null;\n }\n}\n\n/**\n * Type guard to check if the given object is a CompilerPlugin.\n * @param plugin The object to check.\n * @returns Boolean indicating whether the object is a CompilerPlugin.\n */\nexport function isCompilerPlugin(plugin: unknown): plugin is CompilerPlugin {\n return (\n plugin instanceof CompilerPlugin ||\n (isPlugin(plugin) && plugin.type === PluginType.Compiler)\n );\n}\n"],"mappings":";;;;;;AAqCA,IAAsB,iBAAtB,cAEA,kCAAuC;;;;CAIrC,AAAgB,OAAO,gCAAW;;;;;;CAOlC,MAAa,UACb,QAC0C;AACxC,SAAO;;;;;;;;AASX,SAAgB,iBAAiB,QAA2C;AAC1E,QACE,kBAAkB,kBAClB,8BAAS,OAAO,IAAI,OAAO,SAAS,gCAAW"}
@@ -20,8 +20,7 @@ var EventInterceptor = class {
20
20
  this.cleanupTimer = setInterval(() => {
21
21
  for (const [event, handlers] of this.subscribers) for (const handler of handlers) {
22
22
  const options = Reflect.get(handler, "options");
23
- const isExpired = options.time && Date.now() - options.registeredAt > options.time;
24
- if (isExpired) this.unsubscribe(event, handler, "time");
23
+ if (options.time && Date.now() - options.registeredAt > options.time) this.unsubscribe(event, handler, "time");
25
24
  }
26
25
  }, 6e4).unref();
27
26
  }
@@ -112,8 +111,7 @@ var EventInterceptor = class {
112
111
  const subscribers = this.subscribers.get(event);
113
112
  if (subscribers && subscribers.size > 0) for (const subscriber of subscribers) {
114
113
  const options = Reflect.get(subscriber, "options");
115
- const isExpired = options.time && Date.now() - options.registeredAt > options.time;
116
- if (isExpired) {
114
+ if (options.time && Date.now() - options.registeredAt > options.time) {
117
115
  this.unsubscribe(event, subscriber, "time");
118
116
  continue;
119
117
  }
@@ -141,4 +139,4 @@ Object.defineProperty(exports, 'EventInterceptor', {
141
139
  return EventInterceptor;
142
140
  }
143
141
  });
144
- //# sourceMappingURL=EventInterceptor-CQ4PBpBJ.js.map
142
+ //# sourceMappingURL=EventInterceptor-CQEXyUTp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EventInterceptor-CQ4PBpBJ.js","names":[],"sources":["../src/components/common/EventInterceptor.ts"],"sourcesContent":["import { Awaitable, Client, ClientEvents, Events } from 'discord.js';\n\nexport interface EventInterceptorContextData<E extends keyof ClientEvents> {\n /**\n * The filter to use for the collector.\n */\n filter?: (...args: ClientEvents[E]) => Awaitable<boolean>;\n /**\n * The duration (in ms) that the collector should run for.\n */\n time?: number;\n /**\n * If the collector should automatically reset the timer when a button is clicked.\n */\n autoReset?: boolean;\n /**\n * Whether the collector should run only once.\n */\n once?: boolean;\n /**\n * The handler to run when the collector ends.\n */\n onEnd?: (reason: string) => Awaitable<void>;\n /**\n * The handler to run upon an error.\n */\n onError?: EventInterceptorErrorHandler;\n}\n\n/**\n * The error handler for the event interceptor.\n */\nexport type EventInterceptorErrorHandler = (error: Error) => Awaitable<void>;\n\n/**\n * The event interceptor class that allows subscribing to events and handling them with custom logic.\n * It also supports automatic cleanup of expired subscriptions.\n */\nexport class EventInterceptor {\n private subscribers = new Map<\n keyof ClientEvents,\n Set<(...args: any[]) => void>\n >();\n private globalHandlers = new Map<\n keyof ClientEvents,\n (...args: any[]) => void\n >();\n private cleanupTimer: NodeJS.Timeout | null = null;\n\n /**\n * Creates the event interceptor.\n */\n public constructor(public readonly client: Client) {\n this.#cleanupLoop();\n }\n\n #cleanupLoop() {\n if (this.cleanupTimer) clearInterval(this.cleanupTimer);\n\n this.cleanupTimer = setInterval(() => {\n for (const [event, handlers] of this.subscribers) {\n for (const handler of handlers) {\n const options = Reflect.get(\n handler,\n 'options',\n ) as EventInterceptorContextData<keyof ClientEvents> & {\n registeredAt: number;\n };\n\n const isExpired =\n options.time && Date.now() - options.registeredAt > options.time;\n\n if (isExpired) {\n this.unsubscribe(event, handler, 'time');\n }\n }\n }\n }, 60_000).unref();\n }\n\n /**\n * Destroys the event interceptor.\n */\n public destroy(): void {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n this.cleanupTimer = null;\n }\n\n for (const [event, handlers] of this.subscribers) {\n for (const handler of handlers) {\n this.unsubscribe(event, handler, 'destroy');\n }\n }\n\n this.subscribers.clear();\n this.globalHandlers.clear();\n }\n\n /**\n * Whether the event has subscribers.\n * @param event The event to check.\n */\n public hasSubscribers(event: keyof ClientEvents): boolean {\n return this.subscribers.has(event);\n }\n\n /**\n * Returns the number of subscribers for the event.\n * @param event The event to check.\n */\n public getSubscriberCount(event: keyof ClientEvents): number {\n const handlers = this.subscribers.get(event);\n return handlers?.size ?? 0;\n }\n\n /**\n * Whether the event has global handlers.\n */\n public hasGlobalHandlers(): boolean {\n return this.globalHandlers.size > 0;\n }\n\n /**\n * Returns the number of global handlers.\n */\n public getGlobalHandlersCount(): number {\n return this.subscribers.size;\n }\n\n /**\n * Subscribes to an event.\n * @param event The event to subscribe to.\n * @param listener The listener to call when the event is emitted.\n * @returns A function to unsubscribe from the event.\n */\n public subscribe<Event extends keyof ClientEvents>(\n event: Event,\n listener: (...args: ClientEvents[Event]) => void,\n options?: EventInterceptorContextData<Event>,\n ): () => void {\n if (!this.subscribers.has(event)) {\n this.subscribers.set(event, new Set());\n this.client.on(event, this.createGlobalHandler(event));\n this.client.setMaxListeners(this.client.getMaxListeners() + 1);\n }\n\n options ??= {};\n\n // @ts-ignore\n options.registeredAt = Date.now();\n\n Reflect.set(listener, 'options', options);\n\n this.subscribers.get(event)!.add(listener);\n\n return () => {\n this.unsubscribe(event, listener);\n };\n }\n\n /**\n * Unsubscribes from an event.\n * @param event The event to unsubscribe from.\n */\n public unsubscribe<Event extends keyof ClientEvents>(\n event: Event,\n listener: (...args: ClientEvents[Event]) => void,\n reason?: string,\n ): void {\n const handlers = this.subscribers.get(event);\n if (!handlers) return;\n\n handlers.delete(listener);\n\n if (handlers.size < 1) {\n this.subscribers.delete(event);\n this.client.removeListener(event, this.globalHandlers.get(event)!);\n this.globalHandlers.delete(event);\n this.client.setMaxListeners(\n Math.max(this.client.getMaxListeners() - 1, 0),\n );\n }\n\n Reflect.get(listener, 'options').onEnd?.(reason ?? 'unsubscribe');\n }\n\n /**\n * Creates a global handler for the event.\n * @param event The event to create a global handler for.\n * @returns The global handler.\n */\n private createGlobalHandler<Event extends keyof ClientEvents>(\n event: Event,\n ): (...args: ClientEvents[Event]) => void {\n if (this.globalHandlers.has(event)) {\n return this.globalHandlers.get(event)!;\n }\n\n const handler = async (...args: ClientEvents[Event]) => {\n const subscribers = this.subscribers.get(event);\n if (subscribers && subscribers.size > 0) {\n for (const subscriber of subscribers) {\n const options = Reflect.get(\n subscriber,\n 'options',\n ) as EventInterceptorContextData<Event> & { registeredAt: number };\n\n const isExpired =\n options.time && Date.now() - options.registeredAt > options.time;\n\n if (isExpired) {\n this.unsubscribe(event, subscriber, 'time');\n continue;\n }\n\n if (options.autoReset) {\n options.registeredAt = Date.now();\n }\n\n if (options.filter && !(await options.filter(...args))) {\n continue;\n }\n\n try {\n await subscriber(...args);\n } catch (e) {\n if (options.onError) {\n await options.onError(<Error>e);\n } else {\n throw e;\n }\n } finally {\n if (options.once) {\n this.unsubscribe(event, subscriber, 'once');\n }\n }\n }\n }\n };\n\n this.globalHandlers.set(event, handler);\n\n return handler;\n }\n}\n"],"mappings":";;;;;;AAsCA,IAAa,mBAAb,MAA8B;CAC5B,AAAQ,8BAAc,IAAI;CAI1B,AAAQ,iCAAiB,IAAI;CAI7B,AAAQ,eAAsC;;;;CAK9C,AAAO,YAAY,AAAgB,QAAgB;EAAhB;AACjC,QAAK;;CAGP,eAAe;AACb,MAAI,KAAK,aAAc,eAAc,KAAK;AAE1C,OAAK,eAAe,kBAAkB;AACpC,QAAK,MAAM,CAAC,OAAO,aAAa,KAAK,YACnC,MAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,UAAU,QAAQ,IACtB,SACA;IAKF,MAAM,YACN,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,eAAe,QAAQ;AAE5D,QAA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AAU,YAAW,0FAAQ,UAAU;;;;;;;CAQrD,AAAQ,oBACR,OACyC;AACvC,MAAI,KAAK,eAAe,IAAI,OAC1B,QAAO,KAAK,eAAe,IAAI;EAGjC,MAAM,UAAU,OAAO,GAAG,SAA8B;GACtD,MAAM,cAAc,KAAK,YAAY,IAAI;AACzC,OAAI,eAAe,YAAY,OAAO,EACpC,MAAK,MAAM,cAAc,aAAa;IACpC,MAAM,UAAU,QAAQ,IACtB,YACA;IAGF,MAAM,YACN,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,eAAe,QAAQ;AAE5D,QAAI,WAAW;AACb,UAAK,YAAY,OAAO,YAAY;AACpC;;AAGF,QAAI,QAAQ,UACV,SAAQ,eAAe,KAAK;AAG9B,QAAI,QAAQ,UAAU,CAAE,MAAM,QAAQ,OAAO,GAAG,MAC9C;AAGF,QAAI;AACF,WAAM,WAAW,GAAG;aACb,GAAG;AACV,SAAI,QAAQ,QACV,OAAM,QAAQ,QAAgB;SAE9B,OAAM;cAEA;AACR,SAAI,QAAQ,KACV,MAAK,YAAY,OAAO,YAAY;;;;AAO9C,OAAK,eAAe,IAAI,OAAO;AAE/B,SAAO"}
1
+ {"version":3,"file":"EventInterceptor-CQEXyUTp.js","names":[],"sources":["../src/components/common/EventInterceptor.ts"],"sourcesContent":["import { Awaitable, Client, ClientEvents, Events } from 'discord.js';\n\nexport interface EventInterceptorContextData<E extends keyof ClientEvents> {\n /**\n * The filter to use for the collector.\n */\n filter?: (...args: ClientEvents[E]) => Awaitable<boolean>;\n /**\n * The duration (in ms) that the collector should run for.\n */\n time?: number;\n /**\n * If the collector should automatically reset the timer when a button is clicked.\n */\n autoReset?: boolean;\n /**\n * Whether the collector should run only once.\n */\n once?: boolean;\n /**\n * The handler to run when the collector ends.\n */\n onEnd?: (reason: string) => Awaitable<void>;\n /**\n * The handler to run upon an error.\n */\n onError?: EventInterceptorErrorHandler;\n}\n\n/**\n * The error handler for the event interceptor.\n */\nexport type EventInterceptorErrorHandler = (error: Error) => Awaitable<void>;\n\n/**\n * The event interceptor class that allows subscribing to events and handling them with custom logic.\n * It also supports automatic cleanup of expired subscriptions.\n */\nexport class EventInterceptor {\n private subscribers = new Map<\n keyof ClientEvents,\n Set<(...args: any[]) => void>\n >();\n private globalHandlers = new Map<\n keyof ClientEvents,\n (...args: any[]) => void\n >();\n private cleanupTimer: NodeJS.Timeout | null = null;\n\n /**\n * Creates the event interceptor.\n */\n public constructor(public readonly client: Client) {\n this.#cleanupLoop();\n }\n\n #cleanupLoop() {\n if (this.cleanupTimer) clearInterval(this.cleanupTimer);\n\n this.cleanupTimer = setInterval(() => {\n for (const [event, handlers] of this.subscribers) {\n for (const handler of handlers) {\n const options = Reflect.get(\n handler,\n 'options',\n ) as EventInterceptorContextData<keyof ClientEvents> & {\n registeredAt: number;\n };\n\n const isExpired =\n options.time && Date.now() - options.registeredAt > options.time;\n\n if (isExpired) {\n this.unsubscribe(event, handler, 'time');\n }\n }\n }\n }, 60_000).unref();\n }\n\n /**\n * Destroys the event interceptor.\n */\n public destroy(): void {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n this.cleanupTimer = null;\n }\n\n for (const [event, handlers] of this.subscribers) {\n for (const handler of handlers) {\n this.unsubscribe(event, handler, 'destroy');\n }\n }\n\n this.subscribers.clear();\n this.globalHandlers.clear();\n }\n\n /**\n * Whether the event has subscribers.\n * @param event The event to check.\n */\n public hasSubscribers(event: keyof ClientEvents): boolean {\n return this.subscribers.has(event);\n }\n\n /**\n * Returns the number of subscribers for the event.\n * @param event The event to check.\n */\n public getSubscriberCount(event: keyof ClientEvents): number {\n const handlers = this.subscribers.get(event);\n return handlers?.size ?? 0;\n }\n\n /**\n * Whether the event has global handlers.\n */\n public hasGlobalHandlers(): boolean {\n return this.globalHandlers.size > 0;\n }\n\n /**\n * Returns the number of global handlers.\n */\n public getGlobalHandlersCount(): number {\n return this.subscribers.size;\n }\n\n /**\n * Subscribes to an event.\n * @param event The event to subscribe to.\n * @param listener The listener to call when the event is emitted.\n * @returns A function to unsubscribe from the event.\n */\n public subscribe<Event extends keyof ClientEvents>(\n event: Event,\n listener: (...args: ClientEvents[Event]) => void,\n options?: EventInterceptorContextData<Event>,\n ): () => void {\n if (!this.subscribers.has(event)) {\n this.subscribers.set(event, new Set());\n this.client.on(event, this.createGlobalHandler(event));\n this.client.setMaxListeners(this.client.getMaxListeners() + 1);\n }\n\n options ??= {};\n\n // @ts-ignore\n options.registeredAt = Date.now();\n\n Reflect.set(listener, 'options', options);\n\n this.subscribers.get(event)!.add(listener);\n\n return () => {\n this.unsubscribe(event, listener);\n };\n }\n\n /**\n * Unsubscribes from an event.\n * @param event The event to unsubscribe from.\n */\n public unsubscribe<Event extends keyof ClientEvents>(\n event: Event,\n listener: (...args: ClientEvents[Event]) => void,\n reason?: string,\n ): void {\n const handlers = this.subscribers.get(event);\n if (!handlers) return;\n\n handlers.delete(listener);\n\n if (handlers.size < 1) {\n this.subscribers.delete(event);\n this.client.removeListener(event, this.globalHandlers.get(event)!);\n this.globalHandlers.delete(event);\n this.client.setMaxListeners(\n Math.max(this.client.getMaxListeners() - 1, 0),\n );\n }\n\n Reflect.get(listener, 'options').onEnd?.(reason ?? 'unsubscribe');\n }\n\n /**\n * Creates a global handler for the event.\n * @param event The event to create a global handler for.\n * @returns The global handler.\n */\n private createGlobalHandler<Event extends keyof ClientEvents>(\n event: Event,\n ): (...args: ClientEvents[Event]) => void {\n if (this.globalHandlers.has(event)) {\n return this.globalHandlers.get(event)!;\n }\n\n const handler = async (...args: ClientEvents[Event]) => {\n const subscribers = this.subscribers.get(event);\n if (subscribers && subscribers.size > 0) {\n for (const subscriber of subscribers) {\n const options = Reflect.get(\n subscriber,\n 'options',\n ) as EventInterceptorContextData<Event> & { registeredAt: number };\n\n const isExpired =\n options.time && Date.now() - options.registeredAt > options.time;\n\n if (isExpired) {\n this.unsubscribe(event, subscriber, 'time');\n continue;\n }\n\n if (options.autoReset) {\n options.registeredAt = Date.now();\n }\n\n if (options.filter && !(await options.filter(...args))) {\n continue;\n }\n\n try {\n await subscriber(...args);\n } catch (e) {\n if (options.onError) {\n await options.onError(<Error>e);\n } else {\n throw e;\n }\n } finally {\n if (options.once) {\n this.unsubscribe(event, subscriber, 'once');\n }\n }\n }\n }\n };\n\n this.globalHandlers.set(event, handler);\n\n return handler;\n }\n}\n"],"mappings":";;;;;;AAsCA,IAAa,mBAAb,MAA8B;CAC5B,AAAQ,8BAAc,IAAI,KAGzB;CACD,AAAQ,iCAAiB,IAAI,KAG5B;CACD,AAAQ,eAAsC;;;;CAK9C,AAAO,YAAY,AAAgB,QAAgB;EAAhB;AACjC,QAAK,aAAc;;CAGrB,eAAe;AACb,MAAI,KAAK,aAAc,eAAc,KAAK,aAAa;AAEvD,OAAK,eAAe,kBAAkB;AACpC,QAAK,MAAM,CAAC,OAAO,aAAa,KAAK,YACnC,MAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,UAAU,QAAQ,IACtB,SACA,UACD;AAOD,QAFA,QAAQ,QAAQ,KAAK,KAAK,GAAG,QAAQ,eAAe,QAAQ,KAG1D,MAAK,YAAY,OAAO,SAAS,OAAO;;KAI7C,IAAO,CAAC,OAAO;;;;;CAMpB,AAAO,UAAgB;AACrB,MAAI,KAAK,cAAc;AACrB,iBAAc,KAAK,aAAa;AAChC,QAAK,eAAe;;AAGtB,OAAK,MAAM,CAAC,OAAO,aAAa,KAAK,YACnC,MAAK,MAAM,WAAW,SACpB,MAAK,YAAY,OAAO,SAAS,UAAU;AAI/C,OAAK,YAAY,OAAO;AACxB,OAAK,eAAe,OAAO;;;;;;CAO7B,AAAO,eAAe,OAAoC;AACxD,SAAO,KAAK,YAAY,IAAI,MAAM;;;;;;CAOpC,AAAO,mBAAmB,OAAmC;EAC3D,MAAM,WAAW,KAAK,YAAY,IAAI,MAAM;AAC5C,8DAAO,SAAU,SAAQ;;;;;CAM3B,AAAO,oBAA6B;AAClC,SAAO,KAAK,eAAe,OAAO;;;;;CAMpC,AAAO,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,eAAe,QAAQ,MAE7C;AACb,UAAK,YAAY,OAAO,YAAY,OAAO;AAC3C;;AAGF,QAAI,QAAQ,UACV,SAAQ,eAAe,KAAK,KAAK;AAGnC,QAAI,QAAQ,UAAU,CAAE,MAAM,QAAQ,OAAO,GAAG,KAAK,CACnD;AAGF,QAAI;AACF,WAAM,WAAW,GAAG,KAAK;aAClB,GAAG;AACV,SAAI,QAAQ,QACV,OAAM,QAAQ,QAAgB,EAAC;SAE/B,OAAM;cAEA;AACR,SAAI,QAAQ,KACV,MAAK,YAAY,OAAO,YAAY,OAAO;;;;AAOrD,OAAK,eAAe,IAAI,OAAO,QAAQ;AAEvC,SAAO"}
@@ -1,5 +1,6 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const node_async_hooks = require_chunk.__toESM(require("node:async_hooks"));
2
+ let node_async_hooks = require("node:async_hooks");
3
+ node_async_hooks = require_chunk.__toESM(node_async_hooks);
3
4
 
4
5
  //#region src/app/events/EventWorkerContext.ts
5
6
  /**
@@ -65,4 +66,4 @@ Object.defineProperty(exports, 'runInEventWorkerContext', {
65
66
  return runInEventWorkerContext;
66
67
  }
67
68
  });
68
- //# sourceMappingURL=EventWorkerContext-TZIKxVCu.js.map
69
+ //# sourceMappingURL=EventWorkerContext-Dq29tieI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EventWorkerContext-TZIKxVCu.js","names":[],"sources":["../src/app/events/EventWorkerContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport { ParsedEvent } from '../router';\nimport { CommandKit } from '../../commandkit';\n\n/**\n * Context object containing information about the currently executing event.\n */\nexport interface EventWorkerContext {\n event: string;\n namespace: string | null;\n data: ParsedEvent;\n commandkit: CommandKit;\n arguments: any[];\n variables: Map<string, any>;\n}\n\n/**\n * @private\n * @internal\n */\nconst kEventWorker = Symbol('commandkitEventWorker');\n\n/**\n * Async local storage for event worker context.\n */\nexport const eventWorkerContext = new AsyncLocalStorage<EventWorkerContext>();\n\n/**\n * Runs a callback within an event worker context.\n * @param context - The event worker context\n * @param callback - The callback to execute\n * @returns The result of the callback\n */\nexport function runInEventWorkerContext<T>(\n context: EventWorkerContext,\n callback: () => T,\n): T {\n Reflect.set(context, kEventWorker, true);\n\n return eventWorkerContext.run(context, callback);\n}\n\n/**\n * Gets the current event worker context.\n * @returns The current event worker context\n * @throws Error if no context is found\n */\nexport function getEventWorkerContext(): EventWorkerContext {\n const context = eventWorkerContext.getStore();\n\n if (!context) {\n throw new Error('Event worker context not found');\n }\n\n return context;\n}\n\n/**\n * Type guard to check if an object is an event worker context.\n * @param worker - The object to check\n * @returns True if the object is an event worker context\n */\nexport function isEventWorkerContext(\n worker: any,\n): worker is EventWorkerContext {\n return worker && Reflect.get(worker, kEventWorker) === true;\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,eAAe,OAAO;;;;AAK5B,MAAa,qBAAqB,IAAI;;;;;;;AAQtC,SAAgB,wBAChB,SACA,UACI;AACF,SAAQ,IAAI,SAAS,cAAc;AAEnC,QAAO,mBAAmB,IAAI,SAAS;;;;;;;AAQzC,SAAgB,wBAA4C;CAC1D,MAAM,UAAU,mBAAmB;AAEnC,KAAI,CAAC,QACH,OAAM,IAAI,MAAM;AAGlB,QAAO;;;;;;;AAQT,SAAgB,qBAChB,QAC+B;AAC7B,QAAO,UAAU,QAAQ,IAAI,QAAQ,kBAAkB"}
1
+ {"version":3,"file":"EventWorkerContext-Dq29tieI.js","names":[],"sources":["../src/app/events/EventWorkerContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport { ParsedEvent } from '../router';\nimport { CommandKit } from '../../commandkit';\n\n/**\n * Context object containing information about the currently executing event.\n */\nexport interface EventWorkerContext {\n event: string;\n namespace: string | null;\n data: ParsedEvent;\n commandkit: CommandKit;\n arguments: any[];\n variables: Map<string, any>;\n}\n\n/**\n * @private\n * @internal\n */\nconst kEventWorker = Symbol('commandkitEventWorker');\n\n/**\n * Async local storage for event worker context.\n */\nexport const eventWorkerContext = new AsyncLocalStorage<EventWorkerContext>();\n\n/**\n * Runs a callback within an event worker context.\n * @param context - The event worker context\n * @param callback - The callback to execute\n * @returns The result of the callback\n */\nexport function runInEventWorkerContext<T>(\n context: EventWorkerContext,\n callback: () => T,\n): T {\n Reflect.set(context, kEventWorker, true);\n\n return eventWorkerContext.run(context, callback);\n}\n\n/**\n * Gets the current event worker context.\n * @returns The current event worker context\n * @throws Error if no context is found\n */\nexport function getEventWorkerContext(): EventWorkerContext {\n const context = eventWorkerContext.getStore();\n\n if (!context) {\n throw new Error('Event worker context not found');\n }\n\n return context;\n}\n\n/**\n * Type guard to check if an object is an event worker context.\n * @param worker - The object to check\n * @returns True if the object is an event worker context\n */\nexport function isEventWorkerContext(\n worker: any,\n): worker is EventWorkerContext {\n return worker && Reflect.get(worker, kEventWorker) === true;\n}\n"],"mappings":";;;;;;;;;AAoBA,MAAM,eAAe,OAAO,wBAAwB;;;;AAKpD,MAAa,qBAAqB,IAAI,oCAAuC;;;;;;;AAQ7E,SAAgB,wBAChB,SACA,UACI;AACF,SAAQ,IAAI,SAAS,cAAc,KAAK;AAExC,QAAO,mBAAmB,IAAI,SAAS,SAAS;;;;;;;AAQlD,SAAgB,wBAA4C;CAC1D,MAAM,UAAU,mBAAmB,UAAU;AAE7C,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,iCAAiC;AAGnD,QAAO;;;;;;;AAQT,SAAgB,qBAChB,QAC+B;AAC7B,QAAO,UAAU,QAAQ,IAAI,QAAQ,aAAa,KAAK"}
@@ -1,4 +1,4 @@
1
- import { CommandKit } from "./analytics-engine-CtMbeudW.js";
1
+ import { CommandKit } from "./analytics-engine-6_M8tCeD.js";
2
2
  import { ParsedEvent } from "./EventsRouter-BacqK6z3.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
 
@@ -40,4 +40,4 @@ declare function getEventWorkerContext(): EventWorkerContext;
40
40
  declare function isEventWorkerContext(worker: any): worker is EventWorkerContext;
41
41
  //#endregion
42
42
  export { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext };
43
- //# sourceMappingURL=EventWorkerContext-D9frVhVe.d.ts.map
43
+ //# sourceMappingURL=EventWorkerContext-xgEc2N2T.d.ts.map
@@ -1,8 +1,12 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const discord_js = require_chunk.__toESM(require("discord.js"));
3
- const node_fs = require_chunk.__toESM(require("node:fs"));
4
- const node_path = require_chunk.__toESM(require("node:path"));
5
- const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
2
+ let discord_js = require("discord.js");
3
+ discord_js = require_chunk.__toESM(discord_js);
4
+ let node_fs = require("node:fs");
5
+ node_fs = require_chunk.__toESM(node_fs);
6
+ let node_path = require("node:path");
7
+ node_path = require_chunk.__toESM(node_path);
8
+ let node_fs_promises = require("node:fs/promises");
9
+ node_fs_promises = require_chunk.__toESM(node_fs_promises);
6
10
 
7
11
  //#region src/app/router/EventsRouter.ts
8
12
  /**
@@ -130,4 +134,4 @@ Object.defineProperty(exports, 'EventsRouter', {
130
134
  return EventsRouter;
131
135
  }
132
136
  });
133
- //# sourceMappingURL=EventsRouter-C_J0M3uO.js.map
137
+ //# sourceMappingURL=EventsRouter-Dzpm7ubq.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EventsRouter-C_J0M3uO.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;;;;;;CAOrB,AAAO,YAAY,AAAQ,SAA8B;;EAA9B;AACzB,MAAI,QAAQ,YACV,SAAQ,cAAc,MAAM,KAAK,IAAI,IAAI,QAAQ;AAGnD,MAAI,0BAAC,QAAQ,yFAAa,QACxB,OAAM,IAAI,MAAM;;;;;;CAQpB,AAAO,eAAe,aAAuB;AAC3C,OAAK,QAAQ,cAAc,MAAM,KAC/B,IAAI,IAAI,CAAC,GAAG,KAAK,QAAQ,aAAa,GAAG;;;;;;;CAS7C,AAAO,MAAM,OAAmC;AAC9C,SAAO,KAAK,OAAO,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G;AAGrC;;AAGF,QAAK,OAAO,IAAI,OAAO;IAAE;IAAO;IAAM;IAAW"}
1
+ {"version":3,"file":"EventsRouter-Dzpm7ubq.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\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,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,6 +1,7 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
2
  const require_error_codes = require('./error-codes-Ds0bnPvT.js');
3
- const discord_js = require_chunk.__toESM(require("discord.js"));
3
+ let discord_js = require("discord.js");
4
+ discord_js = require_chunk.__toESM(discord_js);
4
5
 
5
6
  //#region src/app/commands/MessageCommandParser.ts
6
7
  /**
@@ -265,4 +266,4 @@ Object.defineProperty(exports, 'MessageCommandParser', {
265
266
  return MessageCommandParser;
266
267
  }
267
268
  });
268
- //# sourceMappingURL=MessageCommandParser-TPEPhjvx.js.map
269
+ //# sourceMappingURL=MessageCommandParser-CEuO6Ex3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageCommandParser-TPEPhjvx.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\n * @param schema - Function that returns the options schema for a command\n */\n public constructor(\n public message: Message,\n private prefix: string[],\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 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":";;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;;;;;CAKhC,UAAuC;;;;;CAMvC,WAAyC;;;;;CAMzC,QAAkB;;;;;;;CAQlB,AAAO,YACP,AAAO,SACP,AAAQ,QACR,AAAQ,QACR;EAHO;EACC;EACA;;;;;;CAOR,AAAO,UAAU;AACf,EAAK,KAAK;AACV,SAAO,MAAK;;;;;CAMd,IAAW,UAAU;AACnB,MAAI,CAAC,MAAK,QACR,OAAK,UAAW,IAAI,sBAAsB;AAG5C,SAAO,MAAK;;;;;;;CAQd,AAAO,UAAa,MAA6B;;AAC/C,kCAAO,KAAK,QAAQ,QAAQ,MAAM,MAAM,EAAE,SAAS,qFAAO;;;;;;CAO5D,AAAO,aAAqB;AAC1B,SAAO,KAAK,QAAQ;;;;;;CAOtB,AAAO,gBAAoC;AACzC,SAAO,KAAK,QAAQ;;;;;;CAOtB,AAAO,qBAAyC;AAC9C,SAAO,KAAK,QAAQ;;;;;;CAOtB,AAAO,YAAY;AACjB,OAAK,MAAM,KAAK,KAAK,OACnB,KAAI,KAAK,QAAQ,QAAQ,WAAW,GAClC,QAAO;;;;;;CASb,A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AAK,aAAmB,MAAM;;CAWvC,WAAW,MAAc,WAAW,OAAO;AACzC,SAAO,KAAK,aAAsB,MAAM;;CAW1C,QAAQ,MAAc,WAAW,OAAO;AACtC,SAAO,KAAK,aAAmB,MAAM;;CAgBvC,eACA,MACA,WAAW,OACgE;EACzE,MAAM,SAAS,KAAK,aAAa,MAAM;AAEvC,MACA,kBAAkB,0BAClB,kBAAkB,mBAClB,kBAAkB,gBAEhB,QAAO;AAGT,MAAI,SACF,OAAM,IAAI,MAAM,gBAAgB,KAAK;AAGvC,SAAO;;CAUT,cAAc,WAAW,OAAO;EAC9B,MAAM,MAAM,KAAK,OAAO;AAExB,MAAI,YAAY,QAAQ,OACtB,OAAM,IAAI,MAAM;AAGlB,SAAO,OAAO;;CAUhB,mBAAmB,WAAW,OAAO;EACnC,MAAM,MAAM,KAAK,OAAO;AAExB,MAAI,YAAY,QAAQ,OACtB,OAAM,IAAI,MAAM;AAGlB,SAAO,OAAO"}
1
+ {"version":3,"file":"MessageCommandParser-CEuO6Ex3.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\n * @param schema - Function that returns the options schema for a command\n */\n public constructor(\n public message: Message,\n private prefix: string[],\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 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":";;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;;;;;CAKhC,UAAuC;;;;;CAMvC,WAAyC;;;;;CAMzC,QAAkB,EAAE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EhB,QAAO;AAGT,MAAI,SACF,OAAM,IAAI,MAAM,gBAAgB,KAAK,gBAAgB;AAGvD,SAAO;;CAUT,cAAc,WAAW,OAAO;EAC9B,MAAM,MAAM,KAAK,OAAO,eAAe;AAEvC,MAAI,YAAY,QAAQ,OACtB,OAAM,IAAI,MAAM,0BAA0B;AAG5C,SAAO,OAAO;;CAUhB,mBAAmB,WAAW,OAAO;EACnC,MAAM,MAAM,KAAK,OAAO,oBAAoB;AAE5C,MAAI,YAAY,QAAQ,OACtB,OAAM,IAAI,MAAM,gCAAgC;AAGlD,SAAO,OAAO"}
@@ -1,5 +1,6 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const node_crypto = require_chunk.__toESM(require("node:crypto"));
2
+ let node_crypto = require("node:crypto");
3
+ node_crypto = require_chunk.__toESM(node_crypto);
3
4
 
4
5
  //#region src/plugins/PluginCommon.ts
5
6
  /**
@@ -67,4 +68,4 @@ Object.defineProperty(exports, 'isPlugin', {
67
68
  return isPlugin;
68
69
  }
69
70
  });
70
- //# sourceMappingURL=PluginCommon-Di1xIa8d.js.map
71
+ //# sourceMappingURL=PluginCommon-Cvl5yYM_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginCommon-Di1xIa8d.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,oDAAL;AACL;AACA;;;;;;AAMF,IAAsB,eAAtB,MAGA;;;;CAQE,AAAgB;;;;CAIhB,AAAgB,WAAW,KAAK;;;;CAShC,AAAO,YAAY,AAAmB,SAAY;EAAZ;;;;;CAKtC,MAAa,SAAS,KAAuB;;;;CAK7C,MAAa,WAAW,KAAuB;;;;;;;AAQjD,SAAgB,SAChB,QACwC;AACtC,QAAO,kBAAkB"}
1
+ {"version":3,"file":"PluginCommon-Cvl5yYM_.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,oDAAL;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"}
@@ -1,4 +1,4 @@
1
- const require_PluginCommon = require('./PluginCommon-Di1xIa8d.js');
1
+ const require_PluginCommon = require('./PluginCommon-Cvl5yYM_.js');
2
2
 
3
3
  //#region src/plugins/RuntimePlugin.ts
4
4
  /**
@@ -131,4 +131,4 @@ Object.defineProperty(exports, 'isRuntimePlugin', {
131
131
  return isRuntimePlugin;
132
132
  }
133
133
  });
134
- //# sourceMappingURL=RuntimePlugin-eTdFJwGd.js.map
134
+ //# sourceMappingURL=RuntimePlugin-BUecuBIU.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimePlugin-eTdFJwGd.js","names":[],"sources":["../src/plugins/RuntimePlugin.ts"],"sourcesContent":["import { Interaction, Message } from 'discord.js';\nimport {\n isPlugin,\n PluginCommon,\n PluginOptions,\n PluginType,\n} from './PluginCommon';\nimport type { CommandKitPluginRuntime } from './plugin-runtime/CommandKitPluginRuntime';\nimport { CommandBuilderLike, PreparedAppCommandExecution } from '../app';\nimport { CommandKitEnvironment } from '../context/environment';\nimport { CommandKitHMREvent } from '../utils/dev-hooks';\nimport { PreRegisterCommandsEvent } from '../app/register/CommandRegistrar';\nimport { CommandKitEventDispatch } from './types';\n\n/**\n * CommandKit plugin that runs at the runtime.\n */\nexport abstract class RuntimePlugin<\n T extends PluginOptions = PluginOptions,\n> extends PluginCommon<T, CommandKitPluginRuntime> {\n public readonly type = PluginType.Runtime;\n public readonly preload = new Set<string>();\n\n /**\n * Called before commands are loaded\n */\n public async onBeforeCommandsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after commands are loaded\n */\n public async onAfterCommandsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called before events are loaded\n */\n public async onBeforeEventsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after events are loaded\n */\n public async onAfterEventsLoad(ctx: CommandKitPluginRuntime): Promise<void> {}\n\n /**\n * Called before the client logs in\n */\n public async onBeforeClientLogin(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after the client logs in\n */\n public async onAfterClientLogin(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called before interaction is handled\n * @param interaction The interaction\n */\n public async onBeforeInteraction(\n ctx: CommandKitPluginRuntime,\n interaction: Interaction,\n ): Promise<void> {}\n\n /**\n * Called before message command is processed\n * @param message The message\n */\n public async onBeforeMessageCommand(\n ctx: CommandKitPluginRuntime,\n message: Message,\n ): Promise<void> {}\n\n /**\n * Called before command is executed. This method can execute the command itself.\n * @param source The source that triggered the command\n * @param command The command\n * @param execute The function that executes the command\n */\n public async executeCommand(\n ctx: CommandKitPluginRuntime,\n env: CommandKitEnvironment,\n source: Interaction | Message,\n command: PreparedAppCommandExecution,\n execute: () => Promise<any>,\n ): Promise<boolean> {\n return false;\n }\n\n /**\n * Called after events router is initialized\n * @param ctx The context\n */\n public async onEventsRouterInit(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after commands router is initialized\n * @param ctx The context\n */\n public async onCommandsRouterInit(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called when HMR event is received\n * @param ctx The context\n * @param event The event\n */\n public async performHMR(\n ctx: CommandKitPluginRuntime,\n event: CommandKitHMREvent,\n ): Promise<void> {}\n\n /**\n * Called before command is loaded for registration. This method can be used to modify the command data before it is loaded.\n * @param ctx The context\n * @param commands The command that is being loaded. This is a CommandBuilderLike object which represents Discord's command\n */\n async prepareCommand(\n ctx: CommandKitPluginRuntime,\n commands: CommandBuilderLike,\n ): Promise<CommandBuilderLike | null> {\n return null;\n }\n\n /**\n * Called before command is registered to discord. This method can cancel the registration of the command and handle it manually.\n * @param ctx The context\n * @param data The command registration data\n */\n async onBeforeRegisterCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before global commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called after `onBeforeRegisterCommands` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforeRegisterGlobalCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called before guilds of the command are resolved. It is called after `onBeforeRegisterCommands` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforePrepareGuildCommandsRegistration(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called after guilds of the command are resolved. It is called after `onBeforePrepareGuildCommandsRegistration` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforeRegisterGuildCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called after command and all of its deferred functions are executed.\n * @param ctx The context\n * @param env The environment of the command. This environment contains the command execution data such as command context and more.\n */\n async onAfterCommand(\n ctx: CommandKitPluginRuntime,\n env: CommandKitEnvironment,\n ) {}\n\n /**\n * Called before emitting an event\n * @param ctx The context\n * @param event The event that is being emitted\n */\n public async willEmitEvent(\n ctx: CommandKitPluginRuntime,\n event: CommandKitEventDispatch,\n ) {}\n}\n\nexport function isRuntimePlugin(plugin: unknown): plugin is RuntimePlugin {\n return (\n plugin instanceof RuntimePlugin ||\n (isPlugin(plugin) && plugin.type === PluginType.Runtime)\n );\n}\n"],"mappings":";;;;;;AAiBA,IAAsB,gBAAtB,cAEA,kCAAyC;CACvC,AAAgB,OAAO,gCAAW;CAClC,AAAgB,0BAAU,IAAI;;;;CAK9B,MAAa,qBACb,KACgB;;;;CAKhB,MAAa,oBACb,KACgB;;;;CAKhB,MAAa,mBACb,KACgB;;;;CAKhB,MAAa,kBAAkB,KAA6C;;;;CAK5E,MAAa,oBACb,KACgB;;;;CAKhB,MAAa,mBACb,KACgB;;;;;CAMhB,MAAa,oBACb,KACA,aACgB;;;;;CAMhB,MAAa,uBACb,KACA,SACgB;;;;;;;CAQhB,MAAa,eACb,KACA,KACA,QACA,SACA,SACmB;AACjB,SAAO;;;;;;CAOT,MAAa,mBACb,KACgB;;;;;CAMhB,MAAa,qBACb,KACgB;;;;;;CAOhB,MAAa,WACb,KACA,OACgB;;;;;;CAOhB,MAAM,eACN,KACA,UACqC;AACnC,SAAO;;;;;;;CAQT,MAAM,yBACN,KACA,OACgB;;;;;;;CAQhB,MAAM,+BACN,KACA,OACgB;;;;;;;CAQhB,MAAM,yCACN,KACA,OACgB;;;;;;;CAQhB,MAAM,8BACN,KACA,OACgB;;;;;;CAOhB,MAAM,eACN,KACA,KACA;;;;;;CAOA,MAAa,cACb,KACA,OACA;;AAGF,SAAgB,gBAAgB,QAA0C;AACxE,QACE,kBAAkB,iBAClB,8BAAS,WAAW,OAAO,SAAS,gCAAW"}
1
+ {"version":3,"file":"RuntimePlugin-BUecuBIU.js","names":[],"sources":["../src/plugins/RuntimePlugin.ts"],"sourcesContent":["import { Interaction, Message } from 'discord.js';\nimport {\n isPlugin,\n PluginCommon,\n PluginOptions,\n PluginType,\n} from './PluginCommon';\nimport type { CommandKitPluginRuntime } from './plugin-runtime/CommandKitPluginRuntime';\nimport { CommandBuilderLike, PreparedAppCommandExecution } from '../app';\nimport { CommandKitEnvironment } from '../context/environment';\nimport { CommandKitHMREvent } from '../utils/dev-hooks';\nimport { PreRegisterCommandsEvent } from '../app/register/CommandRegistrar';\nimport { CommandKitEventDispatch } from './types';\n\n/**\n * CommandKit plugin that runs at the runtime.\n */\nexport abstract class RuntimePlugin<\n T extends PluginOptions = PluginOptions,\n> extends PluginCommon<T, CommandKitPluginRuntime> {\n public readonly type = PluginType.Runtime;\n public readonly preload = new Set<string>();\n\n /**\n * Called before commands are loaded\n */\n public async onBeforeCommandsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after commands are loaded\n */\n public async onAfterCommandsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called before events are loaded\n */\n public async onBeforeEventsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after events are loaded\n */\n public async onAfterEventsLoad(ctx: CommandKitPluginRuntime): Promise<void> {}\n\n /**\n * Called before the client logs in\n */\n public async onBeforeClientLogin(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after the client logs in\n */\n public async onAfterClientLogin(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called before interaction is handled\n * @param interaction The interaction\n */\n public async onBeforeInteraction(\n ctx: CommandKitPluginRuntime,\n interaction: Interaction,\n ): Promise<void> {}\n\n /**\n * Called before message command is processed\n * @param message The message\n */\n public async onBeforeMessageCommand(\n ctx: CommandKitPluginRuntime,\n message: Message,\n ): Promise<void> {}\n\n /**\n * Called before command is executed. This method can execute the command itself.\n * @param source The source that triggered the command\n * @param command The command\n * @param execute The function that executes the command\n */\n public async executeCommand(\n ctx: CommandKitPluginRuntime,\n env: CommandKitEnvironment,\n source: Interaction | Message,\n command: PreparedAppCommandExecution,\n execute: () => Promise<any>,\n ): Promise<boolean> {\n return false;\n }\n\n /**\n * Called after events router is initialized\n * @param ctx The context\n */\n public async onEventsRouterInit(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after commands router is initialized\n * @param ctx The context\n */\n public async onCommandsRouterInit(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called when HMR event is received\n * @param ctx The context\n * @param event The event\n */\n public async performHMR(\n ctx: CommandKitPluginRuntime,\n event: CommandKitHMREvent,\n ): Promise<void> {}\n\n /**\n * Called before command is loaded for registration. This method can be used to modify the command data before it is loaded.\n * @param ctx The context\n * @param commands The command that is being loaded. This is a CommandBuilderLike object which represents Discord's command\n */\n async prepareCommand(\n ctx: CommandKitPluginRuntime,\n commands: CommandBuilderLike,\n ): Promise<CommandBuilderLike | null> {\n return null;\n }\n\n /**\n * Called before command is registered to discord. This method can cancel the registration of the command and handle it manually.\n * @param ctx The context\n * @param data The command registration data\n */\n async onBeforeRegisterCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before global commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called after `onBeforeRegisterCommands` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforeRegisterGlobalCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called before guilds of the command are resolved. It is called after `onBeforeRegisterCommands` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforePrepareGuildCommandsRegistration(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called after guilds of the command are resolved. It is called after `onBeforePrepareGuildCommandsRegistration` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforeRegisterGuildCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called after command and all of its deferred functions are executed.\n * @param ctx The context\n * @param env The environment of the command. This environment contains the command execution data such as command context and more.\n */\n async onAfterCommand(\n ctx: CommandKitPluginRuntime,\n env: CommandKitEnvironment,\n ) {}\n\n /**\n * Called before emitting an event\n * @param ctx The context\n * @param event The event that is being emitted\n */\n public async willEmitEvent(\n ctx: CommandKitPluginRuntime,\n event: CommandKitEventDispatch,\n ) {}\n}\n\nexport function isRuntimePlugin(plugin: unknown): plugin is RuntimePlugin {\n return (\n plugin instanceof RuntimePlugin ||\n (isPlugin(plugin) && plugin.type === PluginType.Runtime)\n );\n}\n"],"mappings":";;;;;;AAiBA,IAAsB,gBAAtB,cAEA,kCAAyC;CACvC,AAAgB,OAAO,gCAAW;CAClC,AAAgB,0BAAU,IAAI,KAAa;;;;CAK3C,MAAa,qBACb,KACgB;;;;CAKhB,MAAa,oBACb,KACgB;;;;CAKhB,MAAa,mBACb,KACgB;;;;CAKhB,MAAa,kBAAkB,KAA6C;;;;CAK5E,MAAa,oBACb,KACgB;;;;CAKhB,MAAa,mBACb,KACgB;;;;;CAMhB,MAAa,oBACb,KACA,aACgB;;;;;CAMhB,MAAa,uBACb,KACA,SACgB;;;;;;;CAQhB,MAAa,eACb,KACA,KACA,QACA,SACA,SACmB;AACjB,SAAO;;;;;;CAOT,MAAa,mBACb,KACgB;;;;;CAMhB,MAAa,qBACb,KACgB;;;;;;CAOhB,MAAa,WACb,KACA,OACgB;;;;;;CAOhB,MAAM,eACN,KACA,UACqC;AACnC,SAAO;;;;;;;CAQT,MAAM,yBACN,KACA,OACgB;;;;;;;CAQhB,MAAM,+BACN,KACA,OACgB;;;;;;;CAQhB,MAAM,yCACN,KACA,OACgB;;;;;;;CAQhB,MAAM,8BACN,KACA,OACgB;;;;;;CAOhB,MAAM,eACN,KACA,KACA;;;;;;CAOA,MAAa,cACb,KACA,OACA;;AAGF,SAAgB,gBAAgB,QAA0C;AACxE,QACE,kBAAkB,iBAClB,8BAAS,OAAO,IAAI,OAAO,SAAS,gCAAW"}
@@ -1,4 +1,4 @@
1
- import { AnalyticsEngine, FilterFunction } from "../analytics-engine-CtMbeudW.js";
1
+ import { AnalyticsEngine, FilterFunction } from "../analytics-engine-6_M8tCeD.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";