commandkit 0.1.11-dev.20250404110151 → 0.1.11-dev.20250406075610

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -731,6 +731,36 @@ declare function rethrow(error: unknown): void;
731
731
  */
732
732
  declare function redirect(): never;
733
733
 
734
+ interface PreRegisterCommandsEvent {
735
+ preventDefault(): void;
736
+ commands: CommandData[];
737
+ }
738
+ declare class CommandRegistrar {
739
+ readonly commandkit: CommandKit;
740
+ private api;
741
+ /**
742
+ * Creates an instance of CommandRegistrar.
743
+ * @param commandkit The commandkit instance.
744
+ */
745
+ constructor(commandkit: CommandKit);
746
+ /**
747
+ * Gets the commands data.
748
+ */
749
+ getCommandsData(): CommandData[];
750
+ /**
751
+ * Registers loaded commands.
752
+ */
753
+ register(): Promise<void>;
754
+ /**
755
+ * Updates the global commands.
756
+ */
757
+ updateGlobalCommands(commands: CommandData[]): Promise<void>;
758
+ /**
759
+ * Updates the guild commands.
760
+ */
761
+ updateGuildCommands(commands: CommandData[]): Promise<void>;
762
+ }
763
+
734
764
  type CommandSource = Interaction | Message$1;
735
765
  declare function isMessageSource(source: CommandSource): source is Message$1;
736
766
  declare function isInteractionSource(source: CommandSource): source is Interaction;
@@ -1035,32 +1065,6 @@ declare class MiddlewareContext<T extends CommandExecutionMode = CommandExecutio
1035
1065
  setCommandRunner(fn: RunCommand): void;
1036
1066
  }
1037
1067
 
1038
- declare class CommandRegistrar {
1039
- readonly commandkit: CommandKit;
1040
- private api;
1041
- /**
1042
- * Creates an instance of CommandRegistrar.
1043
- * @param commandkit The commandkit instance.
1044
- */
1045
- constructor(commandkit: CommandKit);
1046
- /**
1047
- * Gets the commands data.
1048
- */
1049
- getCommandsData(): CommandData[];
1050
- /**
1051
- * Registers loaded commands.
1052
- */
1053
- register(): Promise<void>;
1054
- /**
1055
- * Updates the global commands.
1056
- */
1057
- updateGlobalCommands(commands: CommandData[]): Promise<void>;
1058
- /**
1059
- * Updates the guild commands.
1060
- */
1061
- updateGuildCommands(commands: CommandData[]): Promise<void>;
1062
- }
1063
-
1064
1068
  declare class MemoryCache extends CacheProvider {
1065
1069
  #private;
1066
1070
  get<T>(key: string): Promise<CacheEntry<T> | undefined>;
@@ -1578,6 +1582,7 @@ declare abstract class PluginCommon<T extends PluginOptions = PluginOptions, C e
1578
1582
  declare const COMMANDKIT_CACHE_TAG: unique symbol;
1579
1583
  declare const COMMANDKIT_IS_DEV: boolean;
1580
1584
  declare const COMMANDKIT_IS_TEST: boolean;
1585
+ declare const COMMANDKIT_BOOTSTRAP_MODE: "development" | "production";
1581
1586
  /**
1582
1587
  * Types of Hot Module Replacement events
1583
1588
  */
@@ -1664,6 +1669,33 @@ declare abstract class RuntimePlugin<T extends PluginOptions = PluginOptions> ex
1664
1669
  * @param commands The command that is being loaded. This is a CommandBuilderLike object which represents Discord's command
1665
1670
  */
1666
1671
  prepareCommand(ctx: CommandKitPluginRuntime, commands: CommandBuilderLike): Promise<CommandBuilderLike | null>;
1672
+ /**
1673
+ * Called before command is registered to discord. This method can cancel the registration of the command and handle it manually.
1674
+ * @param ctx The context
1675
+ * @param data The command registration data
1676
+ */
1677
+ onBeforeRegisterCommands(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent): Promise<void>;
1678
+ /**
1679
+ * Called before global commands registration. This method can cancel the registration of the command and handle it manually.
1680
+ * This method is called after `onBeforeRegisterCommands` if that stage was not handled.
1681
+ * @param ctx The context
1682
+ * @param event The command registration data
1683
+ */
1684
+ onBeforeRegisterGlobalCommands(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent): Promise<void>;
1685
+ /**
1686
+ * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.
1687
+ * This method is called before guilds of the command are resolved. It is called after `onBeforeRegisterCommands` if that stage was not handled.
1688
+ * @param ctx The context
1689
+ * @param event The command registration data
1690
+ */
1691
+ onBeforePrepareGuildCommandsRegistration(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent): Promise<void>;
1692
+ /**
1693
+ * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.
1694
+ * This method is called after guilds of the command are resolved. It is called after `onBeforePrepareGuildCommandsRegistration` if that stage was not handled.
1695
+ * @param ctx The context
1696
+ * @param event The command registration data
1697
+ */
1698
+ onBeforeRegisterGuildCommands(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent): Promise<void>;
1667
1699
  }
