commandkit 1.0.0-dev.20250613125159 → 1.0.0-dev.20250614074051

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 (115) hide show
  1. package/dist/{CommandKit-BWzWBBGf.d.ts → CommandKit-BSXFD1Tt.d.ts} +359 -342
  2. package/dist/{CommandKit-BwxIJqBr.js → CommandKit-CT3K-Cac.js} +178 -174
  3. package/dist/CommandKit-CT3K-Cac.js.map +1 -0
  4. package/dist/CommandKit.d.ts +1 -1
  5. package/dist/CommandKit.js +4 -4
  6. package/dist/{EventWorkerContext-DdzSorsU.d.ts → EventWorkerContext-BnghX_KV.d.ts} +2 -2
  7. package/dist/{MessageCommandParser-Cz-3I-wL.js → MessageCommandParser-ClkDMI8g.js} +1 -1
  8. package/dist/{MessageCommandParser-Cz-3I-wL.js.map → MessageCommandParser-ClkDMI8g.js.map} +1 -1
  9. package/dist/analytics/analytics-engine.d.ts +1 -1
  10. package/dist/analytics/analytics-engine.js +4 -4
  11. package/dist/analytics/analytics-provider.d.ts +1 -1
  12. package/dist/analytics/utils.js +4 -4
  13. package/dist/app/commands/AppCommandRunner.d.ts +1 -1
  14. package/dist/app/commands/AppCommandRunner.js +4 -4
  15. package/dist/app/commands/Context.d.ts +1 -1
  16. package/dist/app/commands/Context.js +4 -4
  17. package/dist/app/commands/MessageCommandParser.js +1 -1
  18. package/dist/app/events/EventWorkerContext.d.ts +2 -2
  19. package/dist/app/handlers/AppCommandHandler.d.ts +2 -2
  20. package/dist/app/handlers/AppCommandHandler.js +4 -4
  21. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  22. package/dist/app/handlers/AppEventsHandler.js +4 -4
  23. package/dist/app/index.d.ts +2 -2
  24. package/dist/app/index.js +4 -4
  25. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  26. package/dist/app/register/CommandRegistrar.js +4 -4
  27. package/dist/{app-process-Bo-LedP8.js → app-process-DKNuvPMz.js} +2 -2
  28. package/dist/{app-process-Bo-LedP8.js.map → app-process-DKNuvPMz.js.map} +1 -1
  29. package/dist/{build-m0yxcs2c.js → build-CpZp-wxh.js} +4 -4
  30. package/dist/{build-m0yxcs2c.js.map → build-CpZp-wxh.js.map} +1 -1
  31. package/dist/cli/app-process.d.ts +2 -2
  32. package/dist/cli/app-process.js +3 -3
  33. package/dist/cli/build.d.ts +1 -1
  34. package/dist/cli/build.js +6 -6
  35. package/dist/cli/common.d.ts +5 -5
  36. package/dist/cli/common.js +2 -2
  37. package/dist/cli/development.js +7 -7
  38. package/dist/cli/generators.js +2 -2
  39. package/dist/cli/information.js +1 -1
  40. package/dist/cli/init.d.ts +1 -1
  41. package/dist/cli/init.js +5 -5
  42. package/dist/cli/production.d.ts +2 -2
  43. package/dist/cli/production.js +7 -7
  44. package/dist/cli/type-checker.js +3 -3
  45. package/dist/{common-Dasi9oKU.js → common-D11Ax__S.js} +2 -2
  46. package/dist/{common-Dasi9oKU.js.map → common-D11Ax__S.js.map} +1 -1
  47. package/dist/components/index.js +4 -4
  48. package/dist/components/v1/button/Button.js +4 -4
  49. package/dist/components/v1/button/ButtonKit.js +4 -4
  50. package/dist/components/v1/modal/Modal.js +4 -4
  51. package/dist/components/v1/modal/ModalKit.js +4 -4
  52. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +4 -4
  53. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +4 -4
  54. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +4 -4
  55. package/dist/components/v1/select-menu/SelectMenu.js +4 -4
  56. package/dist/components/v1/select-menu/StringSelectMenuKit.js +4 -4
  57. package/dist/components/v1/select-menu/UserSelectMenuKit.js +4 -4
  58. package/dist/config/config.d.ts +4 -4
  59. package/dist/config/config.js +4 -4
  60. package/dist/config/default.d.ts +3 -3
  61. package/dist/config/default.js +4 -4
  62. package/dist/config/loader.d.ts +3 -3
  63. package/dist/config/loader.js +4 -4
  64. package/dist/config/types.d.ts +2 -2
  65. package/dist/config/utils.d.ts +3 -3
  66. package/dist/{config-BEl-UW2l.d.ts → config-CRU_9adq.d.ts} +3 -3
  67. package/dist/context/async-context.d.ts +1 -1
  68. package/dist/context/async-context.js +4 -4
  69. package/dist/context/environment.d.ts +1 -1
  70. package/dist/context/environment.js +4 -4
  71. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  72. package/dist/{feature-flags-DG5Ozd1p.js → feature-flags-B1rI-fjI.js} +2 -2
  73. package/dist/{feature-flags-DG5Ozd1p.js.map → feature-flags-B1rI-fjI.js.map} +1 -1
  74. package/dist/flags/FlagProvider.d.ts +1 -1
  75. package/dist/flags/feature-flags.d.ts +1 -1
  76. package/dist/flags/feature-flags.js +5 -5
  77. package/dist/flags/store.d.ts +1 -1
  78. package/dist/index.d.ts +7 -7
  79. package/dist/index.js +7 -7
  80. package/dist/{init-CpYlmrSy.d.ts → init-CT348Okf.d.ts} +3 -3
  81. package/dist/{init-8cDqgA8y.js → init-Da3dcKxi.js} +4 -4
  82. package/dist/{init-8cDqgA8y.js.map → init-Da3dcKxi.js.map} +1 -1
  83. package/dist/logger/DefaultLogger.js +4 -4
  84. package/dist/logger/Logger.js +4 -4
  85. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  86. package/dist/plugins/PluginCommon.d.ts +1 -1
  87. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  88. package/dist/plugins/index.d.ts +1 -1
  89. package/dist/plugins/index.js +4 -4
  90. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  91. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +4 -4
  92. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  93. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  94. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +4 -4
  95. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
  96. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +4 -4
  97. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  98. package/dist/plugins/types.d.ts +1 -1
  99. package/dist/{type-checker-P8oyY259.js → type-checker-BgT1Ukbb.js} +2 -2
  100. package/dist/{type-checker-P8oyY259.js.map → type-checker-BgT1Ukbb.js.map} +1 -1
  101. package/dist/{types-C8GYFCIt.d.ts → types-CY8KcUfk.d.ts} +2 -2
  102. package/dist/{types-package-BpY3acyl.js → types-package-TSiYacaj.js} +1 -1
  103. package/dist/{types-package-BpY3acyl.js.map → types-package-TSiYacaj.js.map} +1 -1
  104. package/dist/types.d.ts +1 -1
  105. package/dist/utils/colors.d.ts +2 -2
  106. package/dist/utils/dev-hooks.d.ts +1 -1
  107. package/dist/utils/dev-hooks.js +4 -4
  108. package/dist/utils/types-package.js +1 -1
  109. package/dist/utils/utilities.js +4 -4
  110. package/dist/{utils-BjK-2R7h.d.ts → utils-PsznLC5X.d.ts} +2 -2
  111. package/dist/{version-rxKNvLPW.js → version-DR5byBGN.js} +2 -2
  112. package/dist/{version-rxKNvLPW.js.map → version-DR5byBGN.js.map} +1 -1
  113. package/dist/version.js +1 -1
  114. package/package.json +2 -2
  115. package/dist/CommandKit-BwxIJqBr.js.map +0 -1
