commandkit 0.1.11-dev.20250411164423 → 0.1.11-dev.20250417143532

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
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { RESTPostAPIApplicationCommandsJSONBody, Client, Interaction, CacheType, ClientEvents, Awaitable, ButtonBuilder, ButtonInteraction, Events, ModalBuilder, ModalSubmitInteraction, ActionRowBuilder, TextInputBuilder, ButtonStyle, ComponentEmojiResolvable, TextInputStyle, StringSelectMenuInteraction, StringSelectMenuBuilder, ChannelSelectMenuInteraction, ChannelSelectMenuBuilder, MentionableSelectMenuInteraction, MentionableSelectMenuBuilder, UserSelectMenuInteraction, UserSelectMenuBuilder, RoleSelectMenuInteraction, RoleSelectMenuBuilder, BaseSelectMenuComponentData, StringSelectMenuOptionBuilder, SelectMenuComponentOptionData, APISelectMenuOption, UserSelectMenuComponentData, RoleSelectMenuComponentData, MentionableSelectMenuComponentData, ChannelSelectMenuComponentData, Message as Message$1, ApplicationCommandOptionType, GuildMember, Attachment, User, Role, CommandInteractionOption, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, AutocompleteInteraction, Locale, Collection, SlashCommandBuilder, ContextMenuCommandBuilder, PartialMessage } from 'discord.js';
2
+ import { RESTPostAPIApplicationCommandsJSONBody, Client, Interaction, CacheType, ClientEvents, Awaitable, ButtonBuilder, ButtonInteraction, Events, ModalBuilder, ModalSubmitInteraction, ActionRowBuilder, TextInputBuilder, ButtonStyle, ComponentEmojiResolvable, TextInputStyle, StringSelectMenuInteraction, StringSelectMenuBuilder, ChannelSelectMenuInteraction, ChannelSelectMenuBuilder, MentionableSelectMenuInteraction, MentionableSelectMenuBuilder, UserSelectMenuInteraction, UserSelectMenuBuilder, RoleSelectMenuInteraction, RoleSelectMenuBuilder, BaseSelectMenuComponentData, StringSelectMenuOptionBuilder, SelectMenuComponentOptionData, APISelectMenuOption, UserSelectMenuComponentData, RoleSelectMenuComponentData, MentionableSelectMenuComponentData, ChannelSelectMenuComponentData, Message as Message$1, ApplicationCommandOptionType, GuildMember, Attachment, User, Role, CommandInteractionOption, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, AutocompleteInteraction, Guild, TextBasedChannel, Locale, Collection, SlashCommandBuilder, ContextMenuCommandBuilder } from 'discord.js';
3
3
  import EventEmitter from 'node:events';
4
4
  import { Channel } from 'diagnostics_channel';
5
5
  import * as commander from 'commander';
