commandkit 0.1.11-dev.20240202064607 → 0.1.11-dev.20240203230231
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/CommandKit--SA9LcIq.d.mts +452 -0
- package/dist/CommandKit-GIHMEeqf.d.ts +452 -0
- package/dist/CommandKit.d.mts +5 -0
- package/dist/CommandKit.d.ts +5 -0
- package/dist/CommandKit.js +11 -0
- package/dist/CommandKit.js.map +1 -0
- package/dist/CommandKit.mjs +2 -0
- package/dist/CommandKit.mjs.map +1 -0
- package/dist/bootstrap/client.d.mts +13 -0
- package/dist/bootstrap/client.d.ts +13 -0
- package/dist/bootstrap/client.js +2 -0
- package/dist/bootstrap/client.js.map +1 -0
- package/dist/bootstrap/client.mjs +2 -0
- package/dist/bootstrap/client.mjs.map +1 -0
- package/dist/bootstrap/loadEnv.d.mts +3 -0
- package/dist/bootstrap/loadEnv.d.ts +3 -0
- package/dist/bootstrap/loadEnv.js +2 -0
- package/dist/bootstrap/loadEnv.js.map +1 -0
- package/dist/bootstrap/loadEnv.mjs +2 -0
- package/dist/bootstrap/loadEnv.mjs.map +1 -0
- package/dist/chunk-5AIBE2QR.mjs +2 -0
- package/dist/chunk-5AIBE2QR.mjs.map +1 -0
- package/dist/chunk-6CLMSPNA.mjs +2 -0
- package/dist/chunk-6CLMSPNA.mjs.map +1 -0
- package/dist/chunk-77LPS2WP.mjs +2 -0
- package/dist/chunk-77LPS2WP.mjs.map +1 -0
- package/dist/chunk-7KD7ZCH6.mjs +2 -0
- package/dist/chunk-7KD7ZCH6.mjs.map +1 -0
- package/dist/chunk-BCQP4DZP.mjs +2 -0
- package/dist/chunk-BCQP4DZP.mjs.map +1 -0
- package/dist/chunk-BJCWVCAY.mjs +2 -0
- package/dist/chunk-BJCWVCAY.mjs.map +1 -0
- package/dist/chunk-BXBLPEWT.mjs +7 -0
- package/dist/chunk-BXBLPEWT.mjs.map +1 -0
- package/dist/chunk-CHI4NRSH.mjs +2 -0
- package/dist/chunk-CHI4NRSH.mjs.map +1 -0
- package/dist/chunk-DEB7FLUS.mjs +2 -0
- package/dist/chunk-DEB7FLUS.mjs.map +1 -0
- package/dist/chunk-FQGSVSCT.mjs +2 -0
- package/dist/chunk-FQGSVSCT.mjs.map +1 -0
- package/dist/chunk-IFTUM7TS.mjs +2 -0
- package/dist/chunk-IFTUM7TS.mjs.map +1 -0
- package/dist/chunk-KATLDJ7Z.mjs +2 -0
- package/dist/chunk-KATLDJ7Z.mjs.map +1 -0
- package/dist/chunk-KUU3KDAE.mjs +2 -0
- package/dist/chunk-KUU3KDAE.mjs.map +1 -0
- package/dist/chunk-M5FMJETI.mjs +1 -0
- package/dist/chunk-M5FMJETI.mjs.map +1 -0
- package/dist/chunk-PFU3PH6M.mjs +1 -0
- package/dist/chunk-PFU3PH6M.mjs.map +1 -0
- package/dist/chunk-Q7UFCVZL.mjs +2 -0
- package/dist/chunk-Q7UFCVZL.mjs.map +1 -0
- package/dist/chunk-QC2F7O3S.mjs +2 -0
- package/dist/chunk-QC2F7O3S.mjs.map +1 -0
- package/dist/chunk-QYJ4DE3N.mjs +2 -0
- package/dist/chunk-QYJ4DE3N.mjs.map +1 -0
- package/dist/chunk-R6PIHRXD.mjs +2 -0
- package/dist/chunk-R6PIHRXD.mjs.map +1 -0
- package/dist/chunk-RQQKHSL6.mjs +4 -0
- package/dist/chunk-RQQKHSL6.mjs.map +1 -0
- package/dist/chunk-SB3FAFCD.mjs +2 -0
- package/dist/chunk-SB3FAFCD.mjs.map +1 -0
- package/dist/chunk-SXUJOOQY.mjs +4 -0
- package/dist/chunk-SXUJOOQY.mjs.map +1 -0
- package/dist/chunk-SYOEMO4R.mjs +2 -0
- package/dist/chunk-SYOEMO4R.mjs.map +1 -0
- package/dist/chunk-TZXZ3UZS.mjs +2 -0
- package/dist/chunk-TZXZ3UZS.mjs.map +1 -0
- package/dist/chunk-UV2LVAQV.mjs +2 -0
- package/dist/chunk-UV2LVAQV.mjs.map +1 -0
- package/dist/chunk-VURGPMLB.mjs +2 -0
- package/dist/chunk-VURGPMLB.mjs.map +1 -0
- package/dist/chunk-ZJRAI4W5.mjs +2 -0
- package/dist/chunk-ZJRAI4W5.mjs.map +1 -0
- package/dist/components/ButtonKit.d.mts +55 -0
- package/dist/components/ButtonKit.d.ts +55 -0
- package/dist/components/ButtonKit.js +2 -0
- package/dist/components/ButtonKit.js.map +1 -0
- package/dist/components/ButtonKit.mjs +2 -0
- package/dist/components/ButtonKit.mjs.map +1 -0
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +2 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config.d.mts +55 -0
- package/dist/config.d.ts +55 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +2 -0
- package/dist/config.mjs.map +1 -0
- package/dist/environment/actions/development.d.mts +8 -0
- package/dist/environment/actions/development.d.ts +8 -0
- package/dist/environment/actions/development.js +2 -0
- package/dist/environment/actions/development.js.map +1 -0
- package/dist/environment/actions/development.mjs +2 -0
- package/dist/environment/actions/development.mjs.map +1 -0
- package/dist/environment/bundler/bundle.d.mts +3 -0
- package/dist/environment/bundler/bundle.d.ts +3 -0
- package/dist/environment/bundler/bundle.js +2 -0
- package/dist/environment/bundler/bundle.js.map +1 -0
- package/dist/environment/bundler/bundle.mjs +2 -0
- package/dist/environment/bundler/bundle.mjs.map +1 -0
- package/dist/environment/bundler/shims.d.mts +3 -0
- package/dist/environment/bundler/shims.d.ts +3 -0
- package/dist/environment/bundler/shims.js +11 -0
- package/dist/environment/bundler/shims.js.map +1 -0
- package/dist/environment/bundler/shims.mjs +11 -0
- package/dist/environment/bundler/shims.mjs.map +1 -0
- package/dist/environment/cli.d.mts +2 -0
- package/dist/environment/cli.d.ts +2 -0
- package/dist/environment/cli.js +2 -0
- package/dist/environment/cli.js.map +1 -0
- package/dist/environment/cli.mjs +2 -0
- package/dist/environment/cli.mjs.map +1 -0
- package/dist/environment/common/config.d.mts +7 -0
- package/dist/environment/common/config.d.ts +7 -0
- package/dist/environment/common/config.js +2 -0
- package/dist/environment/common/config.js.map +1 -0
- package/dist/environment/common/config.mjs +2 -0
- package/dist/environment/common/config.mjs.map +1 -0
- package/dist/environment/common/logger.d.mts +9 -0
- package/dist/environment/common/logger.d.ts +9 -0
- package/dist/environment/common/logger.js +2 -0
- package/dist/environment/common/logger.js.map +1 -0
- package/dist/environment/common/logger.mjs +2 -0
- package/dist/environment/common/logger.mjs.map +1 -0
- package/dist/handlers/command-handler/CommandHandler.d.mts +5 -0
- package/dist/handlers/command-handler/CommandHandler.d.ts +5 -0
- package/dist/handlers/command-handler/CommandHandler.js +11 -0
- package/dist/handlers/command-handler/CommandHandler.js.map +1 -0
- package/dist/handlers/command-handler/CommandHandler.mjs +2 -0
- package/dist/handlers/command-handler/CommandHandler.mjs.map +1 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.mts +35 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.ts +35 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.js +4 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.js.map +1 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs +2 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs.map +1 -0
- package/dist/handlers/command-handler/functions/registerCommands.d.mts +20 -0
- package/dist/handlers/command-handler/functions/registerCommands.d.ts +20 -0
- package/dist/handlers/command-handler/functions/registerCommands.js +7 -0
- package/dist/handlers/command-handler/functions/registerCommands.js.map +1 -0
- package/dist/handlers/command-handler/functions/registerCommands.mjs +2 -0
- package/dist/handlers/command-handler/functions/registerCommands.mjs.map +1 -0
- package/dist/handlers/command-handler/typings.d.mts +5 -0
- package/dist/handlers/command-handler/typings.d.ts +5 -0
- package/dist/handlers/command-handler/typings.js +2 -0
- package/dist/handlers/command-handler/typings.js.map +1 -0
- package/dist/handlers/command-handler/typings.mjs +1 -0
- package/dist/handlers/command-handler/typings.mjs.map +1 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.mts +9 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.ts +9 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js +2 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js.map +1 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs +2 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs.map +1 -0
- package/dist/handlers/command-handler/validations/devOnly.d.mts +9 -0
- package/dist/handlers/command-handler/validations/devOnly.d.ts +9 -0
- package/dist/handlers/command-handler/validations/devOnly.js +2 -0
- package/dist/handlers/command-handler/validations/devOnly.js.map +1 -0
- package/dist/handlers/command-handler/validations/devOnly.mjs +2 -0
- package/dist/handlers/command-handler/validations/devOnly.mjs.map +1 -0
- package/dist/handlers/command-handler/validations/index.d.mts +10 -0
- package/dist/handlers/command-handler/validations/index.d.ts +10 -0
- package/dist/handlers/command-handler/validations/index.js +4 -0
- package/dist/handlers/command-handler/validations/index.js.map +1 -0
- package/dist/handlers/command-handler/validations/index.mjs +2 -0
- package/dist/handlers/command-handler/validations/index.mjs.map +1 -0
- package/dist/handlers/command-handler/validations/permissions.d.mts +9 -0
- package/dist/handlers/command-handler/validations/permissions.d.ts +9 -0
- package/dist/handlers/command-handler/validations/permissions.js +4 -0
- package/dist/handlers/command-handler/validations/permissions.js.map +1 -0
- package/dist/handlers/command-handler/validations/permissions.mjs +2 -0
- package/dist/handlers/command-handler/validations/permissions.mjs.map +1 -0
- package/dist/handlers/event-handler/EventHandler.d.mts +5 -0
- package/dist/handlers/event-handler/EventHandler.d.ts +5 -0
- package/dist/handlers/event-handler/EventHandler.js +2 -0
- package/dist/handlers/event-handler/EventHandler.js.map +1 -0
- package/dist/handlers/event-handler/EventHandler.mjs +2 -0
- package/dist/handlers/event-handler/EventHandler.mjs.map +1 -0
- package/dist/handlers/event-handler/typings.d.mts +5 -0
- package/dist/handlers/event-handler/typings.d.ts +5 -0
- package/dist/handlers/event-handler/typings.js +2 -0
- package/dist/handlers/event-handler/typings.js.map +1 -0
- package/dist/handlers/event-handler/typings.mjs +1 -0
- package/dist/handlers/event-handler/typings.mjs.map +1 -0
- package/dist/handlers/index.d.mts +5 -0
- package/dist/handlers/index.d.ts +5 -0
- package/dist/handlers/index.js +11 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/index.mjs +2 -0
- package/dist/handlers/index.mjs.map +1 -0
- package/dist/handlers/validation-handler/ValidationHandler.d.mts +14 -0
- package/dist/handlers/validation-handler/ValidationHandler.d.ts +14 -0
- package/dist/handlers/validation-handler/ValidationHandler.js +2 -0
- package/dist/handlers/validation-handler/ValidationHandler.js.map +1 -0
- package/dist/handlers/validation-handler/ValidationHandler.mjs +2 -0
- package/dist/handlers/validation-handler/ValidationHandler.mjs.map +1 -0
- package/dist/handlers/validation-handler/typings.d.mts +14 -0
- package/dist/handlers/validation-handler/typings.d.ts +14 -0
- package/dist/handlers/validation-handler/typings.js +2 -0
- package/dist/handlers/validation-handler/typings.js.map +1 -0
- package/dist/handlers/validation-handler/typings.mjs +1 -0
- package/dist/handlers/validation-handler/typings.mjs.map +1 -0
- package/dist/hooks/common.d.mts +12 -0
- package/dist/hooks/common.d.ts +12 -0
- package/dist/hooks/common.js +11 -0
- package/dist/hooks/common.js.map +1 -0
- package/dist/hooks/common.mjs +2 -0
- package/dist/hooks/common.mjs.map +1 -0
- package/dist/hooks/index.d.mts +14 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/response.d.mts +7 -0
- package/dist/hooks/response.d.ts +7 -0
- package/dist/hooks/response.js +11 -0
- package/dist/hooks/response.js.map +1 -0
- package/dist/hooks/response.mjs +2 -0
- package/dist/hooks/response.mjs.map +1 -0
- package/dist/hooks/useChannel.d.mts +5 -0
- package/dist/hooks/useChannel.d.ts +5 -0
- package/dist/hooks/useChannel.js +11 -0
- package/dist/hooks/useChannel.js.map +1 -0
- package/dist/hooks/useChannel.mjs +2 -0
- package/dist/hooks/useChannel.mjs.map +1 -0
- package/dist/hooks/useClient.d.mts +5 -0
- package/dist/hooks/useClient.d.ts +5 -0
- package/dist/hooks/useClient.js +11 -0
- package/dist/hooks/useClient.js.map +1 -0
- package/dist/hooks/useClient.mjs +2 -0
- package/dist/hooks/useClient.mjs.map +1 -0
- package/dist/hooks/useCommandData.d.mts +5 -0
- package/dist/hooks/useCommandData.d.ts +5 -0
- package/dist/hooks/useCommandData.js +11 -0
- package/dist/hooks/useCommandData.js.map +1 -0
- package/dist/hooks/useCommandData.mjs +2 -0
- package/dist/hooks/useCommandData.mjs.map +1 -0
- package/dist/hooks/useCommandKit.d.mts +9 -0
- package/dist/hooks/useCommandKit.d.ts +9 -0
- package/dist/hooks/useCommandKit.js +11 -0
- package/dist/hooks/useCommandKit.js.map +1 -0
- package/dist/hooks/useCommandKit.mjs +2 -0
- package/dist/hooks/useCommandKit.mjs.map +1 -0
- package/dist/hooks/useGuild.d.mts +5 -0
- package/dist/hooks/useGuild.d.ts +5 -0
- package/dist/hooks/useGuild.js +11 -0
- package/dist/hooks/useGuild.js.map +1 -0
- package/dist/hooks/useGuild.mjs +2 -0
- package/dist/hooks/useGuild.mjs.map +1 -0
- package/dist/hooks/useInteraction.d.mts +9 -0
- package/dist/hooks/useInteraction.d.ts +9 -0
- package/dist/hooks/useInteraction.js +11 -0
- package/dist/hooks/useInteraction.js.map +1 -0
- package/dist/hooks/useInteraction.mjs +2 -0
- package/dist/hooks/useInteraction.mjs.map +1 -0
- package/dist/hooks/useMember.d.mts +5 -0
- package/dist/hooks/useMember.d.ts +5 -0
- package/dist/hooks/useMember.js +11 -0
- package/dist/hooks/useMember.js.map +1 -0
- package/dist/hooks/useMember.mjs +2 -0
- package/dist/hooks/useMember.mjs.map +1 -0
- package/dist/hooks/useUser.d.mts +5 -0
- package/dist/hooks/useUser.d.ts +5 -0
- package/dist/hooks/useUser.js +11 -0
- package/dist/hooks/useUser.js.map +1 -0
- package/dist/hooks/useUser.mjs +2 -0
- package/dist/hooks/useUser.mjs.map +1 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.d.mts +5 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/typings.d.mts +5 -0
- package/dist/typings.d.ts +5 -0
- package/dist/typings.js +2 -0
- package/dist/typings.js.map +1 -0
- package/dist/typings.mjs +1 -0
- package/dist/typings.mjs.map +1 -0
- package/dist/utils/clone.d.mts +3 -0
- package/dist/utils/clone.d.ts +3 -0
- package/dist/utils/clone.js +2 -0
- package/dist/utils/clone.js.map +1 -0
- package/dist/utils/clone.mjs +2 -0
- package/dist/utils/clone.mjs.map +1 -0
- package/dist/utils/colors.d.mts +27 -0
- package/dist/utils/colors.d.ts +27 -0
- package/dist/utils/colors.js +2 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/colors.mjs +2 -0
- package/dist/utils/colors.mjs.map +1 -0
- package/dist/utils/get-paths.d.mts +4 -0
- package/dist/utils/get-paths.d.ts +4 -0
- package/dist/utils/get-paths.js +2 -0
- package/dist/utils/get-paths.js.map +1 -0
- package/dist/utils/get-paths.mjs +2 -0
- package/dist/utils/get-paths.mjs.map +1 -0
- package/dist/utils/resolve-file-url.d.mts +8 -0
- package/dist/utils/resolve-file-url.d.ts +8 -0
- package/dist/utils/resolve-file-url.js +2 -0
- package/dist/utils/resolve-file-url.js.map +1 -0
- package/dist/utils/resolve-file-url.mjs +2 -0
- package/dist/utils/resolve-file-url.mjs.map +1 -0
- package/dist/utils/signal.d.mts +21 -0
- package/dist/utils/signal.d.ts +21 -0
- package/dist/utils/signal.js +2 -0
- package/dist/utils/signal.js.map +1 -0
- package/dist/utils/signal.mjs +2 -0
- package/dist/utils/signal.mjs.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bootstrap/loadEnv.ts"],"sourcesContent":["import { config } from 'dotenv-cra';\n\nexport function loadEnv(type: 'development' | 'production') {\n process.env.NODE_ENV = type;\n\n const result = config();\n\n return result.error?.message;\n}\n"],"mappings":"yCAAA,OAAS,WAAc,aAEhB,SAAS,QAAQ,KAAoC,CAC1D,eAAQ,IAAI,SAAW,KAER,OAAO,EAER,OAAO,OACvB,CANgB","names":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The handler to run when a button is clicked. This handler is called with the interaction as the first argument.
|
|
5
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
6
|
+
*/
|
|
7
|
+
type CommandKitButtonBuilderInteractionCollectorDispatch = (interaction: ButtonInteraction) => Awaitable<void>;
|
|
8
|
+
type CommandKitButtonBuilderOnEnd = () => Awaitable<void>;
|
|
9
|
+
type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {
|
|
10
|
+
/**
|
|
11
|
+
* The message to listen for button interactions on.
|
|
12
|
+
*/
|
|
13
|
+
message: Message;
|
|
14
|
+
/**
|
|
15
|
+
* The duration (in ms) that the collector should run for.
|
|
16
|
+
*/
|
|
17
|
+
time?: number;
|
|
18
|
+
/**
|
|
19
|
+
* If the collector should automatically reset the timer when a button is clicked.
|
|
20
|
+
*/
|
|
21
|
+
autoReset?: boolean;
|
|
22
|
+
} & Omit<InteractionCollectorOptions<ButtonInteraction>, 'filter' | 'componentType'>;
|
|
23
|
+
declare class ButtonKit extends ButtonBuilder {
|
|
24
|
+
#private;
|
|
25
|
+
/**
|
|
26
|
+
* Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
|
|
27
|
+
* If unused, this expires after 24 hours or custom time if specified.
|
|
28
|
+
* @param handler The handler to run when the button is clicked
|
|
29
|
+
* @param data The context data to use for the interaction collector
|
|
30
|
+
* @returns This button
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const button = new ButtonKit()
|
|
34
|
+
* .setLabel('Click me')
|
|
35
|
+
* .setStyle(ButtonStyle.Primary)
|
|
36
|
+
* .setCustomId('click_me');
|
|
37
|
+
*
|
|
38
|
+
* const row = new ActionRowBuilder().addComponents(button);
|
|
39
|
+
*
|
|
40
|
+
* const message = await channel.send({ content: 'Click the button', components: [row] });
|
|
41
|
+
*
|
|
42
|
+
* button.onClick(async (interaction) => {
|
|
43
|
+
* await interaction.reply('You clicked me!');
|
|
44
|
+
* }, { message });
|
|
45
|
+
*
|
|
46
|
+
* // Remove onClick handler and destroy the interaction collector
|
|
47
|
+
* button.onClick(null);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data?: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
|
|
51
|
+
onEnd(handler: CommandKitButtonBuilderOnEnd): this;
|
|
52
|
+
dispose(): this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { ButtonKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The handler to run when a button is clicked. This handler is called with the interaction as the first argument.
|
|
5
|
+
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
6
|
+
*/
|
|
7
|
+
type CommandKitButtonBuilderInteractionCollectorDispatch = (interaction: ButtonInteraction) => Awaitable<void>;
|
|
8
|
+
type CommandKitButtonBuilderOnEnd = () => Awaitable<void>;
|
|
9
|
+
type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {
|
|
10
|
+
/**
|
|
11
|
+
* The message to listen for button interactions on.
|
|
12
|
+
*/
|
|
13
|
+
message: Message;
|
|
14
|
+
/**
|
|
15
|
+
* The duration (in ms) that the collector should run for.
|
|
16
|
+
*/
|
|
17
|
+
time?: number;
|
|
18
|
+
/**
|
|
19
|
+
* If the collector should automatically reset the timer when a button is clicked.
|
|
20
|
+
*/
|
|
21
|
+
autoReset?: boolean;
|
|
22
|
+
} & Omit<InteractionCollectorOptions<ButtonInteraction>, 'filter' | 'componentType'>;
|
|
23
|
+
declare class ButtonKit extends ButtonBuilder {
|
|
24
|
+
#private;
|
|
25
|
+
/**
|
|
26
|
+
* Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
|
|
27
|
+
* If unused, this expires after 24 hours or custom time if specified.
|
|
28
|
+
* @param handler The handler to run when the button is clicked
|
|
29
|
+
* @param data The context data to use for the interaction collector
|
|
30
|
+
* @returns This button
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const button = new ButtonKit()
|
|
34
|
+
* .setLabel('Click me')
|
|
35
|
+
* .setStyle(ButtonStyle.Primary)
|
|
36
|
+
* .setCustomId('click_me');
|
|
37
|
+
*
|
|
38
|
+
* const row = new ActionRowBuilder().addComponents(button);
|
|
39
|
+
*
|
|
40
|
+
* const message = await channel.send({ content: 'Click the button', components: [row] });
|
|
41
|
+
*
|
|
42
|
+
* button.onClick(async (interaction) => {
|
|
43
|
+
* await interaction.reply('You clicked me!');
|
|
44
|
+
* }, { message });
|
|
45
|
+
*
|
|
46
|
+
* // Remove onClick handler and destroy the interaction collector
|
|
47
|
+
* button.onClick(null);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data?: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
|
|
51
|
+
onEnd(handler: CommandKitButtonBuilderOnEnd): this;
|
|
52
|
+
dispose(): this;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { ButtonKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var ButtonKit_exports={};__export(ButtonKit_exports,{ButtonKit:()=>ButtonKit});module.exports=__toCommonJS(ButtonKit_exports);var import_discord=require("discord.js");var ButtonKit=class extends import_discord.ButtonBuilder{static{__name(this,"ButtonKit")}#onClickHandler=null;#onEndHandler=null;#contextData=null;#collector=null;onClick(handler,data){if(this.data.style===import_discord.ButtonStyle.Link)throw new TypeError('Cannot setup "onClick" handler on link buttons.');if(!handler)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return this.#destroyCollector(),this.#onClickHandler=handler,data&&(this.#contextData=data),this.#setupInteractionCollector(),this}onEnd(handler){if(!handler)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return this.#onEndHandler=handler,this}#setupInteractionCollector(){if(!this.#contextData||!this.#onClickHandler)return;let message=this.#contextData.message;if(!message)throw new TypeError('Cannot setup "onClick" handler without a message in the context data.');if("customId"in this.data&&!this.data.customId)throw new TypeError('Cannot setup "onClick" handler on a button without a custom id.');let data={time:864e5,autoReset:!0,...this.#contextData},collector=this.#collector=message.createMessageComponentCollector({filter:interaction=>interaction.customId===this.data.custom_id&&interaction.message.id===message.id,componentType:import_discord.ComponentType.Button,...data});this.#collector.on("collect",interaction=>{let handler=this.#onClickHandler;return handler?this.#collector?(data.autoReset&&this.#collector.resetTimer(),handler(interaction)):collector.stop("destroyed"):this.#destroyCollector()}),this.#collector.on("end",()=>{this.#destroyCollector(),this.#onEndHandler?.()})}dispose(){return this.#destroyCollector(),this.#onEndHandler?.(),this}#destroyCollector(){this.#collector?.stop("end"),this.#collector?.removeAllListeners(),this.#collector=null,this.#contextData=null,this.#onClickHandler=null}};0&&(module.exports={ButtonKit});
|
|
2
|
+
//# sourceMappingURL=ButtonKit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/ButtonKit.ts"],"sourcesContent":["import {\n type Message,\n type Awaitable,\n type ButtonInteraction,\n type InteractionCollector,\n type InteractionCollectorOptions,\n type APIButtonComponentWithCustomId,\n ButtonStyle,\n ButtonBuilder,\n ComponentType,\n} from 'discord.js';\n\n/**\n * The handler to run when a button is clicked. This handler is called with the interaction as the first argument.\n * If the first argument is null, it means that the interaction collector has been destroyed.\n */\nexport type CommandKitButtonBuilderInteractionCollectorDispatch = (\n interaction: ButtonInteraction,\n) => Awaitable<void>;\n\nexport type CommandKitButtonBuilderOnEnd = () => Awaitable<void>;\n\nexport type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {\n /**\n * The message to listen for button interactions on.\n */\n message: Message;\n /**\n * The duration (in ms) that the collector should run for.\n */\n time?: number;\n /**\n * If the collector should automatically reset the timer when a button is clicked.\n */\n autoReset?: boolean;\n} & Omit<\n InteractionCollectorOptions<ButtonInteraction>,\n 'filter' | 'componentType'\n>;\n\nexport class ButtonKit extends ButtonBuilder {\n #onClickHandler: CommandKitButtonBuilderInteractionCollectorDispatch | null =\n null;\n #onEndHandler: CommandKitButtonBuilderOnEnd | null = null;\n #contextData: CommandKitButtonBuilderInteractionCollectorDispatchContextData | null =\n null;\n #collector: InteractionCollector<ButtonInteraction> | null = null;\n\n /**\n * Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.\n * If unused, this expires after 24 hours or custom time if specified.\n * @param handler The handler to run when the button is clicked\n * @param data The context data to use for the interaction collector\n * @returns This button\n * @example\n * ```ts\n * const button = new ButtonKit()\n * .setLabel('Click me')\n * .setStyle(ButtonStyle.Primary)\n * .setCustomId('click_me');\n *\n * const row = new ActionRowBuilder().addComponents(button);\n *\n * const message = await channel.send({ content: 'Click the button', components: [row] });\n *\n * button.onClick(async (interaction) => {\n * await interaction.reply('You clicked me!');\n * }, { message });\n *\n * // Remove onClick handler and destroy the interaction collector\n * button.onClick(null);\n * ```\n */\n public onClick(\n handler: CommandKitButtonBuilderInteractionCollectorDispatch,\n data?: CommandKitButtonBuilderInteractionCollectorDispatchContextData,\n ): this {\n if (this.data.style === ButtonStyle.Link) {\n throw new TypeError('Cannot setup \"onClick\" handler on link buttons.');\n }\n\n if (!handler) {\n throw new TypeError(\n 'Cannot setup \"onClick\" without a handler function parameter.',\n );\n }\n\n this.#destroyCollector();\n\n this.#onClickHandler = handler;\n if (data) this.#contextData = data;\n\n this.#setupInteractionCollector();\n\n return this;\n }\n\n public onEnd(handler: CommandKitButtonBuilderOnEnd): this {\n if (!handler) {\n throw new TypeError(\n 'Cannot setup \"onEnd\" without a handler function parameter.',\n );\n }\n\n this.#onEndHandler = handler;\n\n return this;\n }\n\n #setupInteractionCollector() {\n if (!this.#contextData || !this.#onClickHandler) return;\n\n const message = this.#contextData.message;\n\n if (!message) {\n throw new TypeError(\n 'Cannot setup \"onClick\" handler without a message in the context data.',\n );\n }\n\n if ('customId' in this.data && !this.data.customId) {\n throw new TypeError(\n 'Cannot setup \"onClick\" handler on a button without a custom id.',\n );\n }\n\n const data = {\n time: 86_400_000,\n autoReset: true,\n ...this.#contextData,\n };\n\n const collector = (this.#collector =\n message.createMessageComponentCollector({\n filter: (interaction) =>\n interaction.customId ===\n (<APIButtonComponentWithCustomId>this.data).custom_id &&\n interaction.message.id === message.id,\n componentType: ComponentType.Button,\n ...data,\n }));\n\n this.#collector.on('collect', (interaction) => {\n const handler = this.#onClickHandler;\n\n if (!handler) return this.#destroyCollector();\n\n if (!this.#collector) {\n return collector.stop('destroyed');\n }\n\n if (data.autoReset) {\n this.#collector.resetTimer();\n }\n\n return handler(interaction);\n });\n\n this.#collector.on('end', () => {\n this.#destroyCollector();\n this.#onEndHandler?.();\n });\n }\n\n public dispose() {\n this.#destroyCollector();\n this.#onEndHandler?.();\n return this;\n }\n\n #destroyCollector() {\n this.#collector?.stop('end');\n this.#collector?.removeAllListeners();\n this.#collector = null;\n this.#contextData = null;\n this.#onClickHandler = null;\n }\n}\n"],"mappings":"ouBAAA,8HAAA,mBAUO,sBA8BA,IAAM,UAAN,cAAwB,4BAAc,CAxC7C,MAwC6C,0BAC3C,gBACE,KACF,cAAqD,KACrD,aACE,KACF,WAA6D,KA2BtD,QACL,QACA,KACM,CACN,GAAI,KAAK,KAAK,QAAU,2BAAY,KAClC,MAAM,IAAI,UAAU,iDAAiD,EAGvE,GAAI,CAAC,QACH,MAAM,IAAI,UACR,8DACF,EAGF,YAAK,kBAAkB,EAEvB,KAAK,gBAAkB,QACnB,OAAM,KAAK,aAAe,MAE9B,KAAK,2BAA2B,EAEzB,IACT,CAEO,MAAM,QAA6C,CACxD,GAAI,CAAC,QACH,MAAM,IAAI,UACR,4DACF,EAGF,YAAK,cAAgB,QAEd,IACT,CAEA,4BAA6B,CAC3B,GAAI,CAAC,KAAK,cAAgB,CAAC,KAAK,gBAAiB,OAEjD,IAAM,QAAU,KAAK,aAAa,QAElC,GAAI,CAAC,QACH,MAAM,IAAI,UACR,uEACF,EAGF,GAAI,aAAc,KAAK,MAAQ,CAAC,KAAK,KAAK,SACxC,MAAM,IAAI,UACR,iEACF,EAGF,IAAM,KAAO,CACX,KAAM,MACN,UAAW,GACX,GAAG,KAAK,YACV,EAEM,UAAa,KAAK,WACtB,QAAQ,gCAAgC,CACtC,OAAS,aACP,YAAY,WACuB,KAAK,KAAM,WAC9C,YAAY,QAAQ,KAAO,QAAQ,GACrC,cAAe,6BAAc,OAC7B,GAAG,IACL,CAAC,EAEH,KAAK,WAAW,GAAG,UAAY,aAAgB,CAC7C,IAAM,QAAU,KAAK,gBAErB,OAAK,QAEA,KAAK,YAIN,KAAK,WACP,KAAK,WAAW,WAAW,EAGtB,QAAQ,WAAW,GAPjB,UAAU,KAAK,WAAW,EAHd,KAAK,kBAAkB,CAW9C,CAAC,EAED,KAAK,WAAW,GAAG,MAAO,IAAM,CAC9B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,CACvB,CAAC,CACH,CAEO,SAAU,CACf,YAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACd,IACT,CAEA,mBAAoB,CAClB,KAAK,YAAY,KAAK,KAAK,EAC3B,KAAK,YAAY,mBAAmB,EACpC,KAAK,WAAa,KAClB,KAAK,aAAe,KACpB,KAAK,gBAAkB,IACzB,CACF","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var components_exports={};__export(components_exports,{ButtonKit:()=>ButtonKit});module.exports=__toCommonJS(components_exports);var import_discord=require("discord.js");var ButtonKit=class extends import_discord.ButtonBuilder{static{__name(this,"ButtonKit")}#onClickHandler=null;#onEndHandler=null;#contextData=null;#collector=null;onClick(handler,data){if(this.data.style===import_discord.ButtonStyle.Link)throw new TypeError('Cannot setup "onClick" handler on link buttons.');if(!handler)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return this.#destroyCollector(),this.#onClickHandler=handler,data&&(this.#contextData=data),this.#setupInteractionCollector(),this}onEnd(handler){if(!handler)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return this.#onEndHandler=handler,this}#setupInteractionCollector(){if(!this.#contextData||!this.#onClickHandler)return;let message=this.#contextData.message;if(!message)throw new TypeError('Cannot setup "onClick" handler without a message in the context data.');if("customId"in this.data&&!this.data.customId)throw new TypeError('Cannot setup "onClick" handler on a button without a custom id.');let data={time:864e5,autoReset:!0,...this.#contextData},collector=this.#collector=message.createMessageComponentCollector({filter:interaction=>interaction.customId===this.data.custom_id&&interaction.message.id===message.id,componentType:import_discord.ComponentType.Button,...data});this.#collector.on("collect",interaction=>{let handler=this.#onClickHandler;return handler?this.#collector?(data.autoReset&&this.#collector.resetTimer(),handler(interaction)):collector.stop("destroyed"):this.#destroyCollector()}),this.#collector.on("end",()=>{this.#destroyCollector(),this.#onEndHandler?.()})}dispose(){return this.#destroyCollector(),this.#onEndHandler?.(),this}#destroyCollector(){this.#collector?.stop("end"),this.#collector?.removeAllListeners(),this.#collector=null,this.#contextData=null,this.#onClickHandler=null}};0&&(module.exports={ButtonKit});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts","../../src/components/ButtonKit.ts"],"sourcesContent":["export * from './ButtonKit';\n","import {\n type Message,\n type Awaitable,\n type ButtonInteraction,\n type InteractionCollector,\n type InteractionCollectorOptions,\n type APIButtonComponentWithCustomId,\n ButtonStyle,\n ButtonBuilder,\n ComponentType,\n} from 'discord.js';\n\n/**\n * The handler to run when a button is clicked. This handler is called with the interaction as the first argument.\n * If the first argument is null, it means that the interaction collector has been destroyed.\n */\nexport type CommandKitButtonBuilderInteractionCollectorDispatch = (\n interaction: ButtonInteraction,\n) => Awaitable<void>;\n\nexport type CommandKitButtonBuilderOnEnd = () => Awaitable<void>;\n\nexport type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {\n /**\n * The message to listen for button interactions on.\n */\n message: Message;\n /**\n * The duration (in ms) that the collector should run for.\n */\n time?: number;\n /**\n * If the collector should automatically reset the timer when a button is clicked.\n */\n autoReset?: boolean;\n} & Omit<\n InteractionCollectorOptions<ButtonInteraction>,\n 'filter' | 'componentType'\n>;\n\nexport class ButtonKit extends ButtonBuilder {\n #onClickHandler: CommandKitButtonBuilderInteractionCollectorDispatch | null =\n null;\n #onEndHandler: CommandKitButtonBuilderOnEnd | null = null;\n #contextData: CommandKitButtonBuilderInteractionCollectorDispatchContextData | null =\n null;\n #collector: InteractionCollector<ButtonInteraction> | null = null;\n\n /**\n * Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.\n * If unused, this expires after 24 hours or custom time if specified.\n * @param handler The handler to run when the button is clicked\n * @param data The context data to use for the interaction collector\n * @returns This button\n * @example\n * ```ts\n * const button = new ButtonKit()\n * .setLabel('Click me')\n * .setStyle(ButtonStyle.Primary)\n * .setCustomId('click_me');\n *\n * const row = new ActionRowBuilder().addComponents(button);\n *\n * const message = await channel.send({ content: 'Click the button', components: [row] });\n *\n * button.onClick(async (interaction) => {\n * await interaction.reply('You clicked me!');\n * }, { message });\n *\n * // Remove onClick handler and destroy the interaction collector\n * button.onClick(null);\n * ```\n */\n public onClick(\n handler: CommandKitButtonBuilderInteractionCollectorDispatch,\n data?: CommandKitButtonBuilderInteractionCollectorDispatchContextData,\n ): this {\n if (this.data.style === ButtonStyle.Link) {\n throw new TypeError('Cannot setup \"onClick\" handler on link buttons.');\n }\n\n if (!handler) {\n throw new TypeError(\n 'Cannot setup \"onClick\" without a handler function parameter.',\n );\n }\n\n this.#destroyCollector();\n\n this.#onClickHandler = handler;\n if (data) this.#contextData = data;\n\n this.#setupInteractionCollector();\n\n return this;\n }\n\n public onEnd(handler: CommandKitButtonBuilderOnEnd): this {\n if (!handler) {\n throw new TypeError(\n 'Cannot setup \"onEnd\" without a handler function parameter.',\n );\n }\n\n this.#onEndHandler = handler;\n\n return this;\n }\n\n #setupInteractionCollector() {\n if (!this.#contextData || !this.#onClickHandler) return;\n\n const message = this.#contextData.message;\n\n if (!message) {\n throw new TypeError(\n 'Cannot setup \"onClick\" handler without a message in the context data.',\n );\n }\n\n if ('customId' in this.data && !this.data.customId) {\n throw new TypeError(\n 'Cannot setup \"onClick\" handler on a button without a custom id.',\n );\n }\n\n const data = {\n time: 86_400_000,\n autoReset: true,\n ...this.#contextData,\n };\n\n const collector = (this.#collector =\n message.createMessageComponentCollector({\n filter: (interaction) =>\n interaction.customId ===\n (<APIButtonComponentWithCustomId>this.data).custom_id &&\n interaction.message.id === message.id,\n componentType: ComponentType.Button,\n ...data,\n }));\n\n this.#collector.on('collect', (interaction) => {\n const handler = this.#onClickHandler;\n\n if (!handler) return this.#destroyCollector();\n\n if (!this.#collector) {\n return collector.stop('destroyed');\n }\n\n if (data.autoReset) {\n this.#collector.resetTimer();\n }\n\n return handler(interaction);\n });\n\n this.#collector.on('end', () => {\n this.#destroyCollector();\n this.#onEndHandler?.();\n });\n }\n\n public dispose() {\n this.#destroyCollector();\n this.#onEndHandler?.();\n return this;\n }\n\n #destroyCollector() {\n this.#collector?.stop('end');\n this.#collector?.removeAllListeners();\n this.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,CACvB,CAAC,CACH,CAEO,SAAU,CACf,YAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACd,IACT,CAEA,mBAAoB,CAClB,KAAK,YAAY,KAAK,KAAK,EAC3B,KAAK,YAAY,mBAAmB,EACpC,KAAK,WAAa,KAClB,KAAK,aAAe,KACpB,KAAK,gBAAkB,IACzB,CACF","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ClientOptions } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
interface CommandKitConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The Discord client options.
|
|
6
|
+
*/
|
|
7
|
+
clientOptions: ClientOptions;
|
|
8
|
+
/**
|
|
9
|
+
* The Discord bot token. Defaults to `process.env.DISCORD_TOKEN`.
|
|
10
|
+
*/
|
|
11
|
+
token?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether or not to use the watch mode. Defaults to `true`.
|
|
14
|
+
*/
|
|
15
|
+
watch: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The output directory of the project. Defaults to `dist`.
|
|
18
|
+
*/
|
|
19
|
+
outDir: string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether or not to include extra env utilities. Defaults to `true`.
|
|
22
|
+
*/
|
|
23
|
+
envExtra: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Node.js cli options.
|
|
26
|
+
*/
|
|
27
|
+
nodeOptions: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether or not to clear default restart logs. Defaults to `true`.
|
|
30
|
+
*/
|
|
31
|
+
clearRestartLogs: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether or not to minify the output. Defaults to `false`.
|
|
34
|
+
*/
|
|
35
|
+
minify: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether or not to include sourcemaps in production build. Defaults to `false`.
|
|
38
|
+
*/
|
|
39
|
+
sourcemap: boolean | 'inline';
|
|
40
|
+
/**
|
|
41
|
+
* Whether or not to include anti-crash handler in production. Defaults to `true`.
|
|
42
|
+
*/
|
|
43
|
+
antiCrash: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether or not to polyfill `require` function. Defaults to `true`.
|
|
46
|
+
*/
|
|
47
|
+
requirePolyfill: boolean;
|
|
48
|
+
}
|
|
49
|
+
declare function getConfig(): CommandKitConfig;
|
|
50
|
+
declare const requiredProps: readonly ["clientOptions"];
|
|
51
|
+
type R = (typeof requiredProps)[number];
|
|
52
|
+
type PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> & Pick<T, R>;
|
|
53
|
+
declare function defineConfig(config: PartialConfig<CommandKitConfig>): Partial<CommandKitConfig>;
|
|
54
|
+
|
|
55
|
+
export { type CommandKitConfig, defineConfig, getConfig };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ClientOptions } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
interface CommandKitConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The Discord client options.
|
|
6
|
+
*/
|
|
7
|
+
clientOptions: ClientOptions;
|
|
8
|
+
/**
|
|
9
|
+
* The Discord bot token. Defaults to `process.env.DISCORD_TOKEN`.
|
|
10
|
+
*/
|
|
11
|
+
token?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether or not to use the watch mode. Defaults to `true`.
|
|
14
|
+
*/
|
|
15
|
+
watch: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The output directory of the project. Defaults to `dist`.
|
|
18
|
+
*/
|
|
19
|
+
outDir: string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether or not to include extra env utilities. Defaults to `true`.
|
|
22
|
+
*/
|
|
23
|
+
envExtra: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Node.js cli options.
|
|
26
|
+
*/
|
|
27
|
+
nodeOptions: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether or not to clear default restart logs. Defaults to `true`.
|
|
30
|
+
*/
|
|
31
|
+
clearRestartLogs: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether or not to minify the output. Defaults to `false`.
|
|
34
|
+
*/
|
|
35
|
+
minify: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether or not to include sourcemaps in production build. Defaults to `false`.
|
|
38
|
+
*/
|
|
39
|
+
sourcemap: boolean | 'inline';
|
|
40
|
+
/**
|
|
41
|
+
* Whether or not to include anti-crash handler in production. Defaults to `true`.
|
|
42
|
+
*/
|
|
43
|
+
antiCrash: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether or not to polyfill `require` function. Defaults to `true`.
|
|
46
|
+
*/
|
|
47
|
+
requirePolyfill: boolean;
|
|
48
|
+
}
|
|
49
|
+
declare function getConfig(): CommandKitConfig;
|
|
50
|
+
declare const requiredProps: readonly ["clientOptions"];
|
|
51
|
+
type R = (typeof requiredProps)[number];
|
|
52
|
+
type PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> & Pick<T, R>;
|
|
53
|
+
declare function defineConfig(config: PartialConfig<CommandKitConfig>): Partial<CommandKitConfig>;
|
|
54
|
+
|
|
55
|
+
export { type CommandKitConfig, defineConfig, getConfig };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var config_exports={};__export(config_exports,{defineConfig:()=>defineConfig,getConfig:()=>getConfig});module.exports=__toCommonJS(config_exports);var globalConfig={envExtra:!0,outDir:"dist",watch:!0,clearRestartLogs:!0,minify:!1,sourcemap:!1,nodeOptions:[],antiCrash:!0,requirePolyfill:!0,token:process.env.DISCORD_TOKEN};function getConfig(){return globalConfig}__name(getConfig,"getConfig");var requiredProps=["clientOptions"];function defineConfig(config){for(let prop of requiredProps)if(!config[prop])throw new Error(`[CommandKit Config] Missing required config property: ${prop}`);return globalConfig={...globalConfig,...config},globalConfig}__name(defineConfig,"defineConfig");0&&(module.exports={defineConfig,getConfig});
|
|
2
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import type { ClientOptions } from 'discord.js';\n\nexport interface CommandKitConfig {\n /**\n * The Discord client options.\n */\n clientOptions: ClientOptions;\n /**\n * The Discord bot token. Defaults to `process.env.DISCORD_TOKEN`.\n */\n token?: string;\n /**\n * Whether or not to use the watch mode. Defaults to `true`.\n */\n watch: boolean;\n /**\n * The output directory of the project. Defaults to `dist`.\n */\n outDir: string;\n /**\n * Whether or not to include extra env utilities. Defaults to `true`.\n */\n envExtra: boolean;\n /**\n * Node.js cli options.\n */\n nodeOptions: string[];\n /**\n * Whether or not to clear default restart logs. Defaults to `true`.\n */\n clearRestartLogs: boolean;\n /**\n * Whether or not to minify the output. Defaults to `false`.\n */\n minify: boolean;\n /**\n * Whether or not to include sourcemaps in production build. Defaults to `false`.\n */\n sourcemap: boolean | 'inline';\n /**\n * Whether or not to include anti-crash handler in production. Defaults to `true`.\n */\n antiCrash: boolean;\n /**\n * Whether or not to polyfill `require` function. Defaults to `true`.\n */\n requirePolyfill: boolean;\n}\n\nlet globalConfig: Partial<CommandKitConfig> = {\n envExtra: true,\n outDir: 'dist',\n watch: true,\n clearRestartLogs: true,\n minify: false,\n sourcemap: false,\n nodeOptions: [],\n antiCrash: true,\n requirePolyfill: true,\n token: process.env.DISCORD_TOKEN,\n};\n\nexport function getConfig(): CommandKitConfig {\n return globalConfig as CommandKitConfig;\n}\n\nconst requiredProps = ['clientOptions'] as const;\n\ntype R = (typeof requiredProps)[number];\n\ntype PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> &\n Pick<T, R>;\n\nexport function defineConfig(config: PartialConfig<CommandKitConfig>) {\n for (const prop of requiredProps) {\n if (!config[prop]) {\n throw new Error(\n `[CommandKit Config] Missing required config property: ${prop}`,\n );\n }\n }\n\n globalConfig = {\n ...globalConfig,\n ...config,\n };\n\n return globalConfig;\n}\n"],"mappings":"ouBAAA,mJAiDA,IAAI,aAA0C,CAC5C,SAAU,GACV,OAAQ,OACR,MAAO,GACP,iBAAkB,GAClB,OAAQ,GACR,UAAW,GACX,YAAa,CAAC,EACd,UAAW,GACX,gBAAiB,GACjB,MAAO,QAAQ,IAAI,aACrB,EAEO,SAAS,WAA8B,CAC5C,OAAO,YACT,CAFgB,8BAIhB,IAAM,cAAgB,CAAC,eAAe,EAO/B,SAAS,aAAa,OAAyC,CACpE,QAAW,QAAQ,cACjB,GAAI,CAAC,OAAO,IAAI,EACd,MAAM,IAAI,MACR,yDAAyD,IAAI,EAC/D,EAIJ,oBAAe,CACb,GAAG,aACH,GAAG,MACL,EAEO,YACT,CAfgB","names":[]}
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var development_exports={};__export(development_exports,{initializeDevelopmentEnvironment:()=>initializeDevelopmentEnvironment});module.exports=__toCommonJS(development_exports);var import_node_fs=require("fs"),import_node_path=require("path");var ConfigLookupPaths=["js","cjs","mjs"];async function findConfigPath(relative){for(let extension of ConfigLookupPaths){let path=(0,import_node_path.join)(relative,`commandkit.${extension}`);if((0,import_node_fs.existsSync)(path))return path}return null}__name(findConfigPath,"findConfigPath");async function importConfig(path){let config2=await import(`file://${path}`);return config2?.default??config2}__name(importConfig,"importConfig");var resetColor="\x1B[0m",colors_default={reset:text=>`${text}${resetColor}`,bright:text=>`\x1B[1m${text}${resetColor}`,dim:text=>`\x1B[2m${text}${resetColor}`,underscore:text=>`\x1B[4m${text}${resetColor}`,blink:text=>`\x1B[5m${text}${resetColor}`,reverse:text=>`\x1B[7m${text}${resetColor}`,hidden:text=>`\x1B[8m${text}${resetColor}`,black:text=>`\x1B[30m${text}${resetColor}`,red:text=>`\x1B[31m${text}${resetColor}`,green:text=>`\x1B[32m${text}${resetColor}`,yellow:text=>`\x1B[33m${text}${resetColor}`,blue:text=>`\x1B[34m${text}${resetColor}`,magenta:text=>`\x1B[35m${text}${resetColor}`,cyan:text=>`\x1B[36m${text}${resetColor}`,white:text=>`\x1B[37m${text}${resetColor}`,bgBlack:text=>`\x1B[40m${text}${resetColor}`,bgRed:text=>`\x1B[41m${text}${resetColor}`,bgGreen:text=>`\x1B[42m${text}${resetColor}`,bgYellow:text=>`\x1B[43m${text}${resetColor}`,bgBlue:text=>`\x1B[44m${text}${resetColor}`,bgMagenta:text=>`\x1B[45m${text}${resetColor}`,bgCyan:text=>`\x1B[46m${text}${resetColor}`,bgWhite:text=>`\x1B[47m${text}${resetColor}`};var Logger={Fatal:(...message)=>{console.log(colors_default.red("[FATAL ERROR]"),...message),process.exit(1)},Warning:(...message)=>{console.log(colors_default.yellow("[WARNING]"),...message)},Info:(...message)=>{console.log(colors_default.green("[INFO]"),...message)},Debug:(...message)=>{console.log(colors_default.blue("[DEBUG]"),...message)},Log:(...message)=>{console.log(...message)}};var import_dotenv_cra=require("dotenv-cra");function loadEnv(type){return process.env.NODE_ENV=type,(0,import_dotenv_cra.config)().error?.message}__name(loadEnv,"loadEnv");var import_discord=require("discord.js");var globalConfig={envExtra:!0,outDir:"dist",watch:!0,clearRestartLogs:!0,minify:!1,sourcemap:!1,nodeOptions:[],antiCrash:!0,requirePolyfill:!0,token:process.env.DISCORD_TOKEN};function getConfig(){return globalConfig}__name(getConfig,"getConfig");var discord_client;function getClient(){return discord_client}__name(getClient,"getClient");function createClient(){let config2=getConfig();return discord_client=new import_discord.Client(config2.clientOptions),discord_client}__name(createClient,"createClient");var import_tsup=require("tsup");var import_path=require("path");function bundle(mode){switch(mode){case"development":return buildDevelopment();default:throw new Error("Not implemented")}}__name(bundle,"bundle");function buildDevelopment(){let{watch}=getConfig(),outDir=(0,import_path.join)(process.cwd(),".commandkit");return(0,import_tsup.build)({clean:!0,format:["esm"],bundle:!1,dts:!1,skipNodeModulesBundle:!0,minify:!1,shims:!0,sourcemap:"inline",keepNames:!0,outDir:".commandkit",silent:!0,entry:["src"],watch,async onSuccess(){}}).then(()=>(0,import_path.join)(outDir,"client.mjs"))}__name(buildDevelopment,"buildDevelopment");var commandkitVersion="0.1.11-dev.20240203230231";function printBanner(){let banner=colors_default.magenta(`\u25C6 CommandKit ${commandkitVersion}`);Logger.Log(banner),Logger.Info("Initializing the development environment...")}__name(printBanner,"printBanner");async function initializeDevelopmentEnvironment(args){if(printBanner(),getClient()){Logger.Fatal("The development environment is already initialized.");return}let envErr=loadEnv("development");envErr?Logger.Warning("Failed to load .env",envErr):Logger.Debug("Loaded .env");let configPath=await findConfigPath(args.config??process.cwd());if(!configPath){let msg=`Could not locate the commandkit config file${args.config?" at "+args.config:" in the current working directory"}.`;Logger.Fatal(msg);return}try{var config2=await importConfig(configPath);Logger.Debug("Loaded config from",colors_default.yellow(configPath))}catch(e){Logger.Warning("Failed to load config"),Logger.Fatal(colors_default.red(e.stack??`${e}`));return}let client=createClient(),entrypoint=await bundle("development");try{await import(`file://${entrypoint}`),await client.login(config2.token)}catch(e){Logger.Fatal("Failed to load the client entrypoint",e)}}__name(initializeDevelopmentEnvironment,"initializeDevelopmentEnvironment");0&&(module.exports={initializeDevelopmentEnvironment});
|
|
2
|
+
//# sourceMappingURL=development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/environment/actions/development.ts","../../../src/environment/common/config.ts","../../../src/utils/colors.ts","../../../src/environment/common/logger.ts","../../../src/bootstrap/loadEnv.ts","../../../src/bootstrap/client.ts","../../../src/config.ts","../../../src/environment/bundler/bundle.ts"],"sourcesContent":["import type yargs from 'yargs';\nimport { findConfigPath, importConfig } from '../common/config';\nimport colors from '../../utils/colors';\nimport { Logger } from '../common/logger';\nimport { loadEnv } from '../../bootstrap/loadEnv';\nimport { createClient, getClient } from '../../bootstrap/client';\nimport { bundle } from '../bundler/bundle';\n\nconst commandkitVersion = '0.1.11-dev.20240203230231';\n\nfunction printBanner() {\n const banner = colors.magenta(\n `${String.fromCharCode(9670)} CommandKit ${commandkitVersion}`,\n );\n Logger.Log(banner);\n Logger.Info('Initializing the development environment...');\n}\n\nexport async function initializeDevelopmentEnvironment(\n args: yargs.ArgumentsCamelCase<{\n config?: string | undefined;\n nodeOptions?: string | undefined;\n }>,\n) {\n printBanner();\n\n if (getClient()) {\n Logger.Fatal('The development environment is already initialized.');\n return;\n }\n\n const envErr = loadEnv('development');\n\n if (envErr) {\n Logger.Warning('Failed to load .env', envErr);\n } else {\n Logger.Debug('Loaded .env');\n }\n\n const configPath = await findConfigPath(args.config ?? process.cwd());\n if (!configPath) {\n const msg = `Could not locate the commandkit config file${\n args.config ? ' at ' + args.config : ' in the current working directory'\n }.`;\n Logger.Fatal(msg);\n return;\n }\n\n try {\n var config = await importConfig(configPath);\n Logger.Debug('Loaded config from', colors.yellow(configPath));\n } catch (e) {\n Logger.Warning('Failed to load config');\n Logger.Fatal(colors.red((e as Error).stack ?? `${e}`));\n return;\n }\n\n const client = createClient();\n\n // build the project\n const entrypoint = await bundle('development');\n\n try {\n // load the client entrypoint\n await import(`file://${entrypoint}`);\n await client.login(config.token);\n } catch (e) {\n Logger.Fatal('Failed to load the client entrypoint', e);\n }\n}\n","import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { CommandKitConfig } from '../../config';\n\nconst ConfigLookupPaths = [\n // javascript\n 'js',\n 'cjs',\n 'mjs',\n];\n\nexport async function findConfigPath(relative: string) {\n for (const extension of ConfigLookupPaths) {\n const path = join(relative, `commandkit.${extension}`);\n if (existsSync(path)) return path;\n }\n\n return null;\n}\n\nexport async function importConfig(path: string): Promise<CommandKitConfig> {\n const config = await import(`file://${path}`);\n return config?.default ?? config;\n}\n","const resetColor = '\\x1b[0m';\n\nexport default {\n reset: (text: string) => `${text}${resetColor}`,\n bright: (text: string) => `\\x1b[1m${text}${resetColor}`,\n dim: (text: string) => `\\x1b[2m${text}${resetColor}`,\n underscore: (text: string) => `\\x1b[4m${text}${resetColor}`,\n blink: (text: string) => `\\x1b[5m${text}${resetColor}`,\n reverse: (text: string) => `\\x1b[7m${text}${resetColor}`,\n hidden: (text: string) => `\\x1b[8m${text}${resetColor}`,\n\n black: (text: string) => `\\x1b[30m${text}${resetColor}`,\n red: (text: string) => `\\x1b[31m${text}${resetColor}`,\n green: (text: string) => `\\x1b[32m${text}${resetColor}`,\n yellow: (text: string) => `\\x1b[33m${text}${resetColor}`,\n blue: (text: string) => `\\x1b[34m${text}${resetColor}`,\n magenta: (text: string) => `\\x1b[35m${text}${resetColor}`,\n cyan: (text: string) => `\\x1b[36m${text}${resetColor}`,\n white: (text: string) => `\\x1b[37m${text}${resetColor}`,\n\n bgBlack: (text: string) => `\\x1b[40m${text}${resetColor}`,\n bgRed: (text: string) => `\\x1b[41m${text}${resetColor}`,\n bgGreen: (text: string) => `\\x1b[42m${text}${resetColor}`,\n bgYellow: (text: string) => `\\x1b[43m${text}${resetColor}`,\n bgBlue: (text: string) => `\\x1b[44m${text}${resetColor}`,\n bgMagenta: (text: string) => `\\x1b[45m${text}${resetColor}`,\n bgCyan: (text: string) => `\\x1b[46m${text}${resetColor}`,\n bgWhite: (text: string) => `\\x1b[47m${text}${resetColor}`,\n};\n","import colors from '../../utils/colors';\n\nexport const Logger = {\n Fatal: (...message: unknown[]) => {\n console.log(colors.red('[FATAL ERROR]'), ...message);\n process.exit(1);\n },\n Warning: (...message: unknown[]) => {\n console.log(colors.yellow('[WARNING]'), ...message);\n },\n Info: (...message: unknown[]) => {\n console.log(colors.green('[INFO]'), ...message);\n },\n Debug: (...message: unknown[]) => {\n console.log(colors.blue('[DEBUG]'), ...message);\n },\n Log: (...message: unknown[]) => {\n console.log(...message);\n },\n};\n","import { config } from 'dotenv-cra';\n\nexport function loadEnv(type: 'development' | 'production') {\n process.env.NODE_ENV = type;\n\n const result = config();\n\n return result.error?.message;\n}\n","import { Client } from 'discord.js';\nimport { getConfig } from '../config';\n\nlet discord_client: Client;\n\n/**\n * @internal\n */\nexport function getClient() {\n return discord_client;\n}\n\n/**\n * Fetches the client instance. If the client instance is not initialized, an error will be thrown.\n */\nexport function client<T extends boolean = boolean>() {\n if (!discord_client) {\n throw new Error(\n 'Client was not initialized. Make sure to run \"commandkit dev\" to bootstrap the client.',\n );\n }\n\n return discord_client as Client<T>;\n}\n\nexport function createClient() {\n const config = getConfig();\n\n discord_client = new Client(config.clientOptions);\n\n return discord_client;\n}\n","import type { ClientOptions } from 'discord.js';\n\nexport interface CommandKitConfig {\n /**\n * The Discord client options.\n */\n clientOptions: ClientOptions;\n /**\n * The Discord bot token. Defaults to `process.env.DISCORD_TOKEN`.\n */\n token?: string;\n /**\n * Whether or not to use the watch mode. Defaults to `true`.\n */\n watch: boolean;\n /**\n * The output directory of the project. Defaults to `dist`.\n */\n outDir: string;\n /**\n * Whether or not to include extra env utilities. Defaults to `true`.\n */\n envExtra: boolean;\n /**\n * Node.js cli options.\n */\n nodeOptions: string[];\n /**\n * Whether or not to clear default restart logs. Defaults to `true`.\n */\n clearRestartLogs: boolean;\n /**\n * Whether or not to minify the output. Defaults to `false`.\n */\n minify: boolean;\n /**\n * Whether or not to include sourcemaps in production build. Defaults to `false`.\n */\n sourcemap: boolean | 'inline';\n /**\n * Whether or not to include anti-crash handler in production. Defaults to `true`.\n */\n antiCrash: boolean;\n /**\n * Whether or not to polyfill `require` function. Defaults to `true`.\n */\n requirePolyfill: boolean;\n}\n\nlet globalConfig: Partial<CommandKitConfig> = {\n envExtra: true,\n outDir: 'dist',\n watch: true,\n clearRestartLogs: true,\n minify: false,\n sourcemap: false,\n nodeOptions: [],\n antiCrash: true,\n requirePolyfill: true,\n token: process.env.DISCORD_TOKEN,\n};\n\nexport function getConfig(): CommandKitConfig {\n return globalConfig as CommandKitConfig;\n}\n\nconst requiredProps = ['clientOptions'] as const;\n\ntype R = (typeof requiredProps)[number];\n\ntype PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> &\n Pick<T, R>;\n\nexport function defineConfig(config: PartialConfig<CommandKitConfig>) {\n for (const prop of requiredProps) {\n if (!config[prop]) {\n throw new Error(\n `[CommandKit Config] Missing required config property: ${prop}`,\n );\n }\n }\n\n globalConfig = {\n ...globalConfig,\n ...config,\n };\n\n return globalConfig;\n}\n","import { build } from 'tsup';\nimport { getConfig } from '../../config';\nimport { join } from 'path';\n\nexport function bundle(mode: 'development' | 'production') {\n switch (mode) {\n case 'development':\n return buildDevelopment();\n default:\n throw new Error('Not implemented');\n }\n}\n\nfunction buildDevelopment() {\n const { watch } = getConfig();\n\n const outDir = join(process.cwd(), '.commandkit');\n\n return build({\n clean: true,\n format: ['esm'],\n bundle: false,\n dts: false,\n skipNodeModulesBundle: true,\n minify: false,\n shims: true,\n sourcemap: 'inline',\n keepNames: true,\n outDir: '.commandkit',\n silent: true,\n entry: ['src'],\n watch,\n async onSuccess() {\n // return await injectShims('.commandkit', main, false, requirePolyfill);\n },\n }).then(() => {\n return join(outDir, 'client.mjs');\n });\n}\n"],"mappings":"ouBAAA,kLCAA,mBAA2B,cAC3B,iBAAqB,gBAGrB,IAAM,kBAAoB,CAExB,KACA,MACA,KACF,EAEA,eAAsB,eAAe,SAAkB,CACrD,QAAW,aAAa,kBAAmB,CACzC,IAAM,QAAO,uBAAK,SAAU,cAAc,SAAS,EAAE,EACrD,MAAI,2BAAW,IAAI,EAAG,OAAO,IAC/B,CAEA,OAAO,IACT,CAPsB,wCAStB,eAAsB,aAAa,KAAyC,CAC1E,IAAMA,QAAS,MAAM,OAAO,UAAU,IAAI,IAC1C,OAAOA,SAAQ,SAAWA,OAC5B,CAHsB,oCCpBtB,IAAM,WAAa,UAEZ,eAAQ,CACb,MAAQ,MAAiB,GAAG,IAAI,GAAG,UAAU,GAC7C,OAAS,MAAiB,UAAU,IAAI,GAAG,UAAU,GACrD,IAAM,MAAiB,UAAU,IAAI,GAAG,UAAU,GAClD,WAAa,MAAiB,UAAU,IAAI,GAAG,UAAU,GACzD,MAAQ,MAAiB,UAAU,IAAI,GAAG,UAAU,GACpD,QAAU,MAAiB,UAAU,IAAI,GAAG,UAAU,GACtD,OAAS,MAAiB,UAAU,IAAI,GAAG,UAAU,GAErD,MAAQ,MAAiB,WAAW,IAAI,GAAG,UAAU,GACrD,IAAM,MAAiB,WAAW,IAAI,GAAG,UAAU,GACnD,MAAQ,MAAiB,WAAW,IAAI,GAAG,UAAU,GACrD,OAAS,MAAiB,WAAW,IAAI,GAAG,UAAU,GACtD,KAAO,MAAiB,WAAW,IAAI,GAAG,UAAU,GACpD,QAAU,MAAiB,WAAW,IAAI,GAAG,UAAU,GACvD,KAAO,MAAiB,WAAW,IAAI,GAAG,UAAU,GACpD,M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MAAM,aAAa,UAAU,EAC1C,OAAO,MAAM,qBAAsB,eAAO,OAAO,UAAU,CAAC,CAC9D,OAAS,EAAG,CACV,OAAO,QAAQ,uBAAuB,EACtC,OAAO,MAAM,eAAO,IAAK,EAAY,OAAS,GAAG,CAAC,EAAE,CAAC,EACrD,MACF,CAEA,IAAM,OAAS,aAAa,EAGtB,WAAa,MAAM,OAAO,aAAa,EAE7C,GAAI,CAEF,MAAM,OAAO,UAAU,UAAU,IACjC,MAAM,OAAO,MAAMA,QAAO,KAAK,CACjC,OAAS,EAAG,CACV,OAAO,MAAM,uCAAwC,CAAC,CACxD,CACF,CAnDsB","names":["config","config","config"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{initializeDevelopmentEnvironment}from"../../chunk-SB3FAFCD.mjs";import"../../chunk-QC2F7O3S.mjs";import"../../chunk-UV2LVAQV.mjs";import"../../chunk-BJCWVCAY.mjs";import"../../chunk-FQGSVSCT.mjs";import"../../chunk-DEB7FLUS.mjs";import"../../chunk-QYJ4DE3N.mjs";import"../../chunk-ZJRAI4W5.mjs";import"../../chunk-7KD7ZCH6.mjs";export{initializeDevelopmentEnvironment};
|
|
2
|
+
//# sourceMappingURL=development.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var bundle_exports={};__export(bundle_exports,{bundle:()=>bundle});module.exports=__toCommonJS(bundle_exports);var import_tsup=require("tsup");var globalConfig={envExtra:!0,outDir:"dist",watch:!0,clearRestartLogs:!0,minify:!1,sourcemap:!1,nodeOptions:[],antiCrash:!0,requirePolyfill:!0,token:process.env.DISCORD_TOKEN};function getConfig(){return globalConfig}__name(getConfig,"getConfig");var import_path=require("path");function bundle(mode){switch(mode){case"development":return buildDevelopment();default:throw new Error("Not implemented")}}__name(bundle,"bundle");function buildDevelopment(){let{watch}=getConfig(),outDir=(0,import_path.join)(process.cwd(),".commandkit");return(0,import_tsup.build)({clean:!0,format:["esm"],bundle:!1,dts:!1,skipNodeModulesBundle:!0,minify:!1,shims:!0,sourcemap:"inline",keepNames:!0,outDir:".commandkit",silent:!0,entry:["src"],watch,async onSuccess(){}}).then(()=>(0,import_path.join)(outDir,"client.mjs"))}__name(buildDevelopment,"buildDevelopment");0&&(module.exports={bundle});
|
|
2
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/environment/bundler/bundle.ts","../../../src/config.ts"],"sourcesContent":["import { build } from 'tsup';\nimport { getConfig } from '../../config';\nimport { join } from 'path';\n\nexport function bundle(mode: 'development' | 'production') {\n switch (mode) {\n case 'development':\n return buildDevelopment();\n default:\n throw new Error('Not implemented');\n }\n}\n\nfunction buildDevelopment() {\n const { watch } = getConfig();\n\n const outDir = join(process.cwd(), '.commandkit');\n\n return build({\n clean: true,\n format: ['esm'],\n bundle: false,\n dts: false,\n skipNodeModulesBundle: true,\n minify: false,\n shims: true,\n sourcemap: 'inline',\n keepNames: true,\n outDir: '.commandkit',\n silent: true,\n entry: ['src'],\n watch,\n async onSuccess() {\n // return await injectShims('.commandkit', main, false, requirePolyfill);\n },\n }).then(() => {\n return join(outDir, 'client.mjs');\n });\n}\n","import type { ClientOptions } from 'discord.js';\n\nexport interface CommandKitConfig {\n /**\n * The Discord client options.\n */\n clientOptions: ClientOptions;\n /**\n * The Discord bot token. Defaults to `process.env.DISCORD_TOKEN`.\n */\n token?: string;\n /**\n * Whether or not to use the watch mode. Defaults to `true`.\n */\n watch: boolean;\n /**\n * The output directory of the project. Defaults to `dist`.\n */\n outDir: string;\n /**\n * Whether or not to include extra env utilities. Defaults to `true`.\n */\n envExtra: boolean;\n /**\n * Node.js cli options.\n */\n nodeOptions: string[];\n /**\n * Whether or not to clear default restart logs. Defaults to `true`.\n */\n clearRestartLogs: boolean;\n /**\n * Whether or not to minify the output. Defaults to `false`.\n */\n minify: boolean;\n /**\n * Whether or not to include sourcemaps in production build. Defaults to `false`.\n */\n sourcemap: boolean | 'inline';\n /**\n * Whether or not to include anti-crash handler in production. Defaults to `true`.\n */\n antiCrash: boolean;\n /**\n * Whether or not to polyfill `require` function. Defaults to `true`.\n */\n requirePolyfill: boolean;\n}\n\nlet globalConfig: Partial<CommandKitConfig> = {\n envExtra: true,\n outDir: 'dist',\n watch: true,\n clearRestartLogs: true,\n minify: false,\n sourcemap: false,\n nodeOptions: [],\n antiCrash: true,\n requirePolyfill: true,\n token: process.env.DISCORD_TOKEN,\n};\n\nexport function getConfig(): CommandKitConfig {\n return globalConfig as CommandKitConfig;\n}\n\nconst requiredProps = ['clientOptions'] as const;\n\ntype R = (typeof requiredProps)[number];\n\ntype PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> &\n Pick<T, R>;\n\nexport function defineConfig(config: PartialConfig<CommandKitConfig>) {\n for (const prop of requiredProps) {\n if (!config[prop]) {\n throw new Error(\n `[CommandKit Config] Missing required config property: ${prop}`,\n );\n }\n }\n\n globalConfig = {\n ...globalConfig,\n ...config,\n };\n\n return globalConfig;\n}\n"],"mappings":"ouBAAA,+GAAA,gBAAsB,gBCiDtB,IAAI,aAA0C,CAC5C,SAAU,GACV,OAAQ,OACR,MAAO,GACP,iBAAkB,GAClB,OAAQ,GACR,UAAW,GACX,YAAa,CAAC,EACd,UAAW,GACX,gBAAiB,GACjB,MAAO,QAAQ,IAAI,aACrB,EAEO,SAAS,WAA8B,CAC5C,OAAO,YACT,CAFgB,8BD5DhB,gBAAqB,gBAEd,SAAS,OAAO,KAAoC,CACzD,OAAQ,KAAM,CACZ,IAAK,cACH,OAAO,iBAAiB,EAC1B,QACE,MAAM,IAAI,MAAM,iBAAiB,CACrC,CACF,CAPgB,wBAShB,SAAS,kBAAmB,CAC1B,GAAM,CAAE,KAAM,EAAI,UAAU,EAEtB,UAAS,kBAAK,QAAQ,IAAI,EAAG,aAAa,EAEhD,SAAO,mBAAM,CACX,MAAO,GACP,OAAQ,CAAC,KAAK,EACd,OAAQ,GACR,IAAK,GACL,sBAAuB,GACvB,OAAQ,GACR,MAAO,GACP,UAAW,SACX,UAAW,GACX,OAAQ,cACR,OAAQ,GACR,MAAO,CAAC,KAAK,EACb,MACA,MAAM,WAAY,CAElB,CACF,CAAC,EAAE,KAAK,OACC,kBAAK,OAAQ,YAAY,CACjC,CACH,CAzBS","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var shims_exports={};__export(shims_exports,{injectShims:()=>injectShims});module.exports=__toCommonJS(shims_exports);var import_promises=require("fs/promises"),import_node_path=require("path");async function injectShims(outDir,main,antiCrash,polyfillRequire){let path=(0,import_node_path.join)(process.cwd(),outDir,main),head=[`
|
|
2
|
+
|
|
3
|
+
;await (async()=>{`," 'use strict';"].join(`
|
|
4
|
+
`),tail=`
|
|
5
|
+
})();`,requireScript=polyfillRequire?["// --- CommandKit require() polyfill ---",' if (typeof require === "undefined") {',' const { createRequire } = await import("node:module");'," const __require = createRequire(import.meta.url);",' Object.defineProperty(globalThis, "require", {'," value: (id) => {"," return __require(id);"," },"," configurable: true,"," enumerable: false,"," writable: true,"," });"," }","// --- CommandKit require() polyfill ---"].join(`
|
|
6
|
+
`):"",antiCrashScript=antiCrash?["// --- CommandKit Anti-Crash Monitor ---"," // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process"," // instead of using it as a means to resume operation."," // But it exists here due to compatibility reasons with discord bot ecosystem."," const p = (t) => `\\x1b[33m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';"," if (!process.eventNames().includes(e1)) // skip if it is already handled"," process.on(e1, (e) => {"," l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));"," })"," if (!process.eventNames().includes(e2)) // skip if it is already handled"," process.on(e2, (r) => {"," l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));"," });","// --- CommandKit Anti-Crash Monitor ---"].join(`
|
|
7
|
+
`):"",contents=await(0,import_promises.readFile)(path,"utf-8"),finalScript=[head,requireScript,antiCrashScript,tail,`
|
|
8
|
+
|
|
9
|
+
`,contents].join(`
|
|
10
|
+
`);return(0,import_promises.writeFile)(path,finalScript)}__name(injectShims,"injectShims");0&&(module.exports={injectShims});
|
|
11
|
+
//# sourceMappingURL=shims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/environment/bundler/shims.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport async function injectShims(\n outDir: string,\n main: string,\n antiCrash: boolean,\n polyfillRequire: boolean,\n) {\n const path = join(process.cwd(), outDir, main);\n\n const head = ['\\n\\n;await (async()=>{', \" 'use strict';\"].join('\\n');\n const tail = '\\n})();';\n const requireScript = polyfillRequire\n ? [\n '// --- CommandKit require() polyfill ---',\n ' if (typeof require === \"undefined\") {',\n ' const { createRequire } = await import(\"node:module\");',\n ' const __require = createRequire(import.meta.url);',\n ' Object.defineProperty(globalThis, \"require\", {',\n ' value: (id) => {',\n ' return __require(id);',\n ' },',\n ' configurable: true,',\n ' enumerable: false,',\n ' writable: true,',\n ' });',\n ' }',\n '// --- CommandKit require() polyfill ---',\n ].join('\\n')\n : '';\n\n const antiCrashScript = antiCrash\n ? [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[33m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n ].join('\\n')\n : '';\n\n const contents = await readFile(path, 'utf-8');\n const finalScript = [\n head,\n requireScript,\n antiCrashScript,\n tail,\n '\\n\\n',\n contents,\n ].join('\\n');\n\n return writeFile(path, finalScript);\n}\n"],"mappings":"ouBAAA,sHAAA,oBAAoC,uBACpC,iBAAqB,gBAErB,eAAsB,YACpB,OACA,KACA,UACA,gBACA,CACA,IAAM,QAAO,uBAAK,QAAQ,IAAI,EAAG,OAAQ,IAAI,EAEvC,KAAO,CAAC;AAAA;AAAA,oBAA0B,iBAAiB,EAAE,KAAK;AAAA,CAAI,EAC9D,KAAO;AAAA,OACP,cAAgB,gBAClB,CACE,2CACA,0CACA,6DACA,wDACA,qDACA,yBACA,gCACA,WACA,4BACA,2BACA,wBACA,UACA,MACA,0CACF,EAAE,KAAK;AAAA,CAAI,EACX,GAEE,gBAAkB,UACpB,CACE,2CACA,wHACA,2DACA,mFACA,2JACA,6EACA,8BACA,mEACA,SACA,6EACA,8BACA,gFACA,UACA,0CACF,EAAE,KAAK;AAAA,CAAI,EACX,GAEE,SAAW,QAAM,0BAAS,KAAM,OAAO,EACvC,YAAc,CAClB,KACA,cACA,gBACA,KACA;AAAA;AAAA,EACA,QACF,EAAE,KAAK;AAAA,CAAI,EAEX,SAAO,2BAAU,KAAM,WAAW,CACpC,CA3DsB","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{__name}from"../../chunk-7KD7ZCH6.mjs";import{readFile,writeFile}from"node:fs/promises";import{join}from"node:path";async function injectShims(outDir,main,antiCrash,polyfillRequire){let path=join(process.cwd(),outDir,main),head=[`
|
|
2
|
+
|
|
3
|
+
;await (async()=>{`," 'use strict';"].join(`
|
|
4
|
+
`),tail=`
|
|
5
|
+
})();`,requireScript=polyfillRequire?["// --- CommandKit require() polyfill ---",' if (typeof require === "undefined") {',' const { createRequire } = await import("node:module");'," const __require = createRequire(import.meta.url);",' Object.defineProperty(globalThis, "require", {'," value: (id) => {"," return __require(id);"," },"," configurable: true,"," enumerable: false,"," writable: true,"," });"," }","// --- CommandKit require() polyfill ---"].join(`
|
|
6
|
+
`):"",antiCrashScript=antiCrash?["// --- CommandKit Anti-Crash Monitor ---"," // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process"," // instead of using it as a means to resume operation."," // But it exists here due to compatibility reasons with discord bot ecosystem."," const p = (t) => `\\x1b[33m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';"," if (!process.eventNames().includes(e1)) // skip if it is already handled"," process.on(e1, (e) => {"," l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));"," })"," if (!process.eventNames().includes(e2)) // skip if it is already handled"," process.on(e2, (r) => {"," l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));"," });","// --- CommandKit Anti-Crash Monitor ---"].join(`
|
|
7
|
+
`):"",contents=await readFile(path,"utf-8"),finalScript=[head,requireScript,antiCrashScript,tail,`
|
|
8
|
+
|
|
9
|
+
`,contents].join(`
|
|
10
|
+
`);return writeFile(path,finalScript)}__name(injectShims,"injectShims");export{injectShims};
|
|
11
|
+
//# sourceMappingURL=shims.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/environment/bundler/shims.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport async function injectShims(\n outDir: string,\n main: string,\n antiCrash: boolean,\n polyfillRequire: boolean,\n) {\n const path = join(process.cwd(), outDir, main);\n\n const head = ['\\n\\n;await (async()=>{', \" 'use strict';\"].join('\\n');\n const tail = '\\n})();';\n const requireScript = polyfillRequire\n ? [\n '// --- CommandKit require() polyfill ---',\n ' if (typeof require === \"undefined\") {',\n ' const { createRequire } = await import(\"node:module\");',\n ' const __require = createRequire(import.meta.url);',\n ' Object.defineProperty(globalThis, \"require\", {',\n ' value: (id) => {',\n ' return __require(id);',\n ' },',\n ' configurable: true,',\n ' enumerable: false,',\n ' writable: true,',\n ' });',\n ' }',\n '// --- CommandKit require() polyfill ---',\n ].join('\\n')\n : '';\n\n const antiCrashScript = antiCrash\n ? [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[33m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n ].join('\\n')\n : '';\n\n const contents = await readFile(path, 'utf-8');\n const finalScript = [\n head,\n requireScript,\n antiCrashScript,\n tail,\n '\\n\\n',\n contents,\n ].join('\\n');\n\n return writeFile(path, finalScript);\n}\n"],"mappings":"6CAAA,OAAS,SAAU,cAAiB,mBACpC,OAAS,SAAY,YAErB,eAAsB,YACpB,OACA,KACA,UACA,gBACA,CACA,IAAM,KAAO,KAAK,QAAQ,IAAI,EAAG,OAAQ,IAAI,EAEvC,KAAO,CAAC;AAAA;AAAA,oBAA0B,iBAAiB,EAAE,KAAK;AAAA,CAAI,EAC9D,KAAO;AAAA,OACP,cAAgB,gBAClB,CACE,2CACA,0CACA,6DACA,wDACA,qDACA,yBACA,gCACA,WACA,4BACA,2BACA,wBACA,UACA,MACA,0CACF,EAAE,KAAK;AAAA,CAAI,EACX,GAEE,gBAAkB,UACpB,CACE,2CACA,wHACA,2DACA,mFACA,2JACA,6EACA,8BACA,mEACA,SACA,6EACA,8BACA,gFACA,UACA,0CACF,EAAE,KAAK;AAAA,CAAI,EACX,GAEE,SAAW,MAAM,SAAS,KAAM,OAAO,EACvC,YAAc,CAClB,KACA,cACA,gBACA,KACA;AAAA;AAAA,EACA,QACF,EAAE,KAAK;AAAA,CAAI,EAEX,OAAO,UAAU,KAAM,WAAW,CACpC,CA3DsB","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));var import_yargs=__toESM(require("yargs/yargs")),import_helpers=require("yargs/helpers");var import_node_fs=require("fs"),import_node_path=require("path");var ConfigLookupPaths=["js","cjs","mjs"];async function findConfigPath(relative){for(let extension of ConfigLookupPaths){let path=(0,import_node_path.join)(relative,`commandkit.${extension}`);if((0,import_node_fs.existsSync)(path))return path}return null}__name(findConfigPath,"findConfigPath");async function importConfig(path){let config2=await import(`file://${path}`);return config2?.default??config2}__name(importConfig,"importConfig");var resetColor="\x1B[0m",colors_default={reset:text=>`${text}${resetColor}`,bright:text=>`\x1B[1m${text}${resetColor}`,dim:text=>`\x1B[2m${text}${resetColor}`,underscore:text=>`\x1B[4m${text}${resetColor}`,blink:text=>`\x1B[5m${text}${resetColor}`,reverse:text=>`\x1B[7m${text}${resetColor}`,hidden:text=>`\x1B[8m${text}${resetColor}`,black:text=>`\x1B[30m${text}${resetColor}`,red:text=>`\x1B[31m${text}${resetColor}`,green:text=>`\x1B[32m${text}${resetColor}`,yellow:text=>`\x1B[33m${text}${resetColor}`,blue:text=>`\x1B[34m${text}${resetColor}`,magenta:text=>`\x1B[35m${text}${resetColor}`,cyan:text=>`\x1B[36m${text}${resetColor}`,white:text=>`\x1B[37m${text}${resetColor}`,bgBlack:text=>`\x1B[40m${text}${resetColor}`,bgRed:text=>`\x1B[41m${text}${resetColor}`,bgGreen:text=>`\x1B[42m${text}${resetColor}`,bgYellow:text=>`\x1B[43m${text}${resetColor}`,bgBlue:text=>`\x1B[44m${text}${resetColor}`,bgMagenta:text=>`\x1B[45m${text}${resetColor}`,bgCyan:text=>`\x1B[46m${text}${resetColor}`,bgWhite:text=>`\x1B[47m${text}${resetColor}`};var Logger={Fatal:(...message)=>{console.log(colors_default.red("[FATAL ERROR]"),...message),process.exit(1)},Warning:(...message)=>{console.log(colors_default.yellow("[WARNING]"),...message)},Info:(...message)=>{console.log(colors_default.green("[INFO]"),...message)},Debug:(...message)=>{console.log(colors_default.blue("[DEBUG]"),...message)},Log:(...message)=>{console.log(...message)}};var import_dotenv_cra=require("dotenv-cra");function loadEnv(type){return process.env.NODE_ENV=type,(0,import_dotenv_cra.config)().error?.message}__name(loadEnv,"loadEnv");var import_discord=require("discord.js");var globalConfig={envExtra:!0,outDir:"dist",watch:!0,clearRestartLogs:!0,minify:!1,sourcemap:!1,nodeOptions:[],antiCrash:!0,requirePolyfill:!0,token:process.env.DISCORD_TOKEN};function getConfig(){return globalConfig}__name(getConfig,"getConfig");var discord_client;function getClient(){return discord_client}__name(getClient,"getClient");function createClient(){let config2=getConfig();return discord_client=new import_discord.Client(config2.clientOptions),discord_client}__name(createClient,"createClient");var import_tsup=require("tsup");var import_path=require("path");function bundle(mode){switch(mode){case"development":return buildDevelopment();default:throw new Error("Not implemented")}}__name(bundle,"bundle");function buildDevelopment(){let{watch}=getConfig(),outDir=(0,import_path.join)(process.cwd(),".commandkit");return(0,import_tsup.build)({clean:!0,format:["esm"],bundle:!1,dts:!1,skipNodeModulesBundle:!0,minify:!1,shims:!0,sourcemap:"inline",keepNames:!0,outDir:".commandkit",silent:!0,entry:["src"],watch,async onSuccess(){}}).then(()=>(0,import_path.join)(outDir,"client.mjs"))}__name(buildDevelopment,"buildDevelopment");var commandkitVersion="0.1.11-dev.20240203230231";function printBanner(){let banner=colors_default.magenta(`\u25C6 CommandKit ${commandkitVersion}`);Logger.Log(banner),Logger.Info("Initializing the development environment...")}__name(printBanner,"printBanner");async function initializeDevelopmentEnvironment(args){if(printBanner(),getClient()){Logger.Fatal("The development environment is already initialized.");return}let envErr=loadEnv("development");envErr?Logger.Warning("Failed to load .env",envErr):Logger.Debug("Loaded .env");let configPath=await findConfigPath(args.config??process.cwd());if(!configPath){let msg=`Could not locate the commandkit config file${args.config?" at "+args.config:" in the current working directory"}.`;Logger.Fatal(msg);return}try{var config2=await importConfig(configPath);Logger.Debug("Loaded config from",colors_default.yellow(configPath))}catch(e){Logger.Warning("Failed to load config"),Logger.Fatal(colors_default.red(e.stack??`${e}`));return}let client=createClient(),entrypoint=await bundle("development");try{await import(`file://${entrypoint}`),await client.login(config2.token)}catch(e){Logger.Fatal("Failed to load the client entrypoint",e)}}__name(initializeDevelopmentEnvironment,"initializeDevelopmentEnvironment");(0,import_yargs.default)((0,import_helpers.hideBin)(process.argv)).scriptName("commandkit").command("dev","Start the bot in development mode",()=>{},async args=>{await initializeDevelopmentEnvironment(args)}).command("start","Start the production build").command("build","Generate production build of the project").options({config:{alias:"c",type:"string",description:"Path to the commandkit config file"},nodeOptions:{alias:"n",type:"string",description:"Node options to pass to the process"}}).version("0.1.11-dev.20240203230231").help().demandCommand().parse();
|
|
2
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/environment/cli.ts","../../src/environment/common/config.ts","../../src/utils/colors.ts","../../src/environment/common/logger.ts","../../src/bootstrap/loadEnv.ts","../../src/bootstrap/client.ts","../../src/config.ts","../../src/environment/bundler/bundle.ts","../../src/environment/actions/development.ts"],"sourcesContent":["import yargs from 'yargs/yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { initializeDevelopmentEnvironment } from './actions/development';\n\nyargs(hideBin(process.argv))\n .scriptName('commandkit')\n .command(\n 'dev',\n 'Start the bot in development mode',\n () => {},\n async (args) => {\n await initializeDevelopmentEnvironment(args);\n },\n )\n .command('start', 'Start the production build')\n .command('build', 'Generate production build of the project')\n .options({\n config: {\n alias: 'c',\n type: 'string',\n description: 'Path to the commandkit config file',\n },\n nodeOptions: {\n alias: 'n',\n type: 'string',\n description: 'Node options to pass to the process',\n },\n })\n .version('0.1.11-dev.20240203230231')\n .help()\n .demandCommand()\n .parse();\n","import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { CommandKitConfig } from '../../config';\n\nconst ConfigLookupPaths = [\n // javascript\n 'js',\n 'cjs',\n 'mjs',\n];\n\nexport async function findConfigPath(relative: string) {\n for (const extension of ConfigLookupPaths) {\n const path = join(relative, `commandkit.${extension}`);\n if (existsSync(path)) return path;\n }\n\n return null;\n}\n\nexport async function importConfig(path: string): Promise<CommandKitConfig> {\n const config = await import(`file://${path}`);\n return config?.default ?? config;\n}\n","const resetColor = '\\x1b[0m';\n\nexport default {\n reset: (text: string) => `${text}${resetColor}`,\n bright: (text: string) => `\\x1b[1m${text}${resetColor}`,\n dim: (text: string) => `\\x1b[2m${text}${resetColor}`,\n underscore: (text: string) => `\\x1b[4m${text}${resetColor}`,\n blink: (text: string) => `\\x1b[5m${text}${resetColor}`,\n reverse: (text: string) => `\\x1b[7m${text}${resetColor}`,\n hidden: (text: string) => `\\x1b[8m${text}${resetColor}`,\n\n black: (text: string) => `\\x1b[30m${text}${resetColor}`,\n red: (text: string) => `\\x1b[31m${text}${resetColor}`,\n green: (text: string) => `\\x1b[32m${text}${resetColor}`,\n yellow: (text: string) => `\\x1b[33m${text}${resetColor}`,\n blue: (text: string) => `\\x1b[34m${text}${resetColor}`,\n magenta: (text: string) => `\\x1b[35m${text}${resetColor}`,\n cyan: (text: string) => `\\x1b[36m${text}${resetColor}`,\n white: (text: string) => `\\x1b[37m${text}${resetColor}`,\n\n bgBlack: (text: string) => `\\x1b[40m${text}${resetColor}`,\n bgRed: (text: string) => `\\x1b[41m${text}${resetColor}`,\n bgGreen: (text: string) => `\\x1b[42m${text}${resetColor}`,\n bgYellow: (text: string) => `\\x1b[43m${text}${resetColor}`,\n bgBlue: (text: string) => `\\x1b[44m${text}${resetColor}`,\n bgMagenta: (text: string) => `\\x1b[45m${text}${resetColor}`,\n bgCyan: (text: string) => `\\x1b[46m${text}${resetColor}`,\n bgWhite: (text: string) => `\\x1b[47m${text}${resetColor}`,\n};\n","import colors from '../../utils/colors';\n\nexport const Logger = {\n Fatal: (...message: unknown[]) => {\n console.log(colors.red('[FATAL ERROR]'), ...message);\n process.exit(1);\n },\n Warning: (...message: unknown[]) => {\n console.log(colors.yellow('[WARNING]'), ...message);\n },\n Info: (...message: unknown[]) => {\n console.log(colors.green('[INFO]'), ...message);\n },\n Debug: (...message: unknown[]) => {\n console.log(colors.blue('[DEBUG]'), ...message);\n },\n Log: (...message: unknown[]) => {\n console.log(...message);\n },\n};\n","import { config } from 'dotenv-cra';\n\nexport function loadEnv(type: 'development' | 'production') {\n process.env.NODE_ENV = type;\n\n const result = config();\n\n return result.error?.message;\n}\n","import { Client } from 'discord.js';\nimport { getConfig } from '../config';\n\nlet discord_client: Client;\n\n/**\n * @internal\n */\nexport function getClient() {\n return discord_client;\n}\n\n/**\n * Fetches the client instance. If the client instance is not initialized, an error will be thrown.\n */\nexport function client<T extends boolean = boolean>() {\n if (!discord_client) {\n throw new Error(\n 'Client was not initialized. Make sure to run \"commandkit dev\" to bootstrap the client.',\n );\n }\n\n return discord_client as Client<T>;\n}\n\nexport function createClient() {\n const config = getConfig();\n\n discord_client = new Client(config.clientOptions);\n\n return discord_client;\n}\n","import type { ClientOptions } from 'discord.js';\n\nexport interface CommandKitConfig {\n /**\n * The Discord client options.\n */\n clientOptions: ClientOptions;\n /**\n * The Discord bot token. Defaults to `process.env.DISCORD_TOKEN`.\n */\n token?: string;\n /**\n * Whether or not to use the watch mode. Defaults to `true`.\n */\n watch: boolean;\n /**\n * The output directory of the project. Defaults to `dist`.\n */\n outDir: string;\n /**\n * Whether or not to include extra env utilities. Defaults to `true`.\n */\n envExtra: boolean;\n /**\n * Node.js cli options.\n */\n nodeOptions: string[];\n /**\n * Whether or not to clear default restart logs. Defaults to `true`.\n */\n clearRestartLogs: boolean;\n /**\n * Whether or not to minify the output. Defaults to `false`.\n */\n minify: boolean;\n /**\n * Whether or not to include sourcemaps in production build. Defaults to `false`.\n */\n sourcemap: boolean | 'inline';\n /**\n * Whether or not to include anti-crash handler in production. Defaults to `true`.\n */\n antiCrash: boolean;\n /**\n * Whether or not to polyfill `require` function. Defaults to `true`.\n */\n requirePolyfill: boolean;\n}\n\nlet globalConfig: Partial<CommandKitConfig> = {\n envExtra: true,\n outDir: 'dist',\n watch: true,\n clearRestartLogs: true,\n minify: false,\n sourcemap: false,\n nodeOptions: [],\n antiCrash: true,\n requirePolyfill: true,\n token: process.env.DISCORD_TOKEN,\n};\n\nexport function getConfig(): CommandKitConfig {\n return globalConfig as CommandKitConfig;\n}\n\nconst requiredProps = ['clientOptions'] as const;\n\ntype R = (typeof requiredProps)[number];\n\ntype PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> &\n Pick<T, R>;\n\nexport function defineConfig(config: PartialConfig<CommandKitConfig>) {\n for (const prop of requiredProps) {\n if (!config[prop]) {\n throw new Error(\n `[CommandKit Config] Missing required config property: ${prop}`,\n );\n }\n }\n\n globalConfig = {\n ...globalConfig,\n ...config,\n };\n\n return globalConfig;\n}\n","import { build } from 'tsup';\nimport { getConfig } from '../../config';\nimport { join } from 'path';\n\nexport function bundle(mode: 'development' | 'production') {\n switch (mode) {\n case 'development':\n return buildDevelopment();\n default:\n throw new Error('Not implemented');\n }\n}\n\nfunction buildDevelopment() {\n const { watch } = getConfig();\n\n const outDir = join(process.cwd(), '.commandkit');\n\n return build({\n clean: true,\n format: ['esm'],\n bundle: false,\n dts: false,\n skipNodeModulesBundle: true,\n minify: false,\n shims: true,\n sourcemap: 'inline',\n keepNames: true,\n outDir: '.commandkit',\n silent: true,\n entry: ['src'],\n watch,\n async onSuccess() {\n // return await injectShims('.commandkit', main, false, requirePolyfill);\n },\n }).then(() => {\n return join(outDir, 'client.mjs');\n });\n}\n","import type yargs from 'yargs';\nimport { findConfigPath, importConfig } from '../common/config';\nimport colors from '../../utils/colors';\nimport { Logger } from '../common/logger';\nimport { loadEnv } from '../../bootstrap/loadEnv';\nimport { createClient, getClient } from '../../bootstrap/client';\nimport { bundle } from '../bundler/bundle';\n\nconst commandkitVersion = '0.1.11-dev.20240203230231';\n\nfunction printBanner() {\n const banner = colors.magenta(\n `${String.fromCharCode(9670)} CommandKit ${commandkitVersion}`,\n );\n Logger.Log(banner);\n Logger.Info('Initializing the development environment...');\n}\n\nexport async function initializeDevelopmentEnvironment(\n args: yargs.ArgumentsCamelCase<{\n config?: string | undefined;\n nodeOptions?: string | undefined;\n }>,\n) {\n printBanner();\n\n if (getClient()) {\n Logger.Fatal('The development environment is already initialized.');\n return;\n }\n\n const envErr = loadEnv('development');\n\n if (envErr) {\n Logger.Warning('Failed to load .env', envErr);\n } else {\n Logger.Debug('Loaded .env');\n }\n\n const configPath = await findConfigPath(args.config ?? process.cwd());\n if (!configPath) {\n const msg = `Could not locate the commandkit config file${\n args.config ? ' at ' + args.config : ' in the current working directory'\n }.`;\n Logger.Fatal(msg);\n return;\n }\n\n try {\n var config = await importConfig(configPath);\n Logger.Debug('Loaded config from', colors.yellow(configPath));\n } catch (e) {\n Logger.Warning('Failed to load config');\n Logger.Fatal(colors.red((e as Error).stack ?? `${e}`));\n return;\n }\n\n const client = createClient();\n\n // build the project\n const entrypoint = await bundle('development');\n\n try {\n // load the client entrypoint\n await import(`file://${entrypoint}`);\n await client.login(config.token);\n } catch (e) {\n Logger.Fatal('Failed to load the client entrypoint', e);\n }\n}\n"],"mappings":"0zBAAA,iBAAkB,gCAClB,eAAwB,yBCDxB,mBA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a,MAAM,OAAO,aAAa,EAE7C,GAAI,CAEF,MAAM,OAAO,UAAU,UAAU,IACjC,MAAM,OAAO,MAAMA,QAAO,KAAK,CACjC,OAAS,EAAG,CACV,OAAO,MAAM,uCAAwC,CAAC,CACxD,CACF,CAnDsB,+ERdtB,aAAAC,YAAM,wBAAQ,QAAQ,IAAI,CAAC,EACxB,WAAW,YAAY,EACvB,QACC,MACA,oCACA,IAAM,CAAC,EACP,MAAO,MAAS,CACd,MAAM,iCAAiC,IAAI,CAC7C,CACF,EACC,QAAQ,QAAS,4BAA4B,EAC7C,QAAQ,QAAS,0CAA0C,EAC3D,QAAQ,CACP,OAAQ,CACN,MAAO,IACP,KAAM,SACN,YAAa,oCACf,EACA,YAAa,CACX,MAAO,IACP,KAAM,SACN,YAAa,qCACf,CACF,CAAC,EACA,QAAQ,2BAA2B,EACnC,KAAK,EACL,cAAc,EACd,MAAM","names":["config","config","config","yargs"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{initializeDevelopmentEnvironment}from"../chunk-SB3FAFCD.mjs";import"../chunk-QC2F7O3S.mjs";import"../chunk-UV2LVAQV.mjs";import"../chunk-BJCWVCAY.mjs";import"../chunk-FQGSVSCT.mjs";import"../chunk-DEB7FLUS.mjs";import"../chunk-QYJ4DE3N.mjs";import"../chunk-ZJRAI4W5.mjs";import"../chunk-7KD7ZCH6.mjs";import yargs from"yargs/yargs";import{hideBin}from"yargs/helpers";yargs(hideBin(process.argv)).scriptName("commandkit").command("dev","Start the bot in development mode",()=>{},async args=>{await initializeDevelopmentEnvironment(args)}).command("start","Start the production build").command("build","Generate production build of the project").options({config:{alias:"c",type:"string",description:"Path to the commandkit config file"},nodeOptions:{alias:"n",type:"string",description:"Node options to pass to the process"}}).version("0.1.11-dev.20240203230231").help().demandCommand().parse();
|
|
2
|
+
//# sourceMappingURL=cli.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/environment/cli.ts"],"sourcesContent":["import yargs from 'yargs/yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { initializeDevelopmentEnvironment } from './actions/development';\n\nyargs(hideBin(process.argv))\n .scriptName('commandkit')\n .command(\n 'dev',\n 'Start the bot in development mode',\n () => {},\n async (args) => {\n await initializeDevelopmentEnvironment(args);\n },\n )\n .command('start', 'Start the production build')\n .command('build', 'Generate production build of the project')\n .options({\n config: {\n alias: 'c',\n type: 'string',\n description: 'Path to the commandkit config file',\n },\n nodeOptions: {\n alias: 'n',\n type: 'string',\n description: 'Node options to pass to the process',\n },\n })\n .version('0.1.11-dev.20240203230231')\n .help()\n .demandCommand()\n .parse();\n"],"mappings":"oTAAA,OAAO,UAAW,cAClB,OAAS,YAAe,gBAGxB,MAAM,QAAQ,QAAQ,IAAI,CAAC,EACxB,WAAW,YAAY,EACvB,QACC,MACA,oCACA,IAAM,CAAC,EACP,MAAO,MAAS,CACd,MAAM,iCAAiC,IAAI,CAC7C,CACF,EACC,QAAQ,QAAS,4BAA4B,EAC7C,QAAQ,QAAS,0CAA0C,EAC3D,QAAQ,CACP,OAAQ,CACN,MAAO,IACP,KAAM,SACN,YAAa,oCACf,EACA,YAAa,CACX,MAAO,IACP,KAAM,SACN,YAAa,qCACf,CACF,CAAC,EACA,QAAQ,2BAA2B,EACnC,KAAK,EACL,cAAc,EACd,MAAM","names":[]}
|