commandkit 1.0.0-dev.20250514131945 → 1.0.0-dev.20250515152130
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 +59 -2
- package/dist/index.js +147 -25
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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, ContainerComponentData, ComponentBuilder, ContainerBuilder, FileComponentData, FileBuilder, MediaGalleryItemBuilder, MediaGalleryBuilder, ThumbnailBuilder, TextDisplayBuilder, SectionBuilder, SeparatorComponentData, SeparatorBuilder, TextDisplayComponentData, Message as Message$1, ApplicationCommandOptionType, GuildMember, Attachment, User, Role, CommandInteractionOption, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, AutocompleteInteraction, Guild, TextBasedChannel, Locale, Collection, SlashCommandBuilder, ContextMenuCommandBuilder } 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, ContainerComponentData, ComponentBuilder, ContainerBuilder, FileComponentData, FileBuilder, MediaGalleryItemBuilder, MediaGalleryBuilder, ThumbnailBuilder, TextDisplayBuilder, SectionBuilder, SeparatorComponentData, SeparatorBuilder, TextDisplayComponentData, Message as Message$1, ApplicationCommandOptionType, GuildMember, Attachment, User, Role, CommandInteractionOption, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, AutocompleteInteraction, Guild, TextBasedChannel, Locale, Collection, SlashCommandBuilder, ContextMenuCommandBuilder, ContextMenuCommandInteraction } from 'discord.js';
|
|
3
3
|
import EventEmitter from 'node:events';
|
|
4
4
|
import { Channel } from 'diagnostics_channel';
|
|
5
5
|
import { DirectiveTransformerOptions } from 'directive-to-hof';
|
|
@@ -1657,6 +1657,61 @@ declare class CommandKitPluginRuntime {
|
|
|
1657
1657
|
execute<R = any>(f: AsyncFunction<[CommandKitPluginRuntime, RuntimePlugin], R | undefined>): Promise<true | R | undefined>;
|
|
1658
1658
|
}
|
|
1659
1659
|
|
|
1660
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
1661
|
+
type IdentifyFunction<R> = (context: EvaluationContext) => MaybePromise<R>;
|
|
1662
|
+
type DecideFunction<E, R> = (data: {
|
|
1663
|
+
entities: E;
|
|
1664
|
+
}) => MaybePromise<R>;
|
|
1665
|
+
interface FeatureFlagDefinition<R, Entity> {
|
|
1666
|
+
key: string;
|
|
1667
|
+
description?: string;
|
|
1668
|
+
identify?: IdentifyFunction<Entity>;
|
|
1669
|
+
decide: DecideFunction<Entity, R>;
|
|
1670
|
+
}
|
|
1671
|
+
interface CommandFlagContext {
|
|
1672
|
+
client: Client<true>;
|
|
1673
|
+
commandkit: CommandKit;
|
|
1674
|
+
command: {
|
|
1675
|
+
interaction?: ChatInputCommandInteraction | AutocompleteInteraction | ContextMenuCommandInteraction;
|
|
1676
|
+
message?: Message$1;
|
|
1677
|
+
guild: Guild | null;
|
|
1678
|
+
channel: TextBasedChannel | null;
|
|
1679
|
+
command: LoadedCommand;
|
|
1680
|
+
};
|
|
1681
|
+
event: null;
|
|
1682
|
+
}
|
|
1683
|
+
interface EventFlagContext {
|
|
1684
|
+
client: Client<true>;
|
|
1685
|
+
commandkit: CommandKit;
|
|
1686
|
+
event: {
|
|
1687
|
+
data: ParsedEvent;
|
|
1688
|
+
event: string;
|
|
1689
|
+
namespace: string | null;
|
|
1690
|
+
arguments: any[];
|
|
1691
|
+
argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];
|
|
1692
|
+
};
|
|
1693
|
+
command: null;
|
|
1694
|
+
}
|
|
1695
|
+
type EvaluationContext = CommandFlagContext | EventFlagContext;
|
|
1696
|
+
type CustomEvaluationFunction<E> = () => MaybePromise<E>;
|
|
1697
|
+
type CustomEvaluationContext<E> = {
|
|
1698
|
+
identify: E | CustomEvaluationFunction<E>;
|
|
1699
|
+
};
|
|
1700
|
+
interface FlagRunner<E, R> {
|
|
1701
|
+
(): Promise<R>;
|
|
1702
|
+
run(context: CustomEvaluationContext<E>): Promise<R>;
|
|
1703
|
+
}
|
|
1704
|
+
declare class FeatureFlag<R, T> {
|
|
1705
|
+
private options;
|
|
1706
|
+
constructor(options: FeatureFlagDefinition<R, T>);
|
|
1707
|
+
private getContext;
|
|
1708
|
+
execute(res?: T): Promise<R>;
|
|
1709
|
+
}
|
|
1710
|
+
declare function flag<Returns = boolean, Entity = Record<any, any>>(options: FeatureFlagDefinition<Returns, Entity>): FlagRunner<Entity, Returns>;
|
|
1711
|
+
|
|
1712
|
+
declare class FlagStore extends Collection<string, FeatureFlag<any, any>> {
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1660
1715
|
interface CommandKitConfiguration {
|
|
1661
1716
|
defaultLocale: Locale;
|
|
1662
1717
|
getMessageCommandPrefix: (message: Message$1) => Awaitable<string | string[]>;
|
|
@@ -1699,6 +1754,7 @@ declare class CommandKit extends EventEmitter {
|
|
|
1699
1754
|
static readonly Fragment: typeof Fragment;
|
|
1700
1755
|
readonly config: CommandKitConfiguration;
|
|
1701
1756
|
readonly store: Map<string, any>;
|
|
1757
|
+
readonly flags: FlagStore;
|
|
1702
1758
|
commandsRouter: CommandsRouter;
|
|
1703
1759
|
eventsRouter: EventsRouter;
|
|
1704
1760
|
readonly commandHandler: AppCommandHandler;
|
|
@@ -1937,6 +1993,7 @@ interface EventWorkerContext {
|
|
|
1937
1993
|
namespace: string | null;
|
|
1938
1994
|
data: ParsedEvent;
|
|
1939
1995
|
commandkit: CommandKit;
|
|
1996
|
+
arguments: any[];
|
|
1940
1997
|
}
|
|
1941
1998
|
declare const eventWorkerContext: AsyncLocalStorage<EventWorkerContext>;
|
|
1942
1999
|
declare function runInEventWorkerContext<T>(context: EventWorkerContext, callback: () => T): T;
|
|
@@ -1949,4 +2006,4 @@ declare function getEventWorkerContext(): EventWorkerContext;
|
|
|
1949
2006
|
*/
|
|
1950
2007
|
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
1951
2008
|
|
|
1952
|
-
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, 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, CommonDirectiveTransformer, type CommonDirectiveTransformerOptions, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Container, type ContainerProps, Context, type ContextParameters, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, type EventWorkerContext, EventsRouter, type EventsRouterOptions, type EventsTree, File, type FileProps, 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, MediaGallery, MediaGalleryItem, type MediaGalleryItemProps, type MediaGalleryProps, 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, Section, type SectionProps, type SelectMenuKitPredicate, type SelectMenuProps, Separator, type SeparatorProps, type Setup, ShortInput, type SlashCommandMiddlewareContext, StopEventPropagationError, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextDisplay, type TextDisplayProps, TextInput, type TextInputProps, Thumbnail, type ThumbnailProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, after, bootstrapCommandkitCLI, cancelAfter, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, eventWorkerContext, exitContext, exitMiddleware, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getEventWorkerContext, getSourceDirectories, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, createElement as jsx, createElement as jsxs, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, runInEventWorkerContext, stopEvents, useEnvironment, version };
|
|
2009
|
+
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, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type ChatInputCommand, type ChatInputCommandContext, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, type CommandFlagContext, 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, CommonDirectiveTransformer, type CommonDirectiveTransformerOptions, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Container, type ContainerProps, Context, type ContextParameters, type CustomEvaluationContext, type CustomEvaluationFunction, type DecideFunction, DefaultLogger, ElementType, type EvaluationContext, type EventFlagContext, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, type EventWorkerContext, EventsRouter, type EventsRouterOptions, type EventsTree, FeatureFlag, type FeatureFlagDefinition, File, type FileProps, type FlagRunner, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type IdentifyFunction, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, type MaybePromise, MediaGallery, MediaGalleryItem, type MediaGalleryItemProps, type MediaGalleryProps, 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, Section, type SectionProps, type SelectMenuKitPredicate, type SelectMenuProps, Separator, type SeparatorProps, type Setup, ShortInput, type SlashCommandMiddlewareContext, StopEventPropagationError, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextDisplay, type TextDisplayProps, TextInput, type TextInputProps, Thumbnail, type ThumbnailProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, after, bootstrapCommandkitCLI, cancelAfter, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, eventWorkerContext, exitContext, exitMiddleware, flag, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getEventWorkerContext, getSourceDirectories, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, createElement as jsx, createElement as jsxs, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, runInEventWorkerContext, stopEvents, useEnvironment, version };
|
package/dist/index.js
CHANGED
|
@@ -4924,7 +4924,8 @@ var init_AppEventsHandler = __esm({
|
|
|
4924
4924
|
event: name,
|
|
4925
4925
|
namespace: namespace ?? null,
|
|
4926
4926
|
data: data.event,
|
|
4927
|
-
commandkit: this.commandkit
|
|
4927
|
+
commandkit: this.commandkit,
|
|
4928
|
+
arguments: args
|
|
4928
4929
|
},
|
|
4929
4930
|
async () => {
|
|
4930
4931
|
for (const listener of onListeners) {
|
|
@@ -4955,7 +4956,8 @@ var init_AppEventsHandler = __esm({
|
|
|
4955
4956
|
event: name,
|
|
4956
4957
|
namespace: namespace ?? null,
|
|
4957
4958
|
data: data.event,
|
|
4958
|
-
commandkit: this.commandkit
|
|
4959
|
+
commandkit: this.commandkit,
|
|
4960
|
+
arguments: args
|
|
4959
4961
|
},
|
|
4960
4962
|
async () => {
|
|
4961
4963
|
try {
|
|
@@ -5045,6 +5047,11 @@ function write(message) {
|
|
|
5045
5047
|
process.stdout.write(message);
|
|
5046
5048
|
process.stdout.write("\n");
|
|
5047
5049
|
}
|
|
5050
|
+
function findEntrypoint(dir) {
|
|
5051
|
+
const target = (0, import_node_path5.join)(dir, "sharding-manager.js");
|
|
5052
|
+
if (import_node_fs5.default.existsSync(target)) return target;
|
|
5053
|
+
return (0, import_node_path5.join)(dir, "index.js");
|
|
5054
|
+
}
|
|
5048
5055
|
function panic(message) {
|
|
5049
5056
|
write(colors_default.red(`Error: ${message}`));
|
|
5050
5057
|
process.exit(1);
|
|
@@ -5167,6 +5174,7 @@ var init_common3 = __esm({
|
|
|
5167
5174
|
init_types_package();
|
|
5168
5175
|
import_node_child_process = require("child_process");
|
|
5169
5176
|
__name(write, "write");
|
|
5177
|
+
__name(findEntrypoint, "findEntrypoint");
|
|
5170
5178
|
__name(panic, "panic");
|
|
5171
5179
|
__name(ensureTypeScript, "ensureTypeScript");
|
|
5172
5180
|
__name(detectPackageManager, "detectPackageManager");
|
|
@@ -5333,6 +5341,20 @@ var init_CommandKitEventsChannel = __esm({
|
|
|
5333
5341
|
}
|
|
5334
5342
|
});
|
|
5335
5343
|
|
|
5344
|
+
// src/flags/store.ts
|
|
5345
|
+
var import_discord26, _FlagStore, FlagStore;
|
|
5346
|
+
var init_store = __esm({
|
|
5347
|
+
"src/flags/store.ts"() {
|
|
5348
|
+
"use strict";
|
|
5349
|
+
init_cjs_shims();
|
|
5350
|
+
import_discord26 = require("discord.js");
|
|
5351
|
+
_FlagStore = class _FlagStore extends import_discord26.Collection {
|
|
5352
|
+
};
|
|
5353
|
+
__name(_FlagStore, "FlagStore");
|
|
5354
|
+
FlagStore = _FlagStore;
|
|
5355
|
+
}
|
|
5356
|
+
});
|
|
5357
|
+
|
|
5336
5358
|
// src/CommandKit.ts
|
|
5337
5359
|
function onBootstrap(fn) {
|
|
5338
5360
|
bootstrapHooks.add(fn);
|
|
@@ -5340,7 +5362,7 @@ function onBootstrap(fn) {
|
|
|
5340
5362
|
function onApplicationBootstrap(fn) {
|
|
5341
5363
|
onApplicationBootstrapHooks.add(fn);
|
|
5342
5364
|
}
|
|
5343
|
-
var import_node_events2,
|
|
5365
|
+
var import_node_events2, import_discord27, import_node_path7, import_node_fs7, commandkit, bootstrapHooks, onApplicationBootstrapHooks, _started, _CommandKit_instances, bootstrapHooks_fn, applicationBootstrapHooks_fn, init_fn, initCommands_fn, initEvents_fn, _CommandKit, CommandKit;
|
|
5344
5366
|
var init_CommandKit = __esm({
|
|
5345
5367
|
"src/CommandKit.ts"() {
|
|
5346
5368
|
"use strict";
|
|
@@ -5349,7 +5371,7 @@ var init_CommandKit = __esm({
|
|
|
5349
5371
|
init_colors();
|
|
5350
5372
|
init_components();
|
|
5351
5373
|
init_EventInterceptor();
|
|
5352
|
-
|
|
5374
|
+
import_discord27 = require("discord.js");
|
|
5353
5375
|
init_utilities();
|
|
5354
5376
|
import_node_path7 = require("path");
|
|
5355
5377
|
init_AppCommandHandler();
|
|
@@ -5364,6 +5386,7 @@ var init_CommandKit = __esm({
|
|
|
5364
5386
|
init_plugins();
|
|
5365
5387
|
init_types_package();
|
|
5366
5388
|
init_Logger();
|
|
5389
|
+
init_store();
|
|
5367
5390
|
bootstrapHooks = /* @__PURE__ */ new Set();
|
|
5368
5391
|
onApplicationBootstrapHooks = /* @__PURE__ */ new Set();
|
|
5369
5392
|
__name(onBootstrap, "onBootstrap");
|
|
@@ -5395,10 +5418,11 @@ var init_CommandKit = __esm({
|
|
|
5395
5418
|
__privateAdd(this, _started, false);
|
|
5396
5419
|
__publicField(this, "eventInterceptor");
|
|
5397
5420
|
__publicField(this, "config", {
|
|
5398
|
-
defaultLocale:
|
|
5421
|
+
defaultLocale: import_discord27.Locale.EnglishUS,
|
|
5399
5422
|
getMessageCommandPrefix: /* @__PURE__ */ __name(() => "!", "getMessageCommandPrefix")
|
|
5400
5423
|
});
|
|
5401
5424
|
__publicField(this, "store", /* @__PURE__ */ new Map());
|
|
5425
|
+
__publicField(this, "flags", new FlagStore());
|
|
5402
5426
|
__publicField(this, "commandsRouter");
|
|
5403
5427
|
__publicField(this, "eventsRouter");
|
|
5404
5428
|
__publicField(this, "commandHandler", new AppCommandHandler(this));
|
|
@@ -5439,7 +5463,7 @@ var init_CommandKit = __esm({
|
|
|
5439
5463
|
this.commandHandler.registerCommandHandler();
|
|
5440
5464
|
this.incrementClientListenersCount();
|
|
5441
5465
|
if (token !== false && !this.options.client.isReady()) {
|
|
5442
|
-
this.client.once(
|
|
5466
|
+
this.client.once(import_discord27.Events.ClientReady, async () => {
|
|
5443
5467
|
await this.commandHandler.registrar.register();
|
|
5444
5468
|
});
|
|
5445
5469
|
await this.plugins.execute((ctx, plugin) => {
|
|
@@ -5631,7 +5655,7 @@ var init_version = __esm({
|
|
|
5631
5655
|
"use strict";
|
|
5632
5656
|
init_cjs_shims();
|
|
5633
5657
|
version = /* @__MACRO__ $version */
|
|
5634
|
-
"1.0.0-dev.
|
|
5658
|
+
"1.0.0-dev.20250515152130";
|
|
5635
5659
|
}
|
|
5636
5660
|
});
|
|
5637
5661
|
|
|
@@ -5902,9 +5926,9 @@ ${wrapInAsyncIIFE([envScript(isDev), antiCrashScript, requireScript])}
|
|
|
5902
5926
|
` : wrapInAsyncIIFE([envScript(isDev), requireScript])}
|
|
5903
5927
|
|
|
5904
5928
|
import { CommandKit } from 'commandkit';
|
|
5905
|
-
import app from './app.js';
|
|
5906
5929
|
|
|
5907
5930
|
async function bootstrap() {
|
|
5931
|
+
const app = await import('./app.js').then((m) => m.default ?? m);
|
|
5908
5932
|
const commandkit = new CommandKit({
|
|
5909
5933
|
client: app,
|
|
5910
5934
|
});
|
|
@@ -5989,7 +6013,7 @@ __export(development_exports, {
|
|
|
5989
6013
|
});
|
|
5990
6014
|
async function buildAndStart(configPath, skipStart = false) {
|
|
5991
6015
|
const config = await loadConfigFile(configPath);
|
|
5992
|
-
const mainFile = (
|
|
6016
|
+
const mainFile = findEntrypoint(".commandkit");
|
|
5993
6017
|
await buildApplication({
|
|
5994
6018
|
configPath,
|
|
5995
6019
|
isDev: true,
|
|
@@ -6166,6 +6190,7 @@ var init_development = __esm({
|
|
|
6166
6190
|
import_promises6 = require("timers/promises");
|
|
6167
6191
|
import_node_crypto3 = require("crypto");
|
|
6168
6192
|
init_constants();
|
|
6193
|
+
init_common3();
|
|
6169
6194
|
__name(buildAndStart, "buildAndStart");
|
|
6170
6195
|
isCommandSource = /* @__PURE__ */ __name((p) => p.replaceAll("\\", "/").includes("src/app/commands"), "isCommandSource");
|
|
6171
6196
|
isEventSource = /* @__PURE__ */ __name((p) => p.replaceAll("\\", "/").includes("src/app/events"), "isEventSource");
|
|
@@ -6202,7 +6227,7 @@ async function bootstrapProductionServer(configPath) {
|
|
|
6202
6227
|
process.env.COMMANDKIT_BOOTSTRAP_MODE = "production";
|
|
6203
6228
|
const cwd = configPath || process.cwd();
|
|
6204
6229
|
const config = await loadConfigFile(cwd);
|
|
6205
|
-
const mainFile = (
|
|
6230
|
+
const mainFile = findEntrypoint(config.distDir);
|
|
6206
6231
|
if (!(0, import_fs.existsSync)(mainFile)) {
|
|
6207
6232
|
panic(
|
|
6208
6233
|
`Could not locate the entrypoint. Did you forget to build the application? Run 'commandkit build' to build the application first.`
|
|
@@ -6228,12 +6253,11 @@ async function createProductionBuild(configPath) {
|
|
|
6228
6253
|
});
|
|
6229
6254
|
spinner.succeed("Production build completed!");
|
|
6230
6255
|
}
|
|
6231
|
-
var
|
|
6256
|
+
var import_fs;
|
|
6232
6257
|
var init_production = __esm({
|
|
6233
6258
|
"src/cli/production.ts"() {
|
|
6234
6259
|
"use strict";
|
|
6235
6260
|
init_cjs_shims();
|
|
6236
|
-
import_path3 = require("path");
|
|
6237
6261
|
init_loader();
|
|
6238
6262
|
init_app_process();
|
|
6239
6263
|
import_fs = require("fs");
|
|
@@ -6253,7 +6277,7 @@ __export(generators_exports, {
|
|
|
6253
6277
|
generateEvent: () => generateEvent
|
|
6254
6278
|
});
|
|
6255
6279
|
function determineExtension() {
|
|
6256
|
-
return (0, import_fs2.existsSync)((0,
|
|
6280
|
+
return (0, import_fs2.existsSync)((0, import_path3.join)(BASE_PATH, "tsconfig.json")) ? "ts" : "js";
|
|
6257
6281
|
}
|
|
6258
6282
|
function TS_COMMAND_SOURCE(name) {
|
|
6259
6283
|
return `import type { CommandData, ChatInputCommand, MessageCommand } from 'commandkit';
|
|
@@ -6297,16 +6321,16 @@ export const message = async (ctx) => {
|
|
|
6297
6321
|
`;
|
|
6298
6322
|
}
|
|
6299
6323
|
async function generateCommand(name, customPath) {
|
|
6300
|
-
const cmdPath = (0,
|
|
6324
|
+
const cmdPath = (0, import_path3.join)(customPath || COMMANDS_DIR);
|
|
6301
6325
|
if (!(0, import_fs2.existsSync)(cmdPath)) await (0, import_promises7.mkdir)(cmdPath, { recursive: true });
|
|
6302
6326
|
const ext = determineExtension();
|
|
6303
6327
|
const isTypeScript = ext === "ts";
|
|
6304
6328
|
const fileName = `${name}.${ext}`;
|
|
6305
|
-
if ((0, import_fs2.existsSync)((0,
|
|
6329
|
+
if ((0, import_fs2.existsSync)((0, import_path3.join)(cmdPath, fileName))) {
|
|
6306
6330
|
panic(`Command ${name} already exists.`);
|
|
6307
6331
|
}
|
|
6308
6332
|
const commandFile = isTypeScript ? TS_COMMAND_SOURCE(name) : JS_COMMAND_SOURCE(name);
|
|
6309
|
-
await (0, import_promises7.writeFile)((0,
|
|
6333
|
+
await (0, import_promises7.writeFile)((0, import_path3.join)(cmdPath, fileName), commandFile);
|
|
6310
6334
|
console.log(
|
|
6311
6335
|
colors_default.green(
|
|
6312
6336
|
`Command ${colors_default.magenta(name)} created at ${colors_default.blue(formatPath(`${cmdPath}/${fileName}`))}`
|
|
@@ -6314,11 +6338,11 @@ async function generateCommand(name, customPath) {
|
|
|
6314
6338
|
);
|
|
6315
6339
|
}
|
|
6316
6340
|
async function generateEvent(name, customPath) {
|
|
6317
|
-
const eventPath = (0,
|
|
6341
|
+
const eventPath = (0, import_path3.join)(customPath || EVENTS_DIR, name);
|
|
6318
6342
|
if (!(0, import_fs2.existsSync)(eventPath)) await (0, import_promises7.mkdir)(eventPath, { recursive: true });
|
|
6319
6343
|
const ext = determineExtension();
|
|
6320
6344
|
let filename = `event.${ext}`;
|
|
6321
|
-
if ((0, import_fs2.existsSync)((0,
|
|
6345
|
+
if ((0, import_fs2.existsSync)((0, import_path3.join)(eventPath, filename))) {
|
|
6322
6346
|
const count = (await (0, import_promises7.readdir)(eventPath)).length;
|
|
6323
6347
|
filename = `${String(count).padStart(2, "0")}_${filename}`;
|
|
6324
6348
|
}
|
|
@@ -6327,26 +6351,26 @@ export default async function on${name[0].toUpperCase() + name.slice(1)}() {
|
|
|
6327
6351
|
console.log('${name} event fired!');
|
|
6328
6352
|
};
|
|
6329
6353
|
`.trim();
|
|
6330
|
-
await (0, import_promises7.writeFile)((0,
|
|
6354
|
+
await (0, import_promises7.writeFile)((0, import_path3.join)(eventPath, filename), eventFile);
|
|
6331
6355
|
console.log(
|
|
6332
6356
|
colors_default.green(
|
|
6333
6357
|
`Event ${colors_default.magenta(name)} created at ${colors_default.blue(formatPath(eventPath))}/${colors_default.magenta(filename)}`
|
|
6334
6358
|
)
|
|
6335
6359
|
);
|
|
6336
6360
|
}
|
|
6337
|
-
var import_promises7,
|
|
6361
|
+
var import_promises7, import_path3, import_fs2, BASE_PATH, COMMANDS_DIR, EVENTS_DIR, formatPath;
|
|
6338
6362
|
var init_generators = __esm({
|
|
6339
6363
|
"src/cli/generators.ts"() {
|
|
6340
6364
|
"use strict";
|
|
6341
6365
|
init_cjs_shims();
|
|
6342
6366
|
import_promises7 = require("fs/promises");
|
|
6343
|
-
|
|
6367
|
+
import_path3 = require("path");
|
|
6344
6368
|
init_common3();
|
|
6345
6369
|
import_fs2 = require("fs");
|
|
6346
6370
|
init_colors();
|
|
6347
6371
|
BASE_PATH = process.cwd();
|
|
6348
|
-
COMMANDS_DIR = (0,
|
|
6349
|
-
EVENTS_DIR = (0,
|
|
6372
|
+
COMMANDS_DIR = (0, import_path3.join)(BASE_PATH, "src/app/commands");
|
|
6373
|
+
EVENTS_DIR = (0, import_path3.join)(BASE_PATH, "src/app/events");
|
|
6350
6374
|
formatPath = /* @__PURE__ */ __name((path3) => path3.replace(process.cwd(), ".").replace(/\\/g, "/"), "formatPath");
|
|
6351
6375
|
__name(determineExtension, "determineExtension");
|
|
6352
6376
|
__name(TS_COMMAND_SOURCE, "TS_COMMAND_SOURCE");
|
|
@@ -6535,6 +6559,7 @@ __export(index_exports, {
|
|
|
6535
6559
|
ElementType: () => ElementType,
|
|
6536
6560
|
EventInterceptor: () => EventInterceptor,
|
|
6537
6561
|
EventsRouter: () => EventsRouter,
|
|
6562
|
+
FeatureFlag: () => FeatureFlag,
|
|
6538
6563
|
File: () => File,
|
|
6539
6564
|
Fragment: () => Fragment,
|
|
6540
6565
|
HMREventType: () => HMREventType,
|
|
@@ -6577,6 +6602,7 @@ __export(index_exports, {
|
|
|
6577
6602
|
eventWorkerContext: () => eventWorkerContext,
|
|
6578
6603
|
exitContext: () => exitContext,
|
|
6579
6604
|
exitMiddleware: () => exitMiddleware,
|
|
6605
|
+
flag: () => flag,
|
|
6580
6606
|
fromEsbuildPlugin: () => fromEsbuildPlugin,
|
|
6581
6607
|
getCommandKit: () => getCommandKit,
|
|
6582
6608
|
getConfig: () => getConfig,
|
|
@@ -6622,9 +6648,9 @@ init_CommandRegistrar();
|
|
|
6622
6648
|
|
|
6623
6649
|
// src/app/commands/helpers.ts
|
|
6624
6650
|
init_cjs_shims();
|
|
6625
|
-
var
|
|
6651
|
+
var import_discord28 = require("discord.js");
|
|
6626
6652
|
function isMessageSource(source) {
|
|
6627
|
-
return source instanceof
|
|
6653
|
+
return source instanceof import_discord28.Message;
|
|
6628
6654
|
}
|
|
6629
6655
|
__name(isMessageSource, "isMessageSource");
|
|
6630
6656
|
function isInteractionSource(source) {
|
|
@@ -6643,6 +6669,100 @@ init_Logger();
|
|
|
6643
6669
|
init_router();
|
|
6644
6670
|
init_version();
|
|
6645
6671
|
init_plugins();
|
|
6672
|
+
|
|
6673
|
+
// src/flags/feature-flags.ts
|
|
6674
|
+
init_cjs_shims();
|
|
6675
|
+
init_async_context();
|
|
6676
|
+
init_EventWorkerContext();
|
|
6677
|
+
var _FeatureFlag = class _FeatureFlag {
|
|
6678
|
+
constructor(options) {
|
|
6679
|
+
this.options = options;
|
|
6680
|
+
const FlagStore2 = getCommandKit(true).flags;
|
|
6681
|
+
if (FlagStore2.has(options.key)) {
|
|
6682
|
+
throw new Error(`Feature flag with key "${options.key}" already exists.`);
|
|
6683
|
+
}
|
|
6684
|
+
FlagStore2.set(options.key, this);
|
|
6685
|
+
}
|
|
6686
|
+
getContext() {
|
|
6687
|
+
const env = getContext();
|
|
6688
|
+
if (env == null ? void 0 : env.context) {
|
|
6689
|
+
const {
|
|
6690
|
+
client,
|
|
6691
|
+
commandkit: commandkit2,
|
|
6692
|
+
interaction,
|
|
6693
|
+
message,
|
|
6694
|
+
guild,
|
|
6695
|
+
channel,
|
|
6696
|
+
command
|
|
6697
|
+
} = env.context;
|
|
6698
|
+
return {
|
|
6699
|
+
client,
|
|
6700
|
+
commandkit: commandkit2,
|
|
6701
|
+
command: {
|
|
6702
|
+
interaction,
|
|
6703
|
+
message,
|
|
6704
|
+
guild,
|
|
6705
|
+
channel,
|
|
6706
|
+
command
|
|
6707
|
+
},
|
|
6708
|
+
event: null
|
|
6709
|
+
};
|
|
6710
|
+
}
|
|
6711
|
+
const eventCtx = eventWorkerContext.getStore();
|
|
6712
|
+
if (eventCtx) {
|
|
6713
|
+
const { commandkit: commandkit2, data, event, namespace } = eventCtx;
|
|
6714
|
+
return {
|
|
6715
|
+
client: commandkit2.client,
|
|
6716
|
+
commandkit: commandkit2,
|
|
6717
|
+
event: {
|
|
6718
|
+
data,
|
|
6719
|
+
event,
|
|
6720
|
+
namespace,
|
|
6721
|
+
arguments: eventCtx.arguments,
|
|
6722
|
+
argumentsAs: /* @__PURE__ */ __name((eventName) => {
|
|
6723
|
+
const args = eventCtx.arguments;
|
|
6724
|
+
return args;
|
|
6725
|
+
}, "argumentsAs")
|
|
6726
|
+
},
|
|
6727
|
+
command: null
|
|
6728
|
+
};
|
|
6729
|
+
}
|
|
6730
|
+
throw new Error(
|
|
6731
|
+
"Could not determine the execution context. Feature flags may only be used inside a command or event."
|
|
6732
|
+
);
|
|
6733
|
+
}
|
|
6734
|
+
async execute(res) {
|
|
6735
|
+
const { decide, identify } = this.options;
|
|
6736
|
+
const entities = res ?? await (async () => {
|
|
6737
|
+
const ctx = this.getContext();
|
|
6738
|
+
return await (identify == null ? void 0 : identify(ctx)) ?? {};
|
|
6739
|
+
})();
|
|
6740
|
+
const decisionResult = await decide({
|
|
6741
|
+
entities
|
|
6742
|
+
});
|
|
6743
|
+
return decisionResult;
|
|
6744
|
+
}
|
|
6745
|
+
};
|
|
6746
|
+
__name(_FeatureFlag, "FeatureFlag");
|
|
6747
|
+
var FeatureFlag = _FeatureFlag;
|
|
6748
|
+
function flag(options) {
|
|
6749
|
+
const flag2 = new FeatureFlag(options);
|
|
6750
|
+
const runner = flag2.execute.bind(flag2, void 0);
|
|
6751
|
+
runner.run = async function(ctx) {
|
|
6752
|
+
if (!(ctx == null ? void 0 : ctx.identify)) {
|
|
6753
|
+
throw new Error(
|
|
6754
|
+
"Custom evaluation context must have an identify function or object."
|
|
6755
|
+
);
|
|
6756
|
+
}
|
|
6757
|
+
const context2 = typeof ctx === "function" ? await ctx() : ctx;
|
|
6758
|
+
const decisionResult = await flag2.execute(context2);
|
|
6759
|
+
return decisionResult;
|
|
6760
|
+
};
|
|
6761
|
+
return runner;
|
|
6762
|
+
}
|
|
6763
|
+
__name(flag, "flag");
|
|
6764
|
+
|
|
6765
|
+
// src/index.ts
|
|
6646
6766
|
init_utilities();
|
|
6647
6767
|
init_constants();
|
|
6648
6768
|
init_EventWorkerContext();
|
|
@@ -6735,6 +6855,7 @@ var index_default = CommandKit;
|
|
|
6735
6855
|
ElementType,
|
|
6736
6856
|
EventInterceptor,
|
|
6737
6857
|
EventsRouter,
|
|
6858
|
+
FeatureFlag,
|
|
6738
6859
|
File,
|
|
6739
6860
|
Fragment,
|
|
6740
6861
|
HMREventType,
|
|
@@ -6776,6 +6897,7 @@ var index_default = CommandKit;
|
|
|
6776
6897
|
eventWorkerContext,
|
|
6777
6898
|
exitContext,
|
|
6778
6899
|
exitMiddleware,
|
|
6900
|
+
flag,
|
|
6779
6901
|
fromEsbuildPlugin,
|
|
6780
6902
|
getCommandKit,
|
|
6781
6903
|
getConfig,
|