commandkit 1.2.0-rc.6 → 1.2.0-rc.8

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 (207) 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-CxC-b0wN.js} +15 -11
  53. package/dist/{build-oC6ke8bF.js.map → build-CxC-b0wN.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-CuM4HbAQ.js} +136 -148
  72. package/dist/commandkit-CuM4HbAQ.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-DafbZSFy.js} +10 -15
  124. package/dist/{feature-flags-Ug0I9mfF.js.map → feature-flags-DafbZSFy.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-C41hZSJg.js} +11 -8
  139. package/dist/{init-BTnqvIWt.js.map → init-C41hZSJg.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-CS7843dE.js} +2 -2
  202. package/dist/{version-D0XWDQ4f.js.map → version-CS7843dE.js.map} +1 -1
  203. package/dist/version.js +1 -1
  204. package/hooks.cjs +2 -0
  205. package/hooks.d.ts +3 -1
  206. package/package.json +2 -2
  207. package/dist/commandkit-vWHgiaKd.js.map +0 -1
@@ -1,30 +1,37 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const require_colors = require('./colors-Cd4Oz-r-.js');
2
+ const require_colors = require('./colors-DL3ucTiT.js');
3
3
  const require_error_codes = require('./error-codes-Ds0bnPvT.js');
4
4
  const require_element = require('./element-Bak9llw_.js');
5
- const require_EventInterceptor = require('./EventInterceptor-CQ4PBpBJ.js');
5
+ const require_EventInterceptor = require('./EventInterceptor-CQEXyUTp.js');
6
6
  const require_constants = require('./constants-B5_Ta7PR.js');
7
- const require_CompilerPlugin = require('./CompilerPlugin-CjoZAAR8.js');
8
- const require_RuntimePlugin = require('./RuntimePlugin-eTdFJwGd.js');
9
- const require_resolve_file_url = require('./resolve-file-url-DYjaxg_S.js');
7
+ const require_CompilerPlugin = require('./CompilerPlugin-M8r3yNAl.js');
8
+ const require_RuntimePlugin = require('./RuntimePlugin-BUecuBIU.js');
9
+ const require_resolve_file_url = require('./resolve-file-url-ChIyw-Vf.js');
10
10
  const require_utils = require('./utils-KsNof0Xz.js');
11
- const require_types_package = require('./types-package-DrnIdWLg.js');
12
- const require_constants$1 = require('./constants-DxfYtA6t.js');
13
- const require_EventWorkerContext = require('./EventWorkerContext-TZIKxVCu.js');
14
- const require_signals = require('./signals-r7qPAvOR.js');
15
- const require_MessageCommandParser = require('./MessageCommandParser-TPEPhjvx.js');
16
- const require_CommandsRouter = require('./CommandsRouter-tMAivEfv.js');
17
- const require_EventsRouter = require('./EventsRouter-C_J0M3uO.js');
18
- const require_common = require('./common-DNADUU3_.js');
19
- const require_CommandKitEventsChannel = require('./CommandKitEventsChannel-Bgw0XCOl.js');
20
- const require_store = require('./store-CiqLHedg.js');
21
- const node_events = require_chunk.__toESM(require("node:events"));
22
- const discord_js = require_chunk.__toESM(require("discord.js"));
23
- const node_async_hooks = require_chunk.__toESM(require("node:async_hooks"));
24
- const node_fs = require_chunk.__toESM(require("node:fs"));
25
- const node_path = require_chunk.__toESM(require("node:path"));
26
- const node_crypto = require_chunk.__toESM(require("node:crypto"));
27
- const util = require_chunk.__toESM(require("util"));
11
+ const require_types_package = require('./types-package-BWArjyBF.js');
12
+ const require_constants$1 = require('./constants-BOOGN85p.js');
13
+ const require_EventWorkerContext = require('./EventWorkerContext-Dq29tieI.js');
14
+ const require_signals = require('./signals-ChFMD7mB.js');
15
+ const require_MessageCommandParser = require('./MessageCommandParser-CEuO6Ex3.js');
16
+ const require_CommandsRouter = require('./CommandsRouter-DZAeB2v_.js');
17
+ const require_EventsRouter = require('./EventsRouter-Dzpm7ubq.js');
18
+ const require_common = require('./common-DVM_onKu.js');
19
+ const require_CommandKitEventsChannel = require('./CommandKitEventsChannel-B5vbINtP.js');
20
+ const require_store = require('./store-Hcgz7DSt.js');
21
+ let node_events = require("node:events");
22
+ node_events = require_chunk.__toESM(node_events);
23
+ let discord_js = require("discord.js");
24
+ discord_js = require_chunk.__toESM(discord_js);
25
+ let node_async_hooks = require("node:async_hooks");
26
+ node_async_hooks = require_chunk.__toESM(node_async_hooks);
27
+ let node_fs = require("node:fs");
28
+ node_fs = require_chunk.__toESM(node_fs);
29
+ let node_path = require("node:path");
30
+ node_path = require_chunk.__toESM(node_path);
31
+ let node_crypto = require("node:crypto");
32
+ node_crypto = require_chunk.__toESM(node_crypto);
33
+ let util = require("util");
34
+ util = require_chunk.__toESM(util);
28
35
 
