commandkit 0.1.6-dev.20231006183935 → 0.1.6-dev.20231112142249

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/bin/build.mjs ADDED
@@ -0,0 +1,44 @@
1
+ // @ts-check
2
+
3
+ import { build } from 'tsup';
4
+ import ora from 'ora';
5
+ import { Colors, erase, findCommandKitJSON, panic, write } from './common.mjs';
6
+
7
+ export async function bootstrapProductionBuild(config) {
8
+ const {
9
+ minify = false,
10
+ outDir = 'dist',
11
+ main,
12
+ src,
13
+ } = findCommandKitJSON(config);
14
+
15
+ const status = ora('Creating optimized production build...\n').start();
16
+ const start = performance.now();
17
+
18
+ erase(outDir);
19
+
20
+ try {
21
+ await build({
22
+ clean: true,
23
+ format: ['esm'],
24
+ dts: false,
25
+ skipNodeModulesBundle: true,
26
+ minify,
27
+ shims: true,
28
+ banner: {
29
+ js: '/* Optimized production build of your project, generated by CommandKit */'
30
+ },
31
+ sourcemap: false,
32
+ keepNames: true,
33
+ outDir,
34
+ silent: true,
35
+ entry: [src, '!dist', '!.commandkit'],
36
+ });
37
+
38
+ status.succeed(Colors.green(`Build completed in ${(performance.now() - start).toFixed(2)}ms!`));
39
+ write(Colors.green(`\nRun ${Colors.magenta(`node ${outDir}/${main}`)} ${Colors.green('to start your bot.')}`))
40
+ } catch (e) {
41
+ status.fail(`Build failed after ${(performance.now() - start).toFixed(2)}ms!`)
42
+ panic(e);
43
+ }
44
+ }
package/bin/common.mjs ADDED
@@ -0,0 +1,74 @@
1
+ // @ts-check
2
+
3
+ import { join } from 'node:path'
4
+ import fs from 'node:fs';
5
+ import { rimrafSync } from 'rimraf'
6
+
7
+ const resetColor = '\x1b[0m';
8
+
9
+ export const Colors = {
10
+ reset: (text) => `${text}${resetColor}`,
11
+ bright: (text) => `\x1b[1m${text}${resetColor}`,
12
+ dim: (text) => `\x1b[2m${text}${resetColor}`,
13
+ underscore: (text) => `\x1b[4m${text}${resetColor}`,
14
+ blink: (text) => `\x1b[5m${text}${resetColor}`,
15
+ reverse: (text) => `\x1b[7m${text}${resetColor}`,
16
+ hidden: (text) => `\x1b[8m${text}${resetColor}`,
17
+
18
+ black: (text) => `\x1b[30m${text}${resetColor}`,
19
+ red: (text) => `\x1b[31m${text}${resetColor}`,
20
+ green: (text) => `\x1b[32m${text}${resetColor}`,
21
+ yellow: (text) => `\x1b[33m${text}${resetColor}`,
22
+ blue: (text) => `\x1b[34m${text}${resetColor}`,
23
+ magenta: (text) => `\x1b[35m${text}${resetColor}`,
24
+ cyan: (text) => `\x1b[36m${text}${resetColor}`,
25
+ white: (text) => `\x1b[37m${text}${resetColor}`,
26
+
27
+ bgBlack: (text) => `\x1b[40m${text}${resetColor}`,
28
+ bgRed: (text) => `\x1b[41m${text}${resetColor}`,
29
+ bgGreen: (text) => `\x1b[42m${text}${resetColor}`,
30
+ bgYellow: (text) => `\x1b[43m${text}${resetColor}`,
31
+ bgBlue: (text) => `\x1b[44m${text}${resetColor}`,
32
+ bgMagenta: (text) => `\x1b[45m${text}${resetColor}`,
33
+ bgCyan: (text) => `\x1b[46m${text}${resetColor}`,
34
+ bgWhite: (text) => `\x1b[47m${text}${resetColor}`,
35
+ };
36
+
37
+ export function write(message) {
38
+ process.stdout.write(message);
39
+ process.stdout.write('\n');
40
+ }
41
+
42
+ /**
43
+ * @returns {never}
44
+ */
45
+ export function panic(message) {
46
+ write(Colors.red(`Error: ${message}`));
47
+ process.exit(1);
48
+ }
49
+
50
+ export function findPackageJSON() {
51
+ const cwd = process.cwd();
52
+ const target = join(cwd, 'package.json');
53
+
54
+ if (!fs.existsSync(target)) {
55
+ panic('Could not find package.json in current directory.');
56
+ }
57
+
58
+ return JSON.parse(fs.readFileSync(target, 'utf8'));
59
+ }
60
+
61
+ export function findCommandKitJSON(src) {
62
+ const cwd = process.cwd();
63
+ const target = src || join(cwd, 'commandkit.json');
64
+
65
+ if (!fs.existsSync(target)) {
66
+ panic('Could not find commandkit.json in current directory.');
67
+ }
68
+
69
+ return JSON.parse(fs.readFileSync(target, 'utf8'));
70
+ }
71
+
72
+ export function erase(dir) {
73
+ rimrafSync(dir);
74
+ }
@@ -0,0 +1,89 @@
1
+ // @ts-check
2
+ import { config as dotenv } from 'dotenv'
3
+ import { build } from 'tsup';
4
+ import child_process from 'node:child_process'
5
+ import ora from 'ora';
6
+ import { join } from 'node:path';
7
+ import { Colors, erase, findCommandKitJSON, panic, write } from './common.mjs';
8
+
9
+ export async function bootstrapDevelopmentServer(config) {
10
+ const {
11
+ src,
12
+ main = 'index.mjs',
13
+ nodeOptions = ['--watch']
14
+ } = findCommandKitJSON(config);
15
+
16
+ if (!src) {
17
+ panic('Could not find src in commandkit.json');
18
+ }
19
+
20
+ const status = ora(Colors.green('Starting a development server...\n')).start();
21
+ const start = performance.now();
22
+
23
+ erase('.commandkit');
24
+
25
+ try {
26
+ await build({
27
+ clean: true,
28
+ format: ['esm'],
29
+ dts: false,
30
+ skipNodeModulesBundle: true,
31
+ minify: false,
32
+ shims: true,
33
+ sourcemap: false,
34
+ keepNames: true,
35
+ outDir: '.commandkit',
36
+ silent: true,
37
+ entry: [src, '!dist', '!.commandkit'],
38
+ watch: nodeOptions.includes('--watch'),
39
+ });
40
+
41
+ status.succeed(Colors.green(`Server started in ${(performance.now() - start).toFixed(2)}ms!\n`));
42
+
43
+ const processEnv = {};
44
+
45
+ const env = dotenv({
46
+ path: join(process.cwd(), '.env'),
47
+ // @ts-expect-error
48
+ processEnv
49
+ });
50
+
51
+ if (env.error) {
52
+ write(Colors.yellow(`[DOTENV] Warning: ${env.error.message}`));
53
+ }
54
+
55
+ if (env.parsed) {
56
+ write(Colors.blue('[DOTENV] Loaded .env file!'));
57
+ }
58
+
59
+ const ps = child_process.spawn('node', [...nodeOptions, join(process.cwd(), '.commandkit', main)], {
60
+ env: {
61
+ ...process.env,
62
+ ...processEnv,
63
+ NODE_ENV: 'development',
64
+ COMMANDKIT_DEV: 'true'
65
+ },
66
+ cwd: process.cwd(),
67
+ });
68
+
69
+ ps.stdout.on('data', (data) => {
70
+ write(data.toString());
71
+ });
72
+
73
+ ps.stderr.on('data', (data) => {
74
+ write(Colors.red(data.toString()));
75
+ });
76
+
77
+ ps.on('close', (code) => {
78
+ write('\n');
79
+ process.exit(code ?? 0);
80
+ });
81
+
82
+ ps.on('error', (err) => {
83
+ panic(err);
84
+ });
85
+ } catch (e) {
86
+ status.fail(`Error occurred after ${(performance.now() - start).toFixed(2)}ms!\n`)
87
+ panic(e);
88
+ }
89
+ }
package/bin/index.mjs ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+
3
+ // @ts-check
4
+
5
+ import { Command } from 'commander';
6
+ import { bootstrapDevelopmentServer } from './dev-server.mjs';
7
+ import { bootstrapProductionBuild } from './build.mjs';
8
+
9
+ const program = new Command('commandkit');
10
+
11
+ program.command('dev')
12
+ .description('Start your bot in development mode.')
13
+ .option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.json')
14
+ .action(() => {
15
+ const options = program.opts();
16
+ bootstrapDevelopmentServer(options.config)
17
+ });
18
+
19
+ program.command('build')
20
+ .description('Build your project for production usage.')
21
+ .option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.json')
22
+ .action(() => {
23
+ const options = program.opts();
24
+ bootstrapProductionBuild(options.config)
25
+ });
26
+
27
+ program.parse();
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
1
+ import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
2
2
 