1668
1700
  declare function isRuntimePlugin(plugin: unknown): plugin is RuntimePlugin;
1669
1701
 
@@ -1772,7 +1804,7 @@ interface CommandKitConfig {
1772
1804
  /**
1773
1805
  * The plugins to use with CommandKit.
1774
1806
  */
1775
- plugins?: CommandKitPlugin[];
1807
+ plugins?: MaybeArray<CommandKitPlugin[]>;
1776
1808
  /**
1777
1809
  * The esbuild plugins to use with CommandKit.
1778
1810
  */
@@ -1938,4 +1970,4 @@ declare function devOnly<T extends (...args: any[]) => any>(fn: T): T;
1938
1970
  */
1939
1971
  declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
1940
1972
 
1941
- export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitHMREvent, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, MemoryCache, MentionableSelectMenu, MentionableSelectMenuKit, type MentionableSelectMenuKitPredicate, type MentionableSelectMenuProps, type Message, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type Middleware, MiddlewareContext, type MiddlewareContextArgs, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnChannelSelectMenuKitSubmit, type OnLoadArgs, type OnLoadOptions, type OnLoadResult, type OnMentionableSelectMenuKitSubmit, type OnModalKitEnd, type OnModalKitSubmit, type OnResolveArgs, type OnResolveOptions, type OnResolveResult, type OnRoleSelectMenuKitSubmit, type OnSelectMenuKitEnd, type OnSelectMenuKitSubmit, type OnStringSelectMenuKitSubmit, type OnUserSelectMenuKitSubmit, ParagraphInput, type ParsedCommandData, type ParsedEvent, type ParsedMessageCommand, type PluginTransformParameters, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, type SelectMenuKitPredicate, type SelectMenuProps, type Setup, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextInput, type TextInputProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, exitContext, exitMiddleware, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getSourceDirectories, invalidate, isCachedFunction, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired };
1973
+ export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitHMREvent, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, CommandRegistrar, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, MemoryCache, MentionableSelectMenu, MentionableSelectMenuKit, type MentionableSelectMenuKitPredicate, type MentionableSelectMenuProps, type Message, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type Middleware, MiddlewareContext, type MiddlewareContextArgs, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnChannelSelectMenuKitSubmit, type OnLoadArgs, type OnLoadOptions, type OnLoadResult, type OnMentionableSelectMenuKitSubmit, type OnModalKitEnd, type OnModalKitSubmit, type OnResolveArgs, type OnResolveOptions, type OnResolveResult, type OnRoleSelectMenuKitSubmit, type OnSelectMenuKitEnd, type OnSelectMenuKitSubmit, type OnStringSelectMenuKitSubmit, type OnUserSelectMenuKitSubmit, ParagraphInput, type ParsedCommandData, type ParsedEvent, type ParsedMessageCommand, type PluginTransformParameters, type PreRegisterCommandsEvent, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, type SelectMenuKitPredicate, type SelectMenuProps, type Setup, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextInput, type TextInputProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, exitContext, exitMiddleware, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getSourceDirectories, invalidate, isCachedFunction, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired };
package/dist/index.js CHANGED
@@ -1872,14 +1872,15 @@ var init_components = __esm({
1872
1872
  });
1873
1873
 
1874
1874
  // src/utils/constants.ts