@@ -9,13 +9,13 @@ const require_CompilerPlugin = require('./CompilerPlugin-Bmy4izKz.js');
9
9
  const require_RuntimePlugin = require('./RuntimePlugin-CehKbceZ.js');
10
10
  const require_EventWorkerContext = require('./EventWorkerContext-DxfS_0fJ.js');
11
11
  const require_resolve_file_url = require('./resolve-file-url-ifwdwqmq.js');
12
- const require_MessageCommandParser = require('./MessageCommandParser-Cz-3I-wL.js');
12
+ const require_types_package = require('./types-package-TSiYacaj.js');
13
13
  const require_signals = require('./signals-CSSSZAZ6.js');
14
14
  const require_constants$1 = require('./constants-CXwjhIYH.js');
15
- const require_types_package = require('./types-package-BpY3acyl.js');
15
+ const require_MessageCommandParser = require('./MessageCommandParser-ClkDMI8g.js');
16
16
  const require_CommandsRouter = require('./CommandsRouter-DFRh47qD.js');
17
17
  const require_EventsRouter = require('./EventsRouter-CqnrlbjN.js');
18
- const require_common = require('./common-Dasi9oKU.js');
18
+ const require_common = require('./common-D11Ax__S.js');
19
19
  const require_CommandKitEventsChannel = require('./CommandKitEventsChannel-BL_YN3Rm.js');
