commandkit 0.1.11-dev.20250402134911 → 0.1.11-dev.20250403165006
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/LICENSE +5 -0
- package/dist/index.d.ts +9 -116
- package/dist/index.js +325 -580
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Copyright 2025 Avraj Sahota
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
|
|
4
|
+
|
|
5
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
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,
|
|
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';
|
|
3
3
|
import EventEmitter from 'node:events';
|
|
4
4
|
import { Channel } from 'diagnostics_channel';
|
|
5
5
|
import * as commander from 'commander';
|
|
@@ -629,88 +629,6 @@ interface ChannelSelectMenuProps extends Partial<Omit<ChannelSelectMenuComponent
|
|
|
629
629
|
}
|
|
630
630
|
declare function ChannelSelectMenu(props: ChannelSelectMenuProps): ChannelSelectMenuKit;
|
|
631
631
|
|
|
632
|
-
interface TranslatableCommand {
|
|
633
|
-
name?: string;
|
|
634
|
-
description?: string;
|
|
635
|
-
options?: TranslatableCommandOptions[];
|
|
636
|
-
}
|
|
637
|
-
interface TranslatableCommandOptions {
|
|
638
|
-
ref: string;
|
|
639
|
-
name?: string;
|
|
640
|
-
description?: string;
|
|
641
|
-
options?: TranslatableCommandOptions[];
|
|
642
|
-
}
|
|
643
|
-
interface ApiTranslatableCommandOptions extends TranslatableCommandOptions {
|
|
644
|
-
name_localizations?: LocalizationMap;
|
|
645
|
-
description_localizations?: LocalizationMap;
|
|
646
|
-
}
|
|
647
|
-
interface CommandLocalizationTypeData {
|
|
648
|
-
[key: string]: Record<string, string | null>;
|
|
649
|
-
}
|
|
650
|
-
type TranslatableCommandName = string & {};
|
|
651
|
-
interface Translation {
|
|
652
|
-
command: TranslatableCommand;
|
|
653
|
-
translations: Record<string, string>;
|
|
654
|
-
}
|
|
655
|
-
type TranslatableArguments<T extends TranslatableCommandName> = T extends TranslatableCommandName ? CommandLocalizationTypeData[T] extends Record<string, infer ArgType> ? ArgType extends null ? never : Record<string, string> : Record<string, string> : Record<string, string>;
|
|
656
|
-
|
|
657
|
-
interface LocalizationTranslationRequest {
|
|
658
|
-
locale: Locale;
|
|
659
|
-
scope: string;
|
|
660
|
-
key: string;
|
|
661
|
-
args?: Record<string, any> | undefined;
|
|
662
|
-
}
|
|
663
|
-
type TranslationResult = string;
|
|
664
|
-
interface LocalizationStrategy {
|
|
665
|
-
locateTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
666
|
-
getTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
667
|
-
getTranslationStrict(scope: string, locale: Locale): Promise<Translation>;
|
|
668
|
-
translate(request: LocalizationTranslationRequest): Promise<TranslationResult>;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
interface LocalizationConfig {
|
|
672
|
-
/**
|
|
673
|
-
* The locale to use for localization.
|
|
674
|
-
*/
|
|
675
|
-
locale: Locale;
|
|
676
|
-
/**
|
|
677
|
-
* The internalization data target.
|
|
678
|
-
*/
|
|
679
|
-
target: string;
|
|
680
|
-
}
|
|
681
|
-
type Translator<T extends TranslatableCommandName> = <K extends keyof CommandLocalizationTypeData[T] & string>(key: K, args?: CommandLocalizationTypeData[T][K] extends null ? never : CommandLocalizationTypeData[T][K] extends string ? Record<CommandLocalizationTypeData[T][K], string> : Record<string, string>) => Promise<TranslationResult>;
|
|
682
|
-
declare class Localization<T extends TranslatableCommandName = string> {
|
|
683
|
-
private readonly commandkit;
|
|
684
|
-
private readonly config;
|
|
685
|
-
/**
|
|
686
|
-
* Translates the given translatable object.
|
|
687
|
-
* @param translatable The translatable object to translate.
|
|
688
|
-
*/
|
|
689
|
-
readonly t: Translator<T>;
|
|
690
|
-
/**
|
|
691
|
-
* Creates a new localization instance.
|
|
692
|
-
* @param commandkit The command kit instance.
|
|
693
|
-
* @param config The localization configuration.
|
|
694
|
-
*/
|
|
695
|
-
constructor(commandkit: CommandKit, config: LocalizationConfig);
|
|
696
|
-
/**
|
|
697
|
-
* Get the localization strategy.
|
|
698
|
-
*/
|
|
699
|
-
getStrategy(): LocalizationStrategy;
|
|
700
|
-
/**
|
|
701
|
-
* Get the default locale
|
|
702
|
-
*/
|
|
703
|
-
getDefaultLocale(): Locale;
|
|
704
|
-
/**
|
|
705
|
-
* Get the current locale
|
|
706
|
-
*/
|
|
707
|
-
getLocale(): Locale;
|
|
708
|
-
/**
|
|
709
|
-
* Get the localization target
|
|
710
|
-
*/
|
|
711
|
-
getTarget(): string;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
632
|
interface ParsedMessageCommand {
|
|
715
633
|
command: string;
|
|
716
634
|
options: {
|
|
@@ -796,18 +714,6 @@ declare function getContext(): CommandKitEnvironment | undefined;
|
|
|
796
714
|
*/
|
|
797
715
|
declare function useEnvironment(): CommandKitEnvironment;
|
|
798
716
|
|
|
799
|
-
declare class DefaultLocalizationStrategy implements LocalizationStrategy {
|
|
800
|
-
private readonly commandkit;
|
|
801
|
-
private translations;
|
|
802
|
-
constructor(commandkit: CommandKit);
|
|
803
|
-
locateTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
804
|
-
private generateLocaleTypes;
|
|
805
|
-
getTranslationStrict(scope: string, locale: Locale): Promise<Translation>;
|
|
806
|
-
getTranslation(scope: string, locale: Locale): Promise<Translation | null>;
|
|
807
|
-
translate(request: LocalizationTranslationRequest): Promise<TranslationResult>;
|
|
808
|
-
private applyTranslation;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
717
|
/**
|
|
812
718
|
* Cancel upcoming middleware execution.
|
|
813
719
|
* If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.
|
|
@@ -1077,12 +983,6 @@ declare class Context<ExecutionMode extends CommandExecutionMode = CommandExecut
|
|
|
1077
983
|
* @param locale The locale to set.
|
|
1078
984
|
*/
|
|
1079
985
|
setLocale(locale: Locale | null): void;
|
|
1080
|
-
/**
|
|
1081
|
-
* Returns the i18n api for this command.
|
|
1082
|
-
* @param locale The locale to use for the i18n api.
|
|
1083
|
-
* @template T The command name for type-safe translations. Will provide autocomplete from available translations.
|
|
1084
|
-
*/
|
|
1085
|
-
locale<T extends TranslatableCommandName | (string & {}) = string>(locale?: Locale): Localization<T extends TranslatableCommandName ? T : string>;
|
|
1086
986
|
/**
|
|
1087
987
|
* Creates a clone of this context
|
|
1088
988
|
*/
|
|
@@ -1492,7 +1392,6 @@ declare class AppCommandHandler {
|
|
|
1492
1392
|
loadCommands(): Promise<void>;
|
|
1493
1393
|
private loadMiddleware;
|
|
1494
1394
|
private loadCommand;
|
|
1495
|
-
applyLocalizations(command: CommandBuilderLike): Promise<CommandBuilderLike>;
|
|
1496
1395
|
}
|
|
1497
1396
|
|
|
1498
1397
|
type ListenerFunction = GenericFunction | AsyncFunction;
|
|
@@ -1684,7 +1583,6 @@ declare const COMMANDKIT_IS_TEST: boolean;
|
|
|
1684
1583
|
declare const HMREventType: {
|
|
1685
1584
|
readonly ReloadCommands: "reload-commands";
|
|
1686
1585
|
readonly ReloadEvents: "reload-events";
|
|
1687
|
-
readonly ReloadLocales: "reload-locales";
|
|
1688
1586
|
readonly Unknown: "unknown";
|
|
1689
1587
|
};
|
|
1690
1588
|
type HMREventType = (typeof HMREventType)[keyof typeof HMREventType];
|
|
@@ -1759,6 +1657,12 @@ declare abstract class RuntimePlugin<T extends PluginOptions = PluginOptions> ex
|
|
|
1759
1657
|
* @param event The event
|
|
1760
1658
|
*/
|
|
1761
1659
|
performHMR(ctx: CommandKitPluginRuntime, event: CommandKitHMREvent): Promise<void>;
|
|
1660
|
+
/**
|
|
1661
|
+
* Called before command is loaded for registration. This method can be used to modify the command data before it is loaded.
|
|
1662
|
+
* @param ctx The context
|
|
1663
|
+
* @param commands The command that is being loaded. This is a CommandBuilderLike object which represents Discord's command
|
|
1664
|
+
*/
|
|
1665
|
+
prepareCommand(ctx: CommandKitPluginRuntime, commands: CommandBuilderLike): Promise<CommandBuilderLike | null>;
|
|
1762
1666
|
}
|
|
1763
1667
|
declare function isRuntimePlugin(plugin: unknown): plugin is RuntimePlugin;
|
|
1764
1668
|
|
|
@@ -1777,7 +1681,6 @@ declare class CommandKitPluginRuntime {
|
|
|
1777
1681
|
|
|
1778
1682
|
interface CommandKitConfiguration {
|
|
1779
1683
|
defaultLocale: Locale;
|
|
1780
|
-
localizationStrategy: LocalizationStrategy;
|
|
1781
1684
|
getMessageCommandPrefix: (message: Message$1) => Awaitable<string | string[]>;
|
|
1782
1685
|
}
|
|
1783
1686
|
declare let commandkit: CommandKit;
|
|
@@ -1830,11 +1733,6 @@ declare class CommandKit extends EventEmitter {
|
|
|
1830
1733
|
* @param provider The cache provider.
|
|
1831
1734
|
*/
|
|
1832
1735
|
setCacheProvider(provider: CacheProvider): this;
|
|
1833
|
-
/**
|
|
1834
|
-
* Sets the localization strategy for the command handler.
|
|
1835
|
-
* @param strategy The localization strategy.
|
|
1836
|
-
*/
|
|
1837
|
-
setLocalizationStrategy(strategy: LocalizationStrategy): this;
|
|
1838
1736
|
/**
|
|
1839
1737
|
* Resolves the current cache provider.
|
|
1840
1738
|
*/
|
|
@@ -1866,7 +1764,7 @@ declare class CommandKit extends EventEmitter {
|
|
|
1866
1764
|
* - `./src/app`
|
|
1867
1765
|
*/
|
|
1868
1766
|
getAppDirectory(): string | null;
|
|
1869
|
-
getPath(to: '
|
|
1767
|
+
getPath(to: 'commands' | 'events'): string | null;
|
|
1870
1768
|
}
|
|
1871
1769
|
|
|
1872
1770
|
interface CommandKitConfig {
|
|
@@ -1937,11 +1835,6 @@ interface CommandKitConfig {
|
|
|
1937
1835
|
*/
|
|
1938
1836
|
production?: boolean;
|
|
1939
1837
|
};
|
|
1940
|
-
/**
|
|
1941
|
-
* Whether or not to enable typed locales.
|
|
1942
|
-
* @default true
|
|
1943
|
-
*/
|
|
1944
|
-
typedLocales?: boolean;
|
|
1945
1838
|
/**
|
|
1946
1839
|
* Whether or not to enable the typed commands.
|
|
1947
1840
|
* @default true
|
|
@@ -2024,4 +1917,4 @@ declare function getSourceDirectories(): string[];
|
|
|
2024
1917
|
*/
|
|
2025
1918
|
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
2026
1919
|
|
|
2027
|
-
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement,
|
|
1920
|
+
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, CommandKit as default, defineConfig, 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 };
|