@@ -871,15 +871,15 @@ declare enum CommandKitEnvironmentType {
871
871
  * @param fn The function to run after the current command.
872
872
  * @returns The deferred function id. This can be used to cancel the deferred function.
873
873
  */
874
- declare function afterCommand(fn: GenericFunction<[CommandKitEnvironment]>): string;
874
+ declare function after(fn: GenericFunction<[CommandKitEnvironment]>): string;
875
875
  /**
876
- * Cancels a deferred function registered with `afterCommand`.
876
+ * Cancels a deferred function registered with `after`.
877
877
  * @param id The deferred function id to cancel.
878
878
  */
879
- declare function cancelAfterCommand(id: string): void;
879
+ declare function cancelAfter(id: string): void;
880
880
 
881
881
  declare const CommandExecutionMode: {
882
- readonly SlashCommand: "chatInput";
882
+ readonly ChatInputCommand: "chatInput";
883
883
  readonly MessageContextMenu: "messageContextMenu";
884
884
  readonly UserContextMenu: "userContextMenu";
885
885
  readonly Autocomplete: "autocomplete";
@@ -901,7 +901,7 @@ type MessageCommandContext = Context<'message'>;
901
901
  type InteractionCommandContext = Context<'autocomplete' | 'chatInput' | 'messageContextMenu' | 'userContextMenu'>;
902
902
  type MessageCommandMiddlewareContext = MiddlewareContext<'message'>;
903
903
  type InteractionCommandMiddlewareContext = MiddlewareContext<'autocomplete' | 'chatInput' | 'messageContextMenu' | 'userContextMenu'>;
904
- type SlashCommandContext = Context<'chatInput'>;
904
+ type ChatInputCommandContext = Context<'chatInput'>;
905
905
  type SlashCommandMiddlewareContext = MiddlewareContext<'chatInput'>;
906
906
  type AutocompleteCommandContext = Context<'autocomplete'>;
907
907
  type AutocompleteCommandMiddlewareContext = MiddlewareContext<'autocomplete'>;
@@ -911,7 +911,7 @@ type UserContextMenuCommandContext = Context<'userContextMenu'>;
911
911
  type UserContextMenuCommandMiddlewareContext = MiddlewareContext<'userContextMenu'>;
912
912
  type CommandContextOptions<T extends CommandExecutionMode> = T extends 'message' ? MessageCommandOptions : T extends 'chatInput' ? ChatInputCommandInteraction['options'] : T extends 'autocomplete' ? AutocompleteInteraction['options'] : T extends 'messageContextMenu' ? MessageContextMenuCommandInteraction['options'] : T extends 'userContextMenu' ? UserContextMenuCommandInteraction['options'] : never;
913
913
  type AnyCommandExecute<ContextType extends Context = Context> = (ctx: ContextType) => Awaitable<unknown>;
914
- type SlashCommand = AnyCommandExecute<SlashCommandContext>;
914
+ type ChatInputCommand = AnyCommandExecute<ChatInputCommandContext>;
915
915
  type AutocompleteCommand = AnyCommandExecute<AutocompleteCommandContext>;
916
916
  type MessageContextMenuCommand = AnyCommandExecute<MessageContextMenuCommandContext>;
917
917
  type UserContextMenuCommand = AnyCommandExecute<UserContextMenuCommandContext>;
@@ -931,6 +931,22 @@ declare class Context<ExecutionMode extends CommandExecutionMode = CommandExecut
931
931
  * The message that triggered the command.
932
932
  */
933
933
  readonly message: ContextParameters<ExecutionMode>['message'];
934
+ /**
935
+ * The guild where the command was triggered.
936
+ */
937
+ readonly guild: Guild | null;
938
+ /**
939
+ * The guild ID where the command was triggered.
940
+ */
941
+ readonly guildId: string | null;
942
+ /**
943
+ * The channel where the command was triggered.
944
+ */
945
+ readonly channel: TextBasedChannel | null;
946
+ /**
947
+ * The channel id where the command was triggered.
948
+ */
949
+ readonly channelId: string | null;
934
950
  /**
935
951
  * The client instance.
936
952
  */
@@ -973,7 +989,7 @@ declare class Context<ExecutionMode extends CommandExecutionMode = CommandExecut
973
989
  /**
974
990
  * Whether the command was triggered by a slash command interaction.
975
991
  */
976
- isSlashCommand(): this is SlashCommandContext;
992
+ isChatInputCommand(): this is ChatInputCommandContext;
977
993
  /**
978
994
  * Whether the command was triggered by an autocomplete interaction.
979
995
  */
@@ -1026,22 +1042,6 @@ declare class Context<ExecutionMode extends CommandExecutionMode = CommandExecut
1026
1042
  * If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
1027
1043
  */
1028
1044
  exit(): void;
1029
- /**
1030
- * Defers the given function to be executed after this command's execution.
1031
- * @param fn The function to defer.
1032
- * @returns A unique identifier for the deferred function.
1033
- */
1034
- defer(fn: GenericFunction<[CommandKitEnvironment]>): string;
1035
- /**
1036
- * Cancels the deferred function with the given identifier.
1037
- * @param id The identifier of the deferred function.
1038
- */
1039
- cancelDeferred(id: string): void;
1040
- /**
1041
- * Validates if the given function is a cached function.
1042
- * @param fn The function to validate.
1043
- */
1044
- isCached(fn: GenericFunction): boolean;
1045
1045
  }
1046
1046
  declare class MiddlewareContext<T extends CommandExecutionMode = CommandExecutionMode> extends Context<T, MiddlewareContextArgs> {
1047
1047
  #private;
@@ -1379,7 +1379,6 @@ declare class AppCommandHandler {
1379
1379
  readonly registrar: CommandRegistrar;
1380
1380
  private onInteraction;
1381
1381
  private onMessageCreate;
1382
- private onMessageUpdate;
1383
1382
  readonly commandRunner: AppCommandRunner;
1384
1383
  readonly externalCommandData: Collection<string, Command>;
1385
1384
  readonly externalMiddlewareData: Collection<string, Middleware>;
@@ -1634,11 +1633,6 @@ declare abstract class RuntimePlugin<T extends PluginOptions = PluginOptions> ex
1634
1633
  * @param message The message
1635
1634
  */
1636
1635
  onBeforeMessageCommand(ctx: CommandKitPluginRuntime, message: Message$1): Promise<void>;
1637
- /**
1638
- * Called before message update command is processed
1639
- * @param message The message
1640
- */
1641
- onBeforeMessageUpdateCommand(ctx: CommandKitPluginRuntime, oldMessage: Message$1 | PartialMessage, newMessage: Message$1 | PartialMessage): Promise<void>;
1642
1636
  /**
1643
1637
  * Called before command is executed. This method can execute the command itself.
1644
1638
  * @param source The source that triggered the command
@@ -1695,6 +1689,12 @@ declare abstract class RuntimePlugin<T extends PluginOptions = PluginOptions> ex
1695
1689
  * @param event The command registration data
1696
1690
  */
1697
1691
  onBeforeRegisterGuildCommands(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent): Promise<void>;
1692
+ /**
1693
+ * Called after command and all of its deferred functions are executed.
1694
+ * @param ctx The context
1695
+ * @param env The environment of the command. This environment contains the command execution data such as command context and more.
1696
+ */
1697
+ onAfterCommand(ctx: CommandKitPluginRuntime, env: CommandKitEnvironment): Promise<void>;
1698
1698
  }
1699
1699
  declare function isRuntimePlugin(plugin: unknown): plugin is RuntimePlugin;
1700
1700
 
@@ -1998,4 +1998,4 @@ declare function devOnly<T extends (...args: any[]) => any>(fn: T): T;
1998
1998
  */
1999
1999
  declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
2000
2000
 
2001
- export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, type BootstrapFunction, 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, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zxcvbnm____ };
2001
+ export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, type BootstrapFunction, 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 ChatInputCommand, type ChatInputCommandContext, 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 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, after, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfter, 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, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zxcvbnm____ };