3
3
  interface CommandProps {
4
4
  interaction: CommandInteraction;
@@ -150,4 +150,55 @@ declare class CommandKit {
150
150
  get devRoleIds(): string[];
151
151
  }
152
152
 
153
- export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps };
153
+ type CommandKitButtonBuilderInteractionCollectorDispatch = (interaction: ButtonInteraction) => Awaitable<void>;
154
+ type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {
155
+ /**
156
+ * The message to listen for button interactions on.
157
+ */
158
+ message: Message;
159
+ /**
160
+ * If the collector should automatically reset the timer when a button is clicked.
161
+ */
162
+ autoReset?: boolean;
163
+ } & Omit<InteractionCollectorOptions<ButtonInteraction>, 'filter' | 'componentType'>;
164
+ declare class ButtonKit extends ButtonBuilder {
165
+ #private;
166
+ /**
167
+ * Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
168
+ * If unused, this expires after 24 hours or custom time if specified.
169
+ * @param handler The handler to run when the button is clicked
170
+ * @param data The context data to use for the interaction collector
171
+ * @returns This button
172
+ * @example
173
+ * ```ts
174
+ * const button = new ButtonKit()
175
+ * .setLabel('Click me')
176
+ * .setStyle(ButtonStyle.Primary)
177
+ * .setCustomId('click_me');
178
+ *
179
+ * const message = await channel.send({ content: 'Click the button', components: [new MessageActionRow().addComponents(button)] });
180
+ *
181
+ * button.onClick(async (interaction) => {
182
+ * await interaction.reply('You clicked me!');
183
+ * }, { message });
184
+ *
185
+ * // remove onClick handler and destroy the interaction collector
186
+ * button.onClick(null);
187
+ * ```
188
+ */
189
+ onClick(handler: null): this;
190
+ onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
191
+ }
192
+
193
+ type CommandKitEffectCallback = () => void;
194
+ type CommandKitSignalInitializer<T> = T | (() => T);
195
+ type CommandKitSignalUpdater<T> = T | ((prev: T) => T);
196
+ type CommandKitSignal<T> = readonly [
197
+ () => T,
198
+ (value: CommandKitSignalUpdater<T>) => void,
199
+ () => void
200
+ ];
201
+ declare function createSignal<T = unknown>(value?: CommandKitSignalInitializer<T>): CommandKitSignal<T>;
202
+ declare function createEffect(callback: CommandKitEffectCallback): void;
203
+
204
+ export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
1
+ import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
2
2
 