29
36
  //#region src/context/async-context.ts
30
37
  const kCommandWorker = Symbol("commandkitCommandWorker");
@@ -61,8 +68,7 @@ function makeContextAwareFunction(env, fn, finalizer) {
61
68
  const _fn = (...args) => {
62
69
  return provideContext(env, async () => {
63
70
  try {
64
- const result = await fn(...args);
65
- return result;
71
+ return await fn(...args);
66
72
  } catch (e) {
67
73
  if (!require_error_codes.isCommandKitError(e)) env.setExecutionError(e);
68
74
  else throw e;
@@ -88,8 +94,7 @@ function getCommandKit(strict = false) {
88
94
  * @internal
89
95
  */
90
96
  function getContext() {
91
- const ctx = context.getStore();
92
- return ctx;
97
+ return context.getStore();
93
98
  }
94
99
  /**
95
100
  * Use current commandkit context. Throws an error if no context is found.
@@ -99,6 +104,12 @@ function useEnvironment() {
99
104
  if (!ctx) throw new Error("No commandkit environment found. Please make sure you are inside commandkit handler.");
100
105
  return ctx;
101
106
  }
107
+ /**
108
+ * Use the shared data store in the current environment. Throws an error if no context is found.
109
+ */
110
+ function useStore() {
111
+ return useEnvironment().store;
112
+ }
102
113
 
103
114
  //#endregion
104
115
  //#region src/components/v1/button/ButtonKit.ts
@@ -195,15 +206,13 @@ var ButtonKit = class extends discord_js.ButtonBuilder {
195
206
  }
196
207
  #setupInteractionCollector() {
197
208
  if (this.data.style === discord_js.ButtonStyle.Link || !this.#contextData || !this.#onClickHandler) return;
198
- const myCustomId = this.customId ?? null;
199
- if (myCustomId === null) throw new TypeError("Cannot setup \"onClick\" handler on a button without a custom id.");
200
- const interceptor = this.#getEventInterceptor();
201
- this.#unsub = interceptor.subscribe(discord_js.Events.InteractionCreate, async (interaction) => {
209
+ if ((this.customId ?? null) === null) throw new TypeError("Cannot setup \"onClick\" handler on a button without a custom id.");
210
+ this.#unsub = this.#getEventInterceptor().subscribe(discord_js.Events.InteractionCreate, async (interaction) => {
202
211
  var _this$contextData5, _this$unsub;
203
212
  if (!interaction.isButton()) return;
204
- const myCustomId$1 = this.customId ?? null;
213
+ const myCustomId = this.customId ?? null;
205
214
  const interactionCustomId = interaction.customId;
206
- if (myCustomId$1 && interactionCustomId !== myCustomId$1) return;
215
+ if (myCustomId && interactionCustomId !== myCustomId) return;
207
216
  const filter = (_this$contextData5 = this.#contextData) === null || _this$contextData5 === void 0 ? void 0 : _this$contextData5.filter;
208
217
  if (filter && !await filter(interaction)) return;
209
218
  const handler = this.#onClickHandler;
@@ -1278,13 +1287,11 @@ var DefaultLogger = class {
1278
1287
  break;
1279
1288
  default: label = "[LOG]";
1280
1289
  }
1281
- const coloredLabel = TextBgColorMap[level](require_colors.colors_default.whiteBright(` ${label} `));
1282
- return `${coloredLabel} `;
1290
+ return `${TextBgColorMap[level](require_colors.colors_default.whiteBright(` ${label} `))} `;
1283
1291
  }
1284
1292
  _getPrefix(level) {
1285
1293
  const timestamp = this._formatTime(/* @__PURE__ */ new Date());
1286
- const label = this._getLevelLabel(level);
1287
- return `${label}${require_colors.colors_default.dim(BoxChars.vertical)} ${require_colors.colors_default.dim(timestamp)}`;
1294
+ return `${this._getLevelLabel(level)}${require_colors.colors_default.dim(BoxChars.vertical)} ${require_colors.colors_default.dim(timestamp)}`;
1288
1295
  }
1289
1296
  _log(level, message) {
1290
1297
  const prefix = this._getPrefix(level);
@@ -1405,8 +1412,7 @@ var CommandKitPluginRuntime = class {
1405
1412
  * @param plugin The plugin to be fetched.
1406
1413
  */
1407
1414
  get(plugin) {
1408
- const p = this.plugins.find((p$1) => p$1 instanceof plugin) ?? null;
1409
- return p;
1415
+ return this.plugins.find((p) => p instanceof plugin) ?? null;
1410
1416
  }
1411
1417
  /**
1412
1418
  * Pre-loads the specified entrypoints for the given plugin.
@@ -1678,9 +1684,8 @@ var CommonDirectiveTransformer = class extends require_CompilerPlugin.CompilerPl
1678
1684
  if (!this.options.enabled) return null;
1679
1685
  if (!this.transformer) return null;
1680
1686
  if (/\.json$/.test(params.id)) return null;
1681
- const result = await this.transformer(params.code.toString(), params.id);
1682
1687
  return {
1683
- code: result.contents,
1688
+ code: (await this.transformer(params.code.toString(), params.id)).contents,
1684
1689
  map: null
1685
1690
  };
1686
1691
  }
@@ -1704,8 +1709,7 @@ var MacroPlugin = class extends require_CompilerPlugin.CompilerPlugin {
1704
1709
  name = "MacroPlugin";
1705
1710
  macroTransformer;
1706
1711
  async activate() {
1707
- const transform = await import("use-macro");
1708
- this.macroTransformer = new transform.MacroTransformer();
1712
+ this.macroTransformer = new (await (import("use-macro"))).MacroTransformer();
1709
1713
  }
1710
1714
  async deactivate() {
1711
1715
  this.macroTransformer = null;
@@ -1837,13 +1841,11 @@ function getCurrentDirectory() {
1837
1841
  * @returns An array of possible source directories.
1838
1842
  */
1839
1843
  function getSourceDirectories() {
1840
- const dist = getConfig().distDir;
1841
- const locations = [
1844
+ return [
1842
1845
  "src",
1843
1846
  ".commandkit",
1844
- dist
1847
+ getConfig().distDir
1845
1848
  ].map((dir) => (0, node_path.join)(require_constants.COMMANDKIT_CWD, dir));
1846
- return locations;
1847
1849
  }
1848
1850
  /**
1849
1851
  * Returns the path to the app directory.
@@ -1947,49 +1949,48 @@ function devOnly(fn) {
1947
1949
  */
1948
1950
  function createProxy(target) {
1949
1951
  let _target = target;
1950
- const proxy = new Proxy(_target, {
1951
- get(target$1, prop, receiver) {
1952
- return Reflect.get(_target, prop, receiver);
1953
- },
1954
- set(target$1, prop, value, receiver) {
1955
- return Reflect.set(_target, prop, value, receiver);
1956
- },
1957
- deleteProperty(target$1, prop) {
1958
- return Reflect.deleteProperty(_target, prop);
1959
- },
1960
- has(target$1, prop) {
1961
- return Reflect.has(_target, prop);
1962
- },
1963
- ownKeys(target$1) {
1964
- return Reflect.ownKeys(_target);
1965
- },
1966
- getOwnPropertyDescriptor(target$1, prop) {
1967
- return Reflect.getOwnPropertyDescriptor(_target, prop);
1968
- },
1969
- defineProperty(target$1, prop, attributes) {
1970
- return Reflect.defineProperty(_target, prop, attributes);
1971
- },
1972
- getPrototypeOf(target$1) {
1973
- return Reflect.getPrototypeOf(_target);
1974
- },
1975
- setPrototypeOf(target$1, proto) {
1976
- return Reflect.setPrototypeOf(_target, proto);
1977
- },
1978
- isExtensible(target$1) {
1979
- return Reflect.isExtensible(_target);
1980
- },
1981
- preventExtensions(target$1) {
1982
- return Reflect.preventExtensions(_target);
1983
- },
1984
- apply(target$1, thisArg, args) {
1985
- return Reflect.apply(_target, thisArg, args);
1986
- },
1987
- construct(target$1, args, newTarget) {
1988
- return Reflect.construct(_target, args, newTarget);
1989
- }
1990
- });
1991
1952
  return {
1992
- proxy,
1953
+ proxy: new Proxy(_target, {
1954
+ get(target$1, prop, receiver) {
1955
+ return Reflect.get(_target, prop, receiver);
1956
+ },
1957
+ set(target$1, prop, value, receiver) {
1958
+ return Reflect.set(_target, prop, value, receiver);
1959
+ },
1960
+ deleteProperty(target$1, prop) {
1961
+ return Reflect.deleteProperty(_target, prop);
1962
+ },
1963
+ has(target$1, prop) {
1964
+ return Reflect.has(_target, prop);
1965
+ },
1966
+ ownKeys(target$1) {
1967
+ return Reflect.ownKeys(_target);
1968
+ },
1969
+ getOwnPropertyDescriptor(target$1, prop) {
1970
+ return Reflect.getOwnPropertyDescriptor(_target, prop);
1971
+ },
1972
+ defineProperty(target$1, prop, attributes) {
1973
+ return Reflect.defineProperty(_target, prop, attributes);
1974
+ },
1975
+ getPrototypeOf(target$1) {
1976
+ return Reflect.getPrototypeOf(_target);
1977
+ },
1978
+ setPrototypeOf(target$1, proto) {
1979
+ return Reflect.setPrototypeOf(_target, proto);
1980
+ },
1981
+ isExtensible(target$1) {
1982
+ return Reflect.isExtensible(_target);
1983
+ },
1984
+ preventExtensions(target$1) {
1985
+ return Reflect.preventExtensions(_target);
1986
+ },
1987
+ apply(target$1, thisArg, args) {
1988
+ return Reflect.apply(_target, thisArg, args);
1989
+ },
1990
+ construct(target$1, args, newTarget) {
1991
+ return Reflect.construct(_target, args, newTarget);
1992
+ }
1993
+ }),
1993
1994
  setTarget(newTarget) {
1994
1995
  _target = newTarget;
1995
1996
  }
@@ -2010,7 +2011,8 @@ var CommandKitEnvironment = class {
2010
2011
  marker: "",
2011
2012
  markStart: 0,
2012
2013
  markEnd: 0,
2013
- context: null
2014
+ context: null,
2015
+ store: new discord_js.Collection()
2014
2016
  };
2015
2017
  /**
2016
2018
  * Creates the commandkit execution environment.
@@ -2072,6 +2074,12 @@ var CommandKitEnvironment = class {
2072
2074
  return this.#data.variables;
2073
2075
  }
2074
2076
  /**
2077
+ * The shared store for this environment
2078
+ */
2079
+ get store() {
2080
+ return this.#data.store;
2081
+ }
2082
+ /**
2075
2083
  * Register a deferred function.
2076
2084
  * @param fn - The deferred function to register.
2077
2085
  * @returns The deferred function id.
@@ -2250,12 +2258,13 @@ var Context = class Context {
2250
2258
  * @param config The context parameters.
2251
2259
  */
2252
2260
  constructor(commandkit$1, config) {
2261
+ var _config$environment;
2253
2262
  this.commandkit = commandkit$1;
2254
2263
  this.config = config;
2255
2264
  this.interaction = config.interaction;
2256
2265
  this.message = config.message;
2257
2266
  this.client = commandkit$1.client;
2258
- this.#store = config.store ?? /* @__PURE__ */ new Map();
2267
+ this.#store = ((_config$environment = config.environment) === null || _config$environment === void 0 ? void 0 : _config$environment.store) ?? config.store ?? new discord_js.Collection();
2259
2268
  this.command = config.command;
2260
2269
  if (config.interaction) {
2261
2270
  this.guild = config.interaction.guild;
@@ -2276,7 +2285,8 @@ var Context = class Context {
2276
2285
  * This store is shared across all contexts in the same command execution, including the cloned contexts and middleware contexts.
2277
2286
  */
2278
2287
  get store() {
2279
- return this.#store;
2288
+ var _this$config$environm;
2289
+ return ((_this$config$environm = this.config.environment) === null || _this$config$environm === void 0 ? void 0 : _this$config$environm.store) ?? this.#store;
2280
2290
  }
2281
2291
  /**
2282
2292
  * Gets the name of the current command.
@@ -2289,13 +2299,8 @@ var Context = class Context {
2289
2299
  * Gets the command options based on the execution mode.
2290
2300
  */
2291
2301
  get options() {
2292
- if (this.isMessage()) {
2293
- const parser = this.config.messageCommandParser;
2294
- return parser.options;
2295
- } else {
2296
- const interaction = this.interaction;
2297
- return interaction.options;
2298
- }
2302
+ if (this.isMessage()) return this.config.messageCommandParser.options;
2303
+ else return this.interaction.options;
2299
2304
  }
2300
2305
  /**
2301
2306
  * Whether this context was forwarded from another context. This happens when a command forwards its context to another command.
@@ -2418,12 +2423,11 @@ var Context = class Context {
2418
2423
  */
2419
2424
  clone(config) {
2420
2425
  if (!config) return new Context(this.commandkit, this.config);
2421
- const ctx = new Context(this.commandkit, {
2426
+ return new Context(this.commandkit, {
2422
2427
  ...this.config,
2423
2428
  ...config,
2424
2429
  store: this.#store
2425
2430
  });
2426
- return ctx;
2427
2431
  }
2428
2432
  /**
2429
2433
  * Checks if this context is a middleware context.
@@ -2522,8 +2526,7 @@ var AppCommandRunner = class {
2522
2526
  let result;
2523
2527
  let stopMiddlewaresCalledInCmd = false;
2524
2528
  if (!beforeMiddlewaresStopped) {
2525
- const targetData = prepared.command.data;
2526
- const fn = targetData[(options === null || options === void 0 ? void 0 : options.handler) || executionMode];
2529
+ const fn = prepared.command.data[(options === null || options === void 0 ? void 0 : options.handler) || executionMode];
2527
2530
  if (!fn) Logger.warn(`Command ${prepared.command.command.name} has no handler for ${executionMode}`);
2528
2531
  const analytics = commandkit$1.analytics;
2529
2532
  if (fn) try {
@@ -2567,10 +2570,9 @@ var AppCommandRunner = class {
2567
2570
  }, this.#finalizer.bind(this));
2568
2571
  const executeCommand = runCommand != null ? runCommand(_executeCommand) : _executeCommand;
2569
2572
  env.markStart(prepared.command.data.command.name);
2570
- const res = await commandkit$1.plugins.execute(async (ctx, plugin) => {
2573
+ if (!await commandkit$1.plugins.execute(async (ctx, plugin) => {
2571
2574
  return plugin.executeCommand(ctx, env, source, prepared, executeCommand);
2572
- });
2573
- if (!res) result = await executeCommand();
2575
+ })) result = await executeCommand();
2574
2576
  } catch (e) {
2575
2577
  if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.StopMiddlewares)) {
2576
2578
  stopMiddlewaresCalledInCmd = true;
@@ -2652,9 +2654,7 @@ var CommandRegistrar = class {
2652
2654
  * Gets the commands data.
2653
2655
  */
2654
2656
  getCommandsData() {
2655
- const handler = this.commandkit.commandHandler;
2656
- const commands = handler.getCommandsArray();
2657
- return commands.flatMap((cmd) => {
2657
+ return this.commandkit.commandHandler.getCommandsArray().flatMap((cmd) => {
2658
2658
  const json = "toJSON" in cmd.data.command ? cmd.data.command.toJSON() : cmd.data.command;
2659
2659
  const __metadata = cmd.metadata ?? cmd.data.metadata;
2660
2660
  const collections = [{
@@ -2831,13 +2831,11 @@ async function beforeExecute(ctx) {
2831
2831
  let missingBotPermissions = [];
2832
2832
  if (typeof botPermissionsRequired === "string") botPermissionsRequired = [botPermissionsRequired];
2833
2833
  if (!userPermissionsRequired.length && !botPermissionsRequired.length) return;
2834
- if (userPermissionsRequired.length) for (const permission of userPermissionsRequired) {
2835
- const hasPermission = userPermissions === null || userPermissions === void 0 ? void 0 : userPermissions.has(permission);
2836
- if (!hasPermission) missingUserPermissions.push(permission);
2834
+ if (userPermissionsRequired.length) {
2835
+ for (const permission of userPermissionsRequired) if (!(userPermissions === null || userPermissions === void 0 ? void 0 : userPermissions.has(permission))) missingUserPermissions.push(permission);
2837
2836
  }
2838
- if (botPermissionsRequired.length) for (const permission of botPermissionsRequired) {
2839
- const hasPermission = botPermissions === null || botPermissions === void 0 ? void 0 : botPermissions.has(permission);
2840
- if (!hasPermission) missingBotPermissions.push(permission);
2837
+ if (botPermissionsRequired.length) {
2838
+ for (const permission of botPermissionsRequired) if (!(botPermissions === null || botPermissions === void 0 ? void 0 : botPermissions.has(permission))) missingBotPermissions.push(permission);
2841
2839
  }
2842
2840
  if (!missingUserPermissions.length && !missingBotPermissions.length) return;
2843
2841
  const pattern = /([a-z])([A-Z])|([A-Z]+)([A-Z][a-z])/g;
@@ -2995,12 +2993,10 @@ var AppCommandHandler = class {
2995
2993
  console.log(require_colors.colors_default.cyan(`${indent}${thisPrefix} ${require_colors.colors_default.bold(displayName)}`));
2996
2994
  }
2997
2995
  commands.forEach((cmd, cmdIndex) => {
2998
- const cmdIsLast = cmdIndex === commands.length - 1 && !hasChildren;
2999
- const cmdPrefix = cmdIsLast ? "└─" : "├─";
2996
+ const cmdPrefix = cmdIndex === commands.length - 1 && !hasChildren ? "└─" : "├─";
3000
2997
  const cmdIndent = category !== uncategorized ? childIndent : indent;
3001
2998
  const name = cmd.data.command.name;
3002
- const hasMw = cmd.command.middlewares.length > 0;
3003
- const middlewareIcon = hasMw ? require_colors.colors_default.magenta(" (λ)") : "";
2999
+ const middlewareIcon = cmd.command.middlewares.length > 0 ? require_colors.colors_default.magenta(" (λ)") : "";
3004
3000
  console.log(`${require_colors.colors_default.green(`${cmdIndent}${cmdPrefix}`)} ${require_colors.colors_default.yellow(name)}${middlewareIcon}`);
3005
3001
  });
3006
3002
  if (hasChildren) {
@@ -3040,21 +3036,18 @@ var AppCommandHandler = class {
3040
3036
  */
3041
3037
  registerCommandHandler() {
3042
3038
  this.onInteraction ??= async (interaction) => {
3043
- const success = await this.commandkit.plugins.execute(async (ctx, plugin) => {
3039
+ if (await this.commandkit.plugins.execute(async (ctx, plugin) => {
3044
3040
  return plugin.onBeforeInteraction(ctx, interaction);
3045
- });
3046
- if (success) return;
3047
- const isCommandLike = interaction.isCommand() || interaction.isAutocomplete() || interaction.isUserContextMenuCommand() || interaction.isMessageContextMenuCommand();
3048
- if (!isCommandLike) return;
3041
+ })) return;
3042
+ if (!(interaction.isCommand() || interaction.isAutocomplete() || interaction.isUserContextMenuCommand() || interaction.isMessageContextMenuCommand())) return;
3049
3043
  const prepared = await this.prepareCommandRun(interaction);
3050
3044
  if (!prepared) return;
3051
3045
  return this.commandRunner.runCommand(prepared, interaction);
3052
3046
  };
3053
3047
  this.onMessageCreate ??= async (message) => {
3054
- const success = await this.commandkit.plugins.execute(async (ctx, plugin) => {
3048
+ if (await this.commandkit.plugins.execute(async (ctx, plugin) => {
3055
3049
  return plugin.onBeforeMessageCommand(ctx, message);
3056
- });
3057
- if (success) return;
3050
+ })) return;
3058
3051
  if (message.author.bot) return;
3059
3052
  const prepared = await this.prepareCommandRun(message);
3060
3053
  if (!prepared) return;
@@ -3071,8 +3064,7 @@ var AppCommandHandler = class {
3071
3064
  */
3072
3065
  async prepareCommandRun(source, cmdName) {
3073
3066
  var _loadedCommand$metada3, _loadedCommand$metada4;
3074
- const config = getConfig();
3075
- if (config.disablePrefixCommands && source instanceof discord_js.Message) return null;
3067
+ if (getConfig().disablePrefixCommands && source instanceof discord_js.Message) return null;
3076
3068
  let parser;
3077
3069
  if (!cmdName) if (source instanceof discord_js.Message) {
3078
3070
  if (source.author.bot) return null;
@@ -3086,24 +3078,20 @@ var AppCommandHandler = class {
3086
3078
  return null;
3087
3079
  }
3088
3080
  if (source.guildId && ((_loadedCommand$metada = loadedCommand$1.metadata) === null || _loadedCommand$metada === void 0 || (_loadedCommand$metada = _loadedCommand$metada.guilds) === null || _loadedCommand$metada === void 0 ? void 0 : _loadedCommand$metada.length) && !((_loadedCommand$metada2 = loadedCommand$1.metadata) === null || _loadedCommand$metada2 === void 0 ? void 0 : _loadedCommand$metada2.guilds.includes(source.guildId))) return null;
3089
- const json = "toJSON" in loadedCommand$1.data.command ? loadedCommand$1.data.command.toJSON() : loadedCommand$1.data.command;
3090
- return ((_json$options = json.options) === null || _json$options === void 0 ? void 0 : _json$options.reduce((acc, opt) => {
3081
+ return ((_json$options = ("toJSON" in loadedCommand$1.data.command ? loadedCommand$1.data.command.toJSON() : loadedCommand$1.data.command).options) === null || _json$options === void 0 ? void 0 : _json$options.reduce((acc, opt) => {
3091
3082
  acc[opt.name] = opt.type;
3092
3083
  return acc;
3093
3084
  }, {})) ?? {};
3094
3085
  });
3095
3086
  try {
3096
- const fullCommand = parser.getFullCommand();
3097
- const parts = fullCommand.split(" ");
3098
- cmdName = parts[0];
3087
+ cmdName = parser.getFullCommand().split(" ")[0];
3099
3088
  } catch (e) {
3100
3089
  if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.InvalidCommandPrefix)) return null;
3101
3090
  Logger.error`${e}`;
3102
3091
  return null;
3103
3092
  }
3104
3093
  } else {
3105
- const isAnyCommand = source.isChatInputCommand() || source.isAutocomplete() || source.isContextMenuCommand();
3106
- if (!isAnyCommand) return null;
3094
+ if (!(source.isChatInputCommand() || source.isAutocomplete() || source.isContextMenuCommand())) return null;
3107
3095
  cmdName = source.commandName;
3108
3096
  }
3109
3097
  const loadedCommand = this.findCommandByName(cmdName);
@@ -3354,8 +3342,7 @@ var AppEventsHandler = class {
3354
3342
  */
3355
3343
  getEvents() {
3356
3344
  if (this.loadedEvents.size === 0) return [];
3357
- const events = this.loadedEvents.toJSON();
3358
- return events.map((event) => ({
3345
+ return this.loadedEvents.toJSON().map((event) => ({
3359
3346
  name: event.name,
3360
3347
  namespace: event.namespace,
3361
3348
  onceListeners: event.listeners.filter((listener) => listener.once).length,
@@ -3377,8 +3364,7 @@ var AppEventsHandler = class {
3377
3364
  await this.commandkit.plugins.execute((ctx, plugin) => {
3378
3365
  return plugin.onBeforeEventsLoad(ctx);
3379
3366
  });
3380
- const router = this.commandkit.eventsRouter;
3381
- const events = await router.scan();
3367
+ const events = await this.commandkit.eventsRouter.scan();
3382
3368
  for (const event of Object.values(events)) {
3383
3369
  const listeners = [];
3384
3370
  for (const listener of event.listeners) {
@@ -3643,8 +3629,7 @@ function registerDevHooks(commandkit$1) {
3643
3629
  function getVariableStore() {
3644
3630
  const ctx = getContext();
3645
3631
  if (!ctx) try {
3646
- const eventContext = require_EventWorkerContext.getEventWorkerContext();
3647
- return eventContext.variables;
3632
+ return require_EventWorkerContext.getEventWorkerContext().variables;
3648
3633
  } catch {
3649
3634
  return null;
3650
3635
  }
@@ -3752,8 +3737,7 @@ var AnalyticsEngine = class {
3752
3737
  }
3753
3738
  }
3754
3739
  async #doNotTrack(event) {
3755
- const dnt = getDoNotTrack();
3756
- if (dnt) return true;
3740
+ if (getDoNotTrack()) return true;
3757
3741
  if (this.#filter) return !this.#filter(this, event);
3758
3742
  return false;
3759
3743
  }
@@ -3943,8 +3927,7 @@ var CommandKit = class CommandKit extends node_events.default {
3943
3927
  * Loads all the plugins.
3944
3928
  */
3945
3929
  async loadPlugins() {
3946
- const config = await loadConfigFile();
3947
- const plugins = config.plugins.flat(2).filter((p) => require_RuntimePlugin.isRuntimePlugin(p));
3930
+ const plugins = (await loadConfigFile()).plugins.flat(2).filter((p) => require_RuntimePlugin.isRuntimePlugin(p));
3948
3931
  if (!plugins.length) return;
3949
3932
  for (const plugin of plugins) await this.plugins.softRegisterPlugin(plugin);
3950
3933
  }
@@ -3992,8 +3975,7 @@ var CommandKit = class CommandKit extends node_events.default {
3992
3975
  return this;
3993
3976
  }
3994
3977
  async #init() {
3995
- const appDir$1 = this.getAppDirectory();
3996
- if (!appDir$1) return;
3978
+ if (!this.getAppDirectory()) throw new Error("CommandKit could not determine the application directory. This issue is common when you are not using the `commandkit dev` command to start the project. You can either use `commandkit dev` to start the project, or set the `COMMANDKIT_IS_CLI=true` environment variable (Note that adding this to `.env` file may not work).");
3997
3979
  const commandsPath = this.getPath("commands");
3998
3980
  const events = this.getPath("events");
3999
3981
  this.commandHandler = new AppCommandHandler(this);
@@ -4472,4 +4454,10 @@ Object.defineProperty(exports, 'useEnvironment', {
4472
4454
  return useEnvironment;
4473
4455
  }
4474
4456
  });
4475
- //# sourceMappingURL=commandkit-vWHgiaKd.js.map
4457
+ Object.defineProperty(exports, 'useStore', {
4458
+ enumerable: true,
4459
+ get: function () {
4460
+ return useStore;
4461
+ }
4462
+ });
4463
+ //# sourceMappingURL=commandkit-CuM4HbAQ.js.map