20
20
  const require_store = require('./store-x93NXUy_.js');
21
21
  const node_events = require_chunk.__toESM(require("node:events"));
@@ -1804,167 +1804,6 @@ function createProxy(target) {
1804
1804
  };
1805
1805
  }
1806
1806
 
1807
- //#endregion
1808
- //#region src/app/register/CommandRegistrar.ts
1809
- /**
1810
- * Handles registration of Discord application commands (slash commands, context menus).
1811
- */
1812
- var CommandRegistrar = class {
1813
- /**
1814
- * @private
1815
- * @internal
1816
- */
1817
- api = new discord_js.REST();
1818
- /**
1819
- * Creates an instance of CommandRegistrar.
1820
- * @param commandkit The commandkit instance.
1821
- */
1822
- constructor(commandkit$1) {
1823
- this.commandkit = commandkit$1;
1824
- this.api.setToken(this.commandkit.client.token ?? process.env.DISCORD_TOKEN ?? process.env.TOKEN ?? "");
1825
- }
1826
- /**
1827
- * Gets the commands data.
1828
- */
1829
- getCommandsData() {
1830
- const handler = this.commandkit.commandHandler;
1831
- const commands = handler.getCommandsArray();
1832
- return commands.flatMap((cmd) => {
1833
- const json$1 = "toJSON" in cmd.data.command ? cmd.data.command.toJSON() : cmd.data.command;
1834
- const collections = [json$1];
1835
- if (cmd.data.userContextMenu && json$1.type !== discord_js.ApplicationCommandType.User) collections.push({
1836
- ...json$1,
1837
- type: discord_js.ApplicationCommandType.User,
1838
- options: void 0,
1839
- description_localizations: void 0,
1840
- description: void 0
1841
- });
1842
- if (cmd.data.messageContextMenu && json$1.type !== discord_js.ApplicationCommandType.Message) collections.push({
1843
- ...json$1,
1844
- type: discord_js.ApplicationCommandType.Message,
1845
- description_localizations: void 0,
1846
- description: void 0,
1847
- options: void 0
1848
- });
1849
- return collections;
1850
- });
1851
- }
1852
- /**
1853
- * Registers loaded commands.
1854
- */
1855
- async register() {
1856
- const commands = this.getCommandsData();
1857
- let preRegistrationPrevented = false;
1858
- const preRegisterEvent = {
1859
- preventDefault() {
1860
- preRegistrationPrevented = true;
1861
- },
1862
- commands
1863
- };
1864
- await this.commandkit.plugins.execute(async (ctx, plugin) => {
1865
- if (preRegistrationPrevented) return;
1866
- return plugin.onBeforeRegisterCommands(ctx, preRegisterEvent);
1867
- });
1868
- if (preRegistrationPrevented) return;
1869
- if (!this.commandkit.client.isReady()) throw new Error("Cannot register commands before the client is ready");
1870
- const guildCommands = commands.filter((command) => {
1871
- var _command$guilds;
1872
- return (_command$guilds = command.guilds) === null || _command$guilds === void 0 ? void 0 : _command$guilds.filter(Boolean).length;
1873
- }).map((c) => {
1874
- var _c$guilds;
1875
- return {
1876
- ...c,
1877
- guilds: Array.from(new Set((_c$guilds = c.guilds) === null || _c$guilds === void 0 ? void 0 : _c$guilds.filter(Boolean)))
1878
- };
1879
- });
1880
- const globalCommands = commands.filter((command) => {
1881
- var _command$guilds2;
1882
- return !((_command$guilds2 = command.guilds) === null || _command$guilds2 === void 0 ? void 0 : _command$guilds2.filter(Boolean).length);
1883
- });
1884
- await this.updateGlobalCommands(globalCommands);
1885
- await this.updateGuildCommands(guildCommands);
1886
- }
1887
- /**
1888
- * Updates the global commands.
1889
- */
1890
- async updateGlobalCommands(commands) {
1891
- if (!commands.length) return;
1892
- let prevented = false;
1893
- const preRegisterEvent = {
1894
- preventDefault() {
1895
- prevented = true;
1896
- },
1897
- commands
1898
- };
1899
- await this.commandkit.plugins.execute(async (ctx, plugin) => {
1900
- if (prevented) return;
1901
- return plugin.onBeforeRegisterGlobalCommands(ctx, preRegisterEvent);
1902
- });
1903
- try {
1904
- const data = await this.api.put(discord_js.Routes.applicationCommands(this.commandkit.client.user.id), { body: commands.map((c) => ({
1905
- ...c,
1906
- guilds: void 0
1907
- })) });
1908
- Logger.info(`✨ Refreshed ${data.length} global application (/) commands`);
1909
- } catch (e) {
1910
- Logger.error("Failed to update global application (/) commands", e);
1911
- }
1912
- }
1913
- /**
1914
- * Updates the guild commands.
1915
- */
1916
- async updateGuildCommands(commands) {
1917
- if (!commands.length) return;
1918
- let prevented = false;
1919
- const preRegisterEvent = {
1920
- preventDefault() {
1921
- prevented = true;
1922
- },
1923
- commands
1924
- };
1925
- await this.commandkit.plugins.execute(async (ctx, plugin) => {
1926
- if (prevented) return;
1927
- return plugin.onBeforePrepareGuildCommandsRegistration(ctx, preRegisterEvent);
1928
- });
1929
- if (prevented) return;
1930
- try {
1931
- const guildCommandsMap = /* @__PURE__ */ new Map();
1932
- commands.forEach((command) => {
1933
- var _command$guilds3;
1934
- if (!((_command$guilds3 = command.guilds) === null || _command$guilds3 === void 0 ? void 0 : _command$guilds3.length)) return;
1935
- command.guilds.forEach((guild) => {
1936
- if (!guildCommandsMap.has(guild)) guildCommandsMap.set(guild, []);
1937
- guildCommandsMap.get(guild).push(command);
1938
- });
1939
- });
1940
- if (!guildCommandsMap.size) return;
1941
- let count = 0;
1942
- for (const [guild, guildCommands] of guildCommandsMap) {
1943
- let prevented$1 = false;
1944
- const preRegisterEvent$1 = {
1945
- preventDefault() {
1946
- prevented$1 = true;
1947
- },
1948
- commands: guildCommands
1949
- };
1950
- await this.commandkit.plugins.execute(async (ctx, plugin) => {
1951
- if (prevented$1) return;
1952
- return plugin.onBeforeRegisterGuildCommands(ctx, preRegisterEvent$1);
1953
- });
1954
- if (prevented$1) continue;
1955
- const data = await this.api.put(discord_js.Routes.applicationGuildCommands(this.commandkit.client.user.id, guild), { body: guildCommands.map((b) => ({
1956
- ...b,
1957
- guilds: void 0
1958
- })) });
1959
- count += data.length;
1960
- }
1961
- Logger.info(`✨ Refreshed ${count} guild application (/) commands`);
1962
- } catch (e) {
1963
- Logger.error("Failed to update guild application (/) commands", e);
1964
- }
1965
- }
1966
- };
1967
-
1968
1807
  //#endregion