3
3
  interface CommandProps {
4
4
  interaction: CommandInteraction;
@@ -150,4 +150,55 @@ declare class CommandKit {
150
150
  get devRoleIds(): string[];
151
151
  }
152
152
 
153
- export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps };
153
+ type CommandKitButtonBuilderInteractionCollectorDispatch = (interaction: ButtonInteraction) => Awaitable<void>;
154
+ type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {
155
+ /**
156
+ * The message to listen for button interactions on.
157
+ */
158
+ message: Message;
159
+ /**
160
+ * If the collector should automatically reset the timer when a button is clicked.
161
+ */
162
+ autoReset?: boolean;
163
+ } & Omit<InteractionCollectorOptions<ButtonInteraction>, 'filter' | 'componentType'>;
164
+ declare class ButtonKit extends ButtonBuilder {
165
+ #private;
166
+ /**
167
+ * Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
168
+ * If unused, this expires after 24 hours or custom time if specified.
169
+ * @param handler The handler to run when the button is clicked
170
+ * @param data The context data to use for the interaction collector
171
+ * @returns This button
172
+ * @example
173
+ * ```ts
174
+ * const button = new ButtonKit()
175
+ * .setLabel('Click me')
176
+ * .setStyle(ButtonStyle.Primary)
177
+ * .setCustomId('click_me');
178
+ *
179
+ * const message = await channel.send({ content: 'Click the button', components: [new MessageActionRow().addComponents(button)] });
180
+ *
181
+ * button.onClick(async (interaction) => {
182
+ * await interaction.reply('You clicked me!');
183
+ * }, { message });
184
+ *
185
+ * // remove onClick handler and destroy the interaction collector
186
+ * button.onClick(null);
187
+ * ```
188
+ */
189
+ onClick(handler: null): this;
190
+ onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
191
+ }
192
+
193
+ type CommandKitEffectCallback = () => void;
194
+ type CommandKitSignalInitializer<T> = T | (() => T);
195
+ type CommandKitSignalUpdater<T> = T | ((prev: T) => T);
196
+ type CommandKitSignal<T> = readonly [
197
+ () => T,
198
+ (value: CommandKitSignalUpdater<T>) => void,
199
+ () => void
200
+ ];
201
+ declare function createSignal<T = unknown>(value?: CommandKitSignalInitializer<T>): CommandKitSignal<T>;
202
+ declare function createEffect(callback: CommandKitEffectCallback): void;
203
+
204
+ export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal };
package/dist/index.js CHANGED
@@ -30,9 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ ButtonKit: () => ButtonKit,
33
34
  CommandKit: () => CommandKit,