1875
- var COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, HMREventType;
1875
+ var COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, COMMANDKIT_BOOTSTRAP_MODE, HMREventType;
1876
1876
  var init_constants = __esm({
1877
1877
  "src/utils/constants.ts"() {
1878
1878
  "use strict";
1879
1879
  init_cjs_shims();
1880
1880
  COMMANDKIT_CACHE_TAG = Symbol("kCommandKitCacheTag");
1881
- COMMANDKIT_IS_DEV = !!process.env.COMMANDKIT_IS_DEV;
1881
+ COMMANDKIT_IS_DEV = process.env.COMMANDKIT_IS_DEV === "true";
1882
1882
  COMMANDKIT_IS_TEST = process.env.COMMANDKIT_IS_TEST === "true";
1883
+ COMMANDKIT_BOOTSTRAP_MODE = process.env.COMMANDKIT_BOOTSTRAP_MODE || "development";
1883
1884
  HMREventType = {
1884
1885
  ReloadCommands: "reload-commands",
1885
1886
  ReloadEvents: "reload-events",
@@ -2053,6 +2054,37 @@ var init_RuntimePlugin = __esm({
2053
2054
  async prepareCommand(ctx, commands) {
2054
2055
  return null;
2055
2056
  }
2057
+ /**
2058
+ * Called before command is registered to discord. This method can cancel the registration of the command and handle it manually.
2059
+ * @param ctx The context
2060
+ * @param data The command registration data
2061
+ */
2062
+ async onBeforeRegisterCommands(ctx, event) {
2063
+ }
2064
+ /**
2065
+ * Called before global commands registration. This method can cancel the registration of the command and handle it manually.
2066
+ * This method is called after `onBeforeRegisterCommands` if that stage was not handled.
2067
+ * @param ctx The context
2068
+ * @param event The command registration data
2069
+ */
2070
+ async onBeforeRegisterGlobalCommands(ctx, event) {
2071
+ }
2072
+ /**
2073
+ * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.
2074
+ * This method is called before guilds of the command are resolved. It is called after `onBeforeRegisterCommands` if that stage was not handled.
2075
+ * @param ctx The context
2076
+ * @param event The command registration data
2077
+ */
2078
+ async onBeforePrepareGuildCommandsRegistration(ctx, event) {
2079
+ }
2080
+ /**
2081
+ * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.
2082
+ * This method is called after guilds of the command are resolved. It is called after `onBeforePrepareGuildCommandsRegistration` if that stage was not handled.
2083
+ * @param ctx The context
2084
+ * @param event The command registration data
2085
+ */
2086
+ async onBeforeRegisterGuildCommands(ctx, event) {
2087
+ }
2056
2088
  };
2057
2089
  __name(_RuntimePlugin, "RuntimePlugin");
2058
2090
  RuntimePlugin = _RuntimePlugin;
@@ -2810,7 +2842,10 @@ function defineConfig(config = {}) {
2810
2842
  ...config.esbuildPlugins ?? [],
2811
2843
  ...defaultConfig.esbuildPlugins ?? []
2812
2844
  ],
2813
- plugins: [...config.plugins ?? [], ...defaultConfig.plugins ?? []],
2845
+ plugins: [
2846
+ ...config.plugins ?? [],
2847
+ ...defaultConfig.plugins ?? []
2848
+ ],
2814
2849
  sourceMap: {
2815
2850
  ...defaultConfig.sourceMap,
2816
2851
  ...config.sourceMap
@@ -3201,10 +3236,22 @@ var init_CommandRegistrar = __esm({
3201
3236
  * Registers loaded commands.
3202
3237
  */
3203
3238
  async register() {
3239
+ const commands = this.getCommandsData();
3240
+ let preRegistrationPrevented = false;
3241
+ const preRegisterEvent = {
3242
+ preventDefault() {
3243
+ preRegistrationPrevented = true;
3244
+ },
3245
+ commands
3246
+ };
3247
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
3248
+ if (preRegistrationPrevented) return;
3249
+ return plugin.onBeforeRegisterCommands(ctx, preRegisterEvent);
3250
+ });
3251
+ if (preRegistrationPrevented) return;
3204
3252
  if (!this.commandkit.client.isReady()) {
3205
3253
  throw new Error("Cannot register commands before the client is ready");
3206
3254
  }
3207
- const commands = this.getCommandsData();
3208
3255
  const guildCommands = commands.filter((command) => {
3209
3256
  var _a;
3210
3257
  return (_a = command.guilds) == null ? void 0 : _a.filter(Boolean).length;
@@ -3229,6 +3276,17 @@ var init_CommandRegistrar = __esm({
3229
3276
  */
3230
3277
  async updateGlobalCommands(commands) {
3231
3278
  if (!commands.length) return;
3279
+ let prevented = false;
3280
+ const preRegisterEvent = {
3281
+ preventDefault() {
3282
+ prevented = true;
3283
+ },
3284
+ commands
3285
+ };
3286
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
3287
+ if (prevented) return;
3288
+ return plugin.onBeforeRegisterGlobalCommands(ctx, preRegisterEvent);
3289
+ });
3232
3290
  try {
3233
3291
  const data = await this.api.put(
3234
3292
  import_discord14.Routes.applicationCommands(this.commandkit.client.user.id),
@@ -3250,6 +3308,22 @@ var init_CommandRegistrar = __esm({
3250
3308
  * Updates the guild commands.
3251
3309
  */
3252
3310
  async updateGuildCommands(commands) {
3311
+ if (!commands.length) return;
3312
+ let prevented = false;
3313
+ const preRegisterEvent = {
3314
+ preventDefault() {
3315
+ prevented = true;
3316
+ },
3317
+ commands
3318
+ };
3319
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
3320
+ if (prevented) return;
3321
+ return plugin.onBeforePrepareGuildCommandsRegistration(
3322
+ ctx,
3323
+ preRegisterEvent
3324
+ );
3325
+ });
3326
+ if (prevented) return;
3253
3327
  try {
3254
3328
  const guildCommandsMap = /* @__PURE__ */ new Map();
3255
3329
  commands.forEach((command) => {
@@ -3265,6 +3339,18 @@ var init_CommandRegistrar = __esm({
3265
3339
  if (!guildCommandsMap.size) return;
3266
3340
  let count = 0;
3267
3341
  for (const [guild, guildCommands] of guildCommandsMap) {
3342
+ let prevented2 = false;
3343
+ const preRegisterEvent2 = {
3344
+ preventDefault() {
3345
+ prevented2 = true;
3346
+ },
3347
+ commands: guildCommands
3348
+ };
3349
+ await this.commandkit.plugins.execute(async (ctx, plugin) => {
3350
+ if (prevented2) return;
3351
+ return plugin.onBeforeRegisterGuildCommands(ctx, preRegisterEvent2);
3352
+ });
3353
+ if (prevented2) continue;
3268
3354
  const data = await this.api.put(
3269
3355
  import_discord14.Routes.applicationGuildCommands(
3270
3356
  this.commandkit.client.user.id,
@@ -5048,6 +5134,26 @@ async function ensureExists(loc) {
5048
5134
  throw new Error(`File not found: ${loc}`);
5049
5135
  }
5050
5136
  }
5137
+ async function copyLocaleFiles(_from, _to) {
5138
+ const resolvedFrom = (0, import_node_path5.join)(process.cwd(), _from);
5139
+ const resolvedTo = (0, import_node_path5.join)(process.cwd(), _to);
5140
+ const localePaths = ["app/locales"];
5141
+ const srcLocalePaths = localePaths.map((path3) => (0, import_node_path5.join)(resolvedFrom, path3));
5142
+ const destLocalePaths = localePaths.map((path3) => (0, import_node_path5.join)(resolvedTo, path3));
5143
+ for (const localePath of srcLocalePaths) {
5144
+ if (!import_node_fs5.default.existsSync(localePath)) {
5145
+ continue;
5146
+ }
5147
+ const destLocalePath = destLocalePaths[srcLocalePaths.indexOf(localePath)];
5148
+ if (!import_node_fs5.default.existsSync(destLocalePath)) {
5149
+ import_node_fs5.default.promises.mkdir(destLocalePath, { recursive: true });
5150
+ }
5151
+ await import_node_fs5.default.promises.cp(localePath, destLocalePath, {
5152
+ recursive: true,
5153
+ force: true
5154
+ });
5155
+ }
5156
+ }
5051
5157
  var import_rimraf, import_node_path5, import_node_fs5, ts;
5052
5158
  var init_common2 = __esm({
5053
5159
  "src/cli/common.ts"() {
@@ -5064,6 +5170,7 @@ var init_common2 = __esm({
5064
5170
  __name(loadTypeScript, "loadTypeScript");
5065
5171
  __name(loadConfigFileFromPath, "loadConfigFileFromPath");
5066
5172
  __name(ensureExists, "ensureExists");
5173
+ __name(copyLocaleFiles, "copyLocaleFiles");
5067
5174
  }
5068
5175
  });
5069
5176
 
@@ -5330,7 +5437,7 @@ var init_CommandKit = __esm({
5330
5437
  return (_a = plugin.onBeforeClientLogin) == null ? void 0 : _a.call(plugin, ctx);
5331
5438
  });
5332
5439
  await this.options.client.login(
5333
- token ?? process.env.TOKEN ?? process.env.DISCORD_TOKEN
5440
+ token ?? this.options.client.token ?? process.env.TOKEN ?? process.env.DISCORD_TOKEN
5334
5441
  );
5335
5442
  await this.plugins.execute((ctx, plugin) => {
5336
5443
  var _a;
@@ -5346,7 +5453,7 @@ var init_CommandKit = __esm({
5346
5453
  */
5347
5454
  async loadPlugins() {
5348
5455
  const config = await loadConfigFile();
5349
- const plugins = config.plugins.filter((p) => isRuntimePlugin(p));
5456
+ const plugins = config.plugins.flat(2).filter((p) => isRuntimePlugin(p));
5350
5457
  if (!plugins.length) return;
5351
5458
  for (const plugin of plugins) {
5352
5459
  await this.plugins.softRegisterPlugin(plugin);
@@ -5510,7 +5617,7 @@ var init_version = __esm({
5510
5617
  "use strict";
5511
5618
  init_cjs_shims();
5512
5619
  version = /* @__MACRO__ $version */
5513
- "0.1.11-dev.20250404110151";
5620
+ "0.1.11-dev.20250406075610";
5514
5621
  }
5515
5622
  });
5516
5623
 
@@ -5750,6 +5857,7 @@ async function buildApplication({
5750
5857
  "!**/*.spec.*"
5751
5858
  ]
5752
5859
  });
5860
+ await copyLocaleFiles("src", dest);
5753
5861
  await injectEntryFile(configPath || process.cwd(), !!isDev, config.distDir);
5754
5862
  } catch (error) {
5755
5863
  console.error("Build failed:", error);
@@ -5801,6 +5909,7 @@ var init_build = __esm({
5801
5909
  init_env();
5802
5910
  import_rimraf2 = require("rimraf");
5803
5911
  init_type_checker();
5912
+ init_common2();
5804
5913
  __name(buildApplication, "buildApplication");
5805
5914
  envScript = /* @__PURE__ */ __name((dev) => `// --- Environment Variables Loader ---
5806
5915
  const $env = [${(dev ? devEnvFileArgs : prodEnvFileArgs).map((p) => `"${p}"`).join(", ")}];
@@ -5861,7 +5970,7 @@ async function buildAndStart(configPath, skipStart = false) {
5861
5970
  await buildApplication({
5862
5971
  configPath,
5863
5972
  isDev: true,
5864
- plugins: config.plugins.filter((p) => isCompilerPlugin(p)),
5973
+ plugins: config.plugins.flat(2).filter((p) => isCompilerPlugin(p)),
5865
5974
  esbuildPlugins: config.esbuildPlugins
5866
5975
  });
5867
5976
  if (skipStart) return null;
@@ -5869,6 +5978,7 @@ async function buildAndStart(configPath, skipStart = false) {
5869
5978
  return ps;
5870
5979
  }
5871
5980
  async function bootstrapDevelopmentServer(configPath) {
5981
+ process.env.COMMANDKIT_BOOTSTRAP_MODE = "development";
5872
5982
  const start = performance.now();
5873
5983
  const cwd = configPath || process.cwd();
5874
5984
  const configPaths = getPossibleConfigPaths(cwd);
@@ -5960,6 +6070,7 @@ async function bootstrapDevelopmentServer(configPath) {
5960
6070
  }, 300);
5961
6071
  const isConfigUpdate = /* @__PURE__ */ __name((path3) => {
5962
6072
  const isConfig = configPaths.some((configPath2) => path3 === configPath2);
6073
+ if (!isConfig) return false;
5963
6074
  console.log(
5964
6075
  colors_default.yellowBright(
5965
6076
  "It seems like commandkit config file was updated, please restart the server manually to apply changes."
@@ -6065,6 +6176,7 @@ __export(production_exports, {
6065
6176
  createProductionBuild: () => createProductionBuild
6066
6177
  });
6067
6178
  async function bootstrapProductionServer(configPath) {
6179
+ process.env.COMMANDKIT_BOOTSTRAP_MODE = "production";
6068
6180
  const cwd = configPath || process.cwd();
6069
6181
  const config = await loadConfigFile(cwd);
6070
6182
  const mainFile = (0, import_path3.join)(config.distDir, "index.js");
@@ -6076,6 +6188,7 @@ async function bootstrapProductionServer(configPath) {
6076
6188
  return createAppProcess(mainFile, cwd, true);
6077
6189
  }
6078
6190
  async function createProductionBuild(configPath) {
6191
+ process.env.COMMANDKIT_BOOTSTRAP_MODE = "production";
6079
6192
  const cwd = configPath || process.cwd();
6080
6193
  const config = await loadConfigFile(cwd);
6081
6194
  const spinner = await createSpinner(
@@ -6378,6 +6491,7 @@ __export(index_exports, {
6378
6491
  AppCommandHandler: () => AppCommandHandler,
6379
6492
  Button: () => Button,
6380
6493
  ButtonKit: () => ButtonKit,
6494
+ COMMANDKIT_BOOTSTRAP_MODE: () => COMMANDKIT_BOOTSTRAP_MODE,
6381
6495
  COMMANDKIT_CACHE_TAG: () => COMMANDKIT_CACHE_TAG,
6382
6496
  COMMANDKIT_IS_DEV: () => COMMANDKIT_IS_DEV,
6383
6497
  COMMANDKIT_IS_TEST: () => COMMANDKIT_IS_TEST,
@@ -6389,6 +6503,7 @@ __export(index_exports, {
6389
6503
  CommandKitEnvironment: () => CommandKitEnvironment,
6390
6504
  CommandKitEnvironmentType: () => CommandKitEnvironmentType,
6391
6505
  CommandKitPluginRuntime: () => CommandKitPluginRuntime,
6506
+ CommandRegistrar: () => CommandRegistrar,
6392
6507
  CommandsRouter: () => CommandsRouter,
6393
6508
  CompilerPlugin: () => CompilerPlugin,
6394
6509
  CompilerPluginRuntime: () => CompilerPluginRuntime,
@@ -6473,6 +6588,7 @@ init_AppCommandHandler();
6473
6588
  init_Context();
6474
6589
  init_MessageCommandParser();
6475
6590
  init_signals();
6591
+ init_CommandRegistrar();
6476
6592
 
6477
6593
  // src/app/commands/helpers.ts
6478
6594
  init_cjs_shims();
@@ -6563,6 +6679,7 @@ var index_default = CommandKit;
6563
6679
  AppCommandHandler,
6564
6680
  Button,
6565
6681
  ButtonKit,
6682
+ COMMANDKIT_BOOTSTRAP_MODE,
6566
6683
  COMMANDKIT_CACHE_TAG,
6567
6684
  COMMANDKIT_IS_DEV,
6568
6685
  COMMANDKIT_IS_TEST,
@@ -6574,6 +6691,7 @@ var index_default = CommandKit;
6574
6691
  CommandKitEnvironment,
6575
6692
  CommandKitEnvironmentType,
6576
6693
  CommandKitPluginRuntime,
6694
+ CommandRegistrar,
6577
6695
  CommandsRouter,
6578
6696
  CompilerPlugin,
6579
6697
  CompilerPluginRuntime,