1969
1808
  //#region src/context/environment.ts
1970
1809
  /**
@@ -2616,6 +2455,167 @@ var AppCommandRunner = class {
2616
2455
  }
2617
2456
  };
2618
2457
 
2458
+ //#endregion
2459
+ //#region src/app/register/CommandRegistrar.ts
2460
+ /**
2461
+ * Handles registration of Discord application commands (slash commands, context menus).
2462
+ */
2463
+ var CommandRegistrar = class {
2464
+ /**
2465
+ * @private
2466
+ * @internal
2467
+ */
2468
+ api = new discord_js.REST();
2469
+ /**
2470
+ * Creates an instance of CommandRegistrar.
2471
+ * @param commandkit The commandkit instance.
2472
+ */
2473
+ constructor(commandkit$1) {
2474
+ this.commandkit = commandkit$1;
2475
+ this.api.setToken(this.commandkit.client.token ?? process.env.DISCORD_TOKEN ?? process.env.TOKEN ?? "");
2476
+ }
2477
+ /**
2478
+ * Gets the commands data.
2479
+ */
2480
+ getCommandsData() {
2481
+ const handler = this.commandkit.commandHandler;
2482
+ const commands = handler.getCommandsArray();
2483
+ return commands.flatMap((cmd) => {
2484
+ const json$1 = "toJSON" in cmd.data.command ? cmd.data.command.toJSON() : cmd.data.command;
2485
+ const collections = [json$1];
2486
+ if (cmd.data.userContextMenu && json$1.type !== discord_js.ApplicationCommandType.User) collections.push({
2487
+ ...json$1,
2488
+ type: discord_js.ApplicationCommandType.User,
2489
+ options: void 0,
2490
+ description_localizations: void 0,
2491
+ description: void 0
2492
+ });
2493
+ if (cmd.data.messageContextMenu && json$1.type !== discord_js.ApplicationCommandType.Message) collections.push({
2494
+ ...json$1,
2495
+ type: discord_js.ApplicationCommandType.Message,
2496
+ description_localizations: void 0,
2497
+ description: void 0,
2498
+ options: void 0
2499
+ });
2500
+ return collections;
2501
+ });
2502
+ }
2503
+ /**
2504
+ * Registers loaded commands.
2505
+ */
2506
+ async register() {
2507
+ const commands = this.getCommandsData();
2508
+ let preRegistrationPrevented = false;
2509
+ const preRegisterEvent = {
2510
+ preventDefault() {
2511
+ preRegistrationPrevented = true;
2512
+ },
2513
+ commands
2514
+ };
2515
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
2516
+ if (preRegistrationPrevented) return;
2517
+ return plugin.onBeforeRegisterCommands(ctx, preRegisterEvent);
2518
+ });
2519
+ if (preRegistrationPrevented) return;
2520
+ if (!this.commandkit.client.isReady()) throw new Error("Cannot register commands before the client is ready");
2521
+ const guildCommands = commands.filter((command) => {
2522
+ var _command$guilds;
2523
+ return (_command$guilds = command.guilds) === null || _command$guilds === void 0 ? void 0 : _command$guilds.filter(Boolean).length;
2524
+ }).map((c) => {
2525
+ var _c$guilds;
2526
+ return {
2527
+ ...c,
2528
+ guilds: Array.from(new Set((_c$guilds = c.guilds) === null || _c$guilds === void 0 ? void 0 : _c$guilds.filter(Boolean)))
2529
+ };
2530
+ });
2531
+ const globalCommands = commands.filter((command) => {
2532
+ var _command$guilds2;
2533
+ return !((_command$guilds2 = command.guilds) === null || _command$guilds2 === void 0 ? void 0 : _command$guilds2.filter(Boolean).length);
2534
+ });
2535
+ await this.updateGlobalCommands(globalCommands);
2536
+ await this.updateGuildCommands(guildCommands);
2537
+ }
2538
+ /**
2539
+ * Updates the global commands.
2540
+ */
2541
+ async updateGlobalCommands(commands) {
2542
+ if (!commands.length) return;
2543
+ let prevented = false;
2544
+ const preRegisterEvent = {
2545
+ preventDefault() {
2546
+ prevented = true;
2547
+ },
2548
+ commands
2549
+ };
2550
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
2551
+ if (prevented) return;
2552
+ return plugin.onBeforeRegisterGlobalCommands(ctx, preRegisterEvent);
2553
+ });
2554
+ try {
2555
+ const data = await this.api.put(discord_js.Routes.applicationCommands(this.commandkit.client.user.id), { body: commands.map((c) => ({
2556
+ ...c,
2557
+ guilds: void 0
2558
+ })) });
2559
+ Logger.info(`✨ Refreshed ${data.length} global application (/) commands`);
2560
+ } catch (e) {
2561
+ Logger.error("Failed to update global application (/) commands", e);
2562
+ }
2563
+ }
2564
+ /**
2565
+ * Updates the guild commands.
2566
+ */
2567
+ async updateGuildCommands(commands) {
2568
+ if (!commands.length) return;
2569
+ let prevented = false;
2570
+ const preRegisterEvent = {
2571
+ preventDefault() {
2572
+ prevented = true;
2573
+ },
2574
+ commands
2575
+ };
2576
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
2577
+ if (prevented) return;
2578
+ return plugin.onBeforePrepareGuildCommandsRegistration(ctx, preRegisterEvent);
2579
+ });
2580
+ if (prevented) return;
2581
+ try {
2582
+ const guildCommandsMap = /* @__PURE__ */ new Map();
2583
+ commands.forEach((command) => {
2584
+ var _command$guilds3;
2585
+ if (!((_command$guilds3 = command.guilds) === null || _command$guilds3 === void 0 ? void 0 : _command$guilds3.length)) return;
2586
+ command.guilds.forEach((guild) => {
2587
+ if (!guildCommandsMap.has(guild)) guildCommandsMap.set(guild, []);
2588
+ guildCommandsMap.get(guild).push(command);
2589
+ });
2590
+ });
2591
+ if (!guildCommandsMap.size) return;
2592
+ let count = 0;
2593
+ for (const [guild, guildCommands] of guildCommandsMap) {
2594
+ let prevented$1 = false;
2595
+ const preRegisterEvent$1 = {
2596
+ preventDefault() {
2597
+ prevented$1 = true;
2598
+ },
2599
+ commands: guildCommands
2600
+ };
2601
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
2602
+ if (prevented$1) return;
2603
+ return plugin.onBeforeRegisterGuildCommands(ctx, preRegisterEvent$1);
2604
+ });
2605
+ if (prevented$1) continue;
2606
+ const data = await this.api.put(discord_js.Routes.applicationGuildCommands(this.commandkit.client.user.id, guild), { body: guildCommands.map((b) => ({
2607
+ ...b,
2608
+ guilds: void 0
2609
+ })) });
2610
+ count += data.length;
2611
+ }
2612
+ Logger.info(`✨ Refreshed ${count} guild application (/) commands`);
2613
+ } catch (e) {
2614
+ Logger.error("Failed to update guild application (/) commands", e);
2615
+ }
2616
+ }
2617
+ };
2618
+
2619
2619
  //#endregion