34
35
  CommandType: () => CommandType,
35
- ReloadType: () => ReloadType
36
+ ReloadType: () => ReloadType,
37
+ createEffect: () => createEffect,
38
+ createSignal: () => createSignal
36
39
  });
37
40
  module.exports = __toCommonJS(src_exports);
38
41
 
@@ -900,6 +903,113 @@ var CommandKit = class {
900
903
  }
901
904
  };
902
905
 
906
+ // src/components/Button.ts
907
+ var import_discord = require("discord.js");
908
+ var ButtonKit = class extends import_discord.ButtonBuilder {
909
+ #onClickHandler = null;
910
+ #contextData = null;
911
+ #collector = null;
912
+ onClick(handler, data) {
913
+ if (this.data.style === import_discord.ButtonStyle.Link) {
914
+ throw new TypeError('Cannot setup "onClick" handler for link buttons');
915
+ }
916
+ this.#destroyCollector();
917
+ this.#onClickHandler = handler;
918
+ if (handler && data)
919
+ this.#contextData = data;
920
+ this.#setupInteractionCollector();
921
+ return this;
922
+ }
923
+ #setupInteractionCollector() {
924
+ if (!this.#contextData || !this.#onClickHandler)
925
+ return;
926
+ const message = this.#contextData?.message;
927
+ if (!message) {
928
+ throw new TypeError(
929
+ 'Cannot setup "onClick" handler without a message in the context data'
930
+ );
931
+ }
932
+ if ("customId" in this.data && !this.data.customId) {
933
+ throw new TypeError('Cannot setup "onClick" handler without a custom id');
934
+ }
935
+ const data = {
936
+ time: 864e5,
937
+ autoReset: true,
938
+ ...this.#contextData
939
+ };
940
+ const collector = this.#collector = message.createMessageComponentCollector({
941
+ filter: (interaction) => interaction.customId === this.data.custom_id && interaction.message.id === message.id,
942
+ componentType: import_discord.ComponentType.Button,
943
+ ...data
944
+ });
945
+ this.#collector.on("collect", (interaction) => {
946
+ const handler = this.#onClickHandler;
947
+ if (!handler)
948
+ return this.#destroyCollector();
949
+ if (!this.#collector) {
950
+ return collector.stop("destroyed");
951
+ }
952
+ if (data.autoReset) {
953
+ this.#collector?.resetTimer();
954
+ }
955
+ return handler(interaction);
956
+ });
957
+ this.#collector.on("end", () => {
958
+ this.#destroyCollector();
959
+ });
960
+ }
961
+ #destroyCollector() {
962
+ this.#collector?.stop("end");
963
+ this.#collector?.removeAllListeners();
964
+ this.#collector = null;
965
+ this.#contextData = null;
966
+ this.#onClickHandler = null;
967
+ }
968
+ };
969
+
970
+ // src/utils/signal.ts
971
+ var context = [];
972
+ function createSignal(value) {
973
+ const subscribers = /* @__PURE__ */ new Set();
974
+ let disposed = false;
975
+ let val = value instanceof Function ? value() : value;
976
+ const getter = () => {
977
+ if (!disposed) {
978
+ const running = getCurrentObserver();
979
+ if (running)
980
+ subscribers.add(running);
981
+ }
982
+ return val;
983
+ };
984
+ const setter = (newValue) => {
985
+ if (disposed)
986
+ return;
987
+ val = newValue instanceof Function ? newValue(val) : newValue;
988
+ for (const subscriber of subscribers) {
989
+ subscriber();
990
+ }
991
+ };
992
+ const dispose = () => {
993
+ subscribers.clear();
994
+ disposed = true;
995
+ };
996
+ return [getter, setter, dispose];
997
+ }
998
+ function createEffect(callback) {
999
+ const execute = () => {
1000
+ context.push(execute);
1001
+ try {
1002
+ callback();
1003
+ } finally {
1004
+ context.pop();
1005
+ }
1006
+ };
1007
+ execute();
1008
+ }
1009
+ function getCurrentObserver() {
1010
+ return context[context.length - 1];
1011
+ }
1012
+
903
1013
  // src/types/index.ts
904
1014
  var CommandType = /* @__PURE__ */ ((CommandType2) => {
905
1015
  CommandType2[CommandType2["ChatInput"] = 1] = "ChatInput";
@@ -914,7 +1024,10 @@ var ReloadType = /* @__PURE__ */ ((ReloadType2) => {
914
1024
  })(ReloadType || {});
915
1025
  // Annotate the CommonJS export names for ESM import in node:
916
1026
  0 && (module.exports = {
1027
+ ButtonKit,
917
1028
  CommandKit,
918
1029
  CommandType,
919
- ReloadType
1030
+ ReloadType,
1031
+ createEffect,
1032
+ createSignal
920
1033
  });
package/dist/index.mjs CHANGED
@@ -870,6 +870,113 @@ var CommandKit = class {
870
870
  }
871
871
  };
872
872
 
873
+ // src/components/Button.ts
874
+ import { ButtonBuilder, ButtonStyle, ComponentType } from "discord.js";
875
+ var ButtonKit = class extends ButtonBuilder {
876
+ #onClickHandler = null;
877
+ #contextData = null;
878
+ #collector = null;
879
+ onClick(handler, data) {
880
+ if (this.data.style === ButtonStyle.Link) {
881
+ throw new TypeError('Cannot setup "onClick" handler for link buttons');
882
+ }
883
+ this.#destroyCollector();
884
+ this.#onClickHandler = handler;
885
+ if (handler && data)
886
+ this.#contextData = data;
887
+ this.#setupInteractionCollector();
888
+ return this;
889
+ }
890
+ #setupInteractionCollector() {
891
+ if (!this.#contextData || !this.#onClickHandler)
892
+ return;
893
+ const message = this.#contextData?.message;
894
+ if (!message) {
895
+ throw new TypeError(
896
+ 'Cannot setup "onClick" handler without a message in the context data'
897
+ );
898
+ }
899
+ if ("customId" in this.data && !this.data.customId) {
900
+ throw new TypeError('Cannot setup "onClick" handler without a custom id');
901
+ }
902
+ const data = {
903
+ time: 864e5,
904
+ autoReset: true,
905
+ ...this.#contextData
906
+ };
907
+ const collector = this.#collector = message.createMessageComponentCollector({
908
+ filter: (interaction) => interaction.customId === this.data.custom_id && interaction.message.id === message.id,
909
+ componentType: ComponentType.Button,
910
+ ...data
911
+ });
912
+ this.#collector.on("collect", (interaction) => {
913
+ const handler = this.#onClickHandler;
914
+ if (!handler)
915
+ return this.#destroyCollector();
916
+ if (!this.#collector) {
917
+ return collector.stop("destroyed");
918
+ }
919
+ if (data.autoReset) {
920
+ this.#collector?.resetTimer();
921
+ }
922
+ return handler(interaction);
923
+ });
924
+ this.#collector.on("end", () => {
925
+ this.#destroyCollector();
926
+ });
927
+ }
928
+ #destroyCollector() {
929
+ this.#collector?.stop("end");
930
+ this.#collector?.removeAllListeners();
931
+ this.#collector = null;
932
+ this.#contextData = null;
933
+ this.#onClickHandler = null;
934
+ }
935
+ };
936
+
937
+ // src/utils/signal.ts
938
+ var context = [];
939
+ function createSignal(value) {
940
+ const subscribers = /* @__PURE__ */ new Set();
941
+ let disposed = false;
942
+ let val = value instanceof Function ? value() : value;
943
+ const getter = () => {
944
+ if (!disposed) {
945
+ const running = getCurrentObserver();
946
+ if (running)
947
+ subscribers.add(running);
948
+ }
949
+ return val;
950
+ };
951
+ const setter = (newValue) => {
952
+ if (disposed)
953
+ return;
954
+ val = newValue instanceof Function ? newValue(val) : newValue;
955
+ for (const subscriber of subscribers) {
956
+ subscriber();
957
+ }
958
+ };
959
+ const dispose = () => {
960
+ subscribers.clear();
961
+ disposed = true;
962
+ };
963
+ return [getter, setter, dispose];
964
+ }
965
+ function createEffect(callback) {
966
+ const execute = () => {
967
+ context.push(execute);
968
+ try {
969
+ callback();
970
+ } finally {
971
+ context.pop();
972
+ }
973
+ };
974
+ execute();
975
+ }
976
+ function getCurrentObserver() {
977
+ return context[context.length - 1];
978
+ }
979
+
873
980
  // src/types/index.ts