2620
2620
  //#region src/app/handlers/AppCommandHandler.ts
2621
2621
  /**
@@ -2965,30 +2965,34 @@ var AppCommandHandler = class {
2965
2965
  command,
2966
2966
  data: { command: {
2967
2967
  name: command.name,
2968
- description: `${command.name} commands`,
2968
+ description: `${command.name} command`,
2969
2969
  type: 1
2970
2970
  } }
2971
2971
  });
2972
2972
  return;
2973
2973
  }
2974
- const data = await import(`${require_resolve_file_url.toFileURL(command.path)}?t=${Date.now()}`);
2975
- if (!data.command) throw new Error(`Invalid export for command ${command.name}: no command definition found`);
2974
+ const commandFileData = await import(`${require_resolve_file_url.toFileURL(command.path)}?t=${Date.now()}`);
2975
+ if (!commandFileData.command) throw new Error(`Invalid export for command ${command.name}: no command definition found`);
2976
+ if ((!commandFileData.command.type || commandFileData.command.type === discord_js.ApplicationCommandType.ChatInput) && !commandFileData.command.description) commandFileData.command.description = `${command.name} command`;
2976
2977
  let handlerCount = 0;
2977
- for (const [key, validator] of Object.entries(commandDataSchema)) {
2978
- if (key !== "command" && data[key]) handlerCount++;
2979
- if (data[key] && !await validator(data[key])) throw new Error(`Invalid export for command ${command.name}: ${key} does not match expected value`);
2978
+ for (const [key, propValidator] of Object.entries(commandDataSchema)) {
2979
+ const exportedProp = commandFileData[key];
2980
+ if (exportedProp) {
2981
+ if (!await propValidator(exportedProp)) throw new Error(`Invalid export for command ${command.name}: ${key} does not match expected value`);
2982
+ if (key !== "command") handlerCount++;
2983
+ }
2980
2984
  }
2981
2985
  if (handlerCount === 0) throw new Error(`Invalid export for command ${command.name}: at least one handler function must be provided`);
2982
- let lastUpdated = data.command;
2986
+ let lastUpdated = commandFileData.command;
2983
2987
  await this.commandkit.plugins.execute(async (ctx, plugin) => {
2984
2988
  const res = await plugin.prepareCommand(ctx, lastUpdated);
2985
2989
  if (res) lastUpdated = res;
2986
2990
  });
2987
2991
  this.loadedCommands.set(id, {
2988
2992
  command,
2989
- guilds: data.guilds,
2993
+ guilds: commandFileData.command.guilds,
2990
2994
  data: {
2991
- ...data,
2995
+ ...commandFileData,
2992
2996
  command: "toJSON" in lastUpdated ? lastUpdated.toJSON() : lastUpdated
2993
2997
  }
2994
2998
  });
@@ -4131,4 +4135,4 @@ Object.defineProperty(exports, 'useEnvironment', {
4131
4135
  return useEnvironment;
4132
4136
  }
4133
4137
  });
4134
- //# sourceMappingURL=CommandKit-BwxIJqBr.js.map
4138
+ //# sourceMappingURL=CommandKit-CT3K-Cac.js.map