874
981
  var CommandType = /* @__PURE__ */ ((CommandType2) => {
875
982
  CommandType2[CommandType2["ChatInput"] = 1] = "ChatInput";
@@ -883,7 +990,10 @@ var ReloadType = /* @__PURE__ */ ((ReloadType2) => {
883
990
  return ReloadType2;
884
991
  })(ReloadType || {});
885
992
  export {
993
+ ButtonKit,
886
994
  CommandKit,
887
995
  CommandType,
888
- ReloadType
996
+ ReloadType,
997
+ createEffect,
998
+ createSignal
889
999
  };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "commandkit",
3
3
  "description": "Beginner friendly command & event handler for Discord.js",
4
- "version": "0.1.6-dev.20231006183935",
4
+ "version": "0.1.6-dev.20231112142249",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
+ "bin": "./bin/index.mjs",
9
10
  "exports": {
10
11
  ".": {
11
12
  "require": "./dist/index.js",
@@ -13,6 +14,10 @@
13
14
  "types": "./dist/index.d.ts"
14
15
  }
15
16
  },
17
+ "files": [
18
+ "dist",
19
+ "bin"
20
+ ],
16
21
  "scripts": {
17
22
  "lint": "tsc",
18
23
  "dev": "tsup --watch",
@@ -32,14 +37,17 @@
32
37
  "event handler"
33
38
  ],
34
39
  "dependencies": {
35
- "rfdc": "^1.3.0"
40
+ "commander": "^11.1.0",
41
+ "ora": "^7.0.1",
42
+ "rfdc": "^1.3.0",
43
+ "rimraf": "^5.0.5",
44
+ "tsup": "^7.2.0"
36
45
  },
37
46
  "devDependencies": {
38
47
  "@types/node": "^20.5.9",
39
48
  "discord.js": "^14.13.0",
40
49
  "dotenv": "^16.3.1",
41
50
  "tsconfig": "workspace:*",
42
- "tsup": "^7.2.0",
43
51
  "tsx": "^3.12.8",
44
52
  "typescript": "^5.1.6"
45
53
  },