commandkit 0.1.6-dev.20231113071041 → 0.1.6-dev.20231124164938
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 +42 -8
- package/bin/common.mjs +33 -5
- package/bin/development.mjs +163 -0
- package/bin/index.mjs +13 -3
- package/bin/parse-env.mjs +52 -0
- package/bin/production.mjs +83 -0
- package/dist/index.d.mts +224 -1
- package/dist/index.d.ts +224 -1
- package/dist/index.js +42 -19
- package/dist/index.mjs +39 -16
- package/package.json +4 -3
- package/bin/dev-server.mjs +0 -91
package/dist/index.d.mts
CHANGED
|
@@ -1,70 +1,228 @@
|
|
|
1
1
|
import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionsString, APIApplicationCommandOption, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Base props for commands.
|
|
5
|
+
*/
|
|
3
6
|
interface CommandProps {
|
|
7
|
+
/**
|
|
8
|
+
* Represents the command's interaction.
|
|
9
|
+
*/
|
|
4
10
|
interaction: CommandInteraction;
|
|
11
|
+
/**
|
|
12
|
+
* The client created in your main file.
|
|
13
|
+
*/
|
|
5
14
|
client: Client<true>;
|
|
15
|
+
/**
|
|
16
|
+
* The main CommandKit handler that instantiated this.
|
|
17
|
+
*/
|
|
6
18
|
handler: CommandKit;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Props for slash command run functions.
|
|
22
|
+
*/
|
|
8
23
|
interface SlashCommandProps {
|
|
24
|
+
/**
|
|
25
|
+
* Represents the command's interaction.
|
|
26
|
+
*/
|
|
9
27
|
interaction: ChatInputCommandInteraction;
|
|
28
|
+
/**
|
|
29
|
+
* The client created in your main file.
|
|
30
|
+
*/
|
|
10
31
|
client: Client<true>;
|
|
32
|
+
/**
|
|
33
|
+
* The CommandKit handler that instantiated this.
|
|
34
|
+
*/
|
|
11
35
|
handler: CommandKit;
|
|
12
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Props for context menu command run functions.
|
|
39
|
+
*/
|
|
13
40
|
interface ContextMenuCommandProps {
|
|
41
|
+
/**
|
|
42
|
+
* Represents the command's interaction.
|
|
43
|
+
*/
|
|
14
44
|
interaction: ContextMenuCommandInteraction;
|
|
45
|
+
/**
|
|
46
|
+
* The client created in your main file.
|
|
47
|
+
*/
|
|
15
48
|
client: Client<true>;
|
|
49
|
+
/**
|
|
50
|
+
* The CommandKit handler that instantiated this.
|
|
51
|
+
*/
|
|
16
52
|
handler: CommandKit;
|
|
17
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Props for command validations.
|
|
56
|
+
*/
|
|
18
57
|
interface ValidationFunctionProps {
|
|
58
|
+
/**
|
|
59
|
+
* Represents the command's interaction.
|
|
60
|
+
* Either a slash command or a context menu command interaction.
|
|
61
|
+
*/
|
|
19
62
|
interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction;
|
|
63
|
+
/**
|
|
64
|
+
* The client created in your main file.
|
|
65
|
+
* Represented as a ready client (`Client<true>`).
|
|
66
|
+
*/
|
|
20
67
|
client: Client<true>;
|
|
68
|
+
/**
|
|
69
|
+
* The command object that is being validated.
|
|
70
|
+
*/
|
|
21
71
|
commandObj: CommandObject;
|
|
72
|
+
/**
|
|
73
|
+
* The CommandKit handler that instantiated this.
|
|
74
|
+
*/
|
|
22
75
|
handler: CommandKit;
|
|
23
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Configuration for commands.
|
|
79
|
+
*/
|
|
24
80
|
interface CommandOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Boolean indicating whether the command is guild-only.
|
|
83
|
+
* @deprecated - Use `dm_permission` in the command's data instead.
|
|
84
|
+
*/
|
|
25
85
|
guildOnly?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Boolean indicating whether the command is developer only.
|
|
88
|
+
*/
|
|
26
89
|
devOnly?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Boolean indicating whether the command is deleted and should not be registered.
|
|
92
|
+
*/
|
|
27
93
|
deleted?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* An array of user permissions.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* userPermissions: ['BanMembers']
|
|
99
|
+
*/
|
|
28
100
|
userPermissions?: PermissionsString[];
|
|
101
|
+
/**
|
|
102
|
+
* An array of bot permissions.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* botPermissions: ['BanMembers']
|
|
106
|
+
*/
|
|
29
107
|
botPermissions?: PermissionsString[];
|
|
30
108
|
[key: string]: any;
|
|
31
109
|
}
|
|
32
110
|
declare enum CommandType {
|
|
111
|
+
/**
|
|
112
|
+
* Slash commands.
|
|
113
|
+
*/
|
|
33
114
|
'ChatInput' = 1,
|
|
115
|
+
/**
|
|
116
|
+
* Message context menu commands.
|
|
117
|
+
*/
|
|
34
118
|
'Message' = 3,
|
|
119
|
+
/**
|
|
120
|
+
* User context menu commands.
|
|
121
|
+
*/
|
|
35
122
|
'User' = 2
|
|
36
123
|
}
|
|
37
124
|
type LocaleString = 'id' | `en-${'GB' | 'US'}` | 'bg' | `zh-${'CN' | 'TW'}` | 'hr' | 'cs' | 'da' | 'nl' | 'fi' | 'fr' | 'de' | 'el' | 'hi' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'ru' | 'es-ES' | 'sv-SE' | 'th' | 'tr' | 'uk' | 'vi';
|
|
125
|
+
/**
|
|
126
|
+
* Common items for command data.
|
|
127
|
+
*/
|
|
38
128
|
type BaseCommandData = {
|
|
129
|
+
/**
|
|
130
|
+
* The name of the command.
|
|
131
|
+
*/
|
|
39
132
|
name: string;
|
|
133
|
+
/**
|
|
134
|
+
* The type of the command.
|
|
135
|
+
*/
|
|
40
136
|
type?: CommandType;
|
|
137
|
+
/**
|
|
138
|
+
* i18n for the command name.
|
|
139
|
+
*/
|
|
41
140
|
name_localizations?: Partial<Record<LocaleString, string | null>>;
|
|
141
|
+
/**
|
|
142
|
+
* Whether to allow this command in DMs.
|
|
143
|
+
*/
|
|
42
144
|
dm_permission?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Default permissions for members for the command.
|
|
147
|
+
*/
|
|
43
148
|
default_member_permissions?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Whether the command is age-restricted.
|
|
151
|
+
*/
|
|
44
152
|
nsfw?: boolean;
|
|
45
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* Data for chat input commands.
|
|
156
|
+
*/
|
|
46
157
|
type ChatInputCommandData = BaseCommandData & {
|
|
158
|
+
/**
|
|
159
|
+
* The command's type.
|
|
160
|
+
*/
|
|
47
161
|
type?: CommandType.ChatInput;
|
|
162
|
+
/**
|
|
163
|
+
* The description of the command.
|
|
164
|
+
*/
|
|
48
165
|
description: string;
|
|
166
|
+
/**
|
|
167
|
+
* i18n for the command description.
|
|
168
|
+
*/
|
|
49
169
|
description_localizations?: Partial<Record<LocaleString, string | null>>;
|
|
170
|
+
/**
|
|
171
|
+
* Chat input command options.
|
|
172
|
+
*/
|
|
50
173
|
options?: Array<APIApplicationCommandOption>;
|
|
51
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* Represents any context menu command data.
|
|
177
|
+
*/
|
|
52
178
|
type UserOrMessageCommandData = BaseCommandData & {
|
|
53
179
|
type: CommandType.User | CommandType.Message;
|
|
54
180
|
};
|
|
55
181
|
type CommandData = ChatInputCommandData | UserOrMessageCommandData;
|
|
56
182
|
type CommandObject = {
|
|
183
|
+
/**
|
|
184
|
+
* Command data which is a slash command builder or raw JSON data.
|
|
185
|
+
* @example
|
|
186
|
+
* {
|
|
187
|
+
* name: 'ping',
|
|
188
|
+
* description: 'Replies with Pong!'
|
|
189
|
+
* }
|
|
190
|
+
*/
|
|
57
191
|
data: CommandData;
|
|
192
|
+
/**
|
|
193
|
+
* CommandKit command options.
|
|
194
|
+
* @example
|
|
195
|
+
* {
|
|
196
|
+
* devOnly: true,
|
|
197
|
+
* userPermissions: ['ManageGuild'],
|
|
198
|
+
* botPermissions: ['ManageGuild'],
|
|
199
|
+
* }
|
|
200
|
+
*/
|
|
58
201
|
options?: CommandOptions;
|
|
202
|
+
/**
|
|
203
|
+
* The path to the command file.
|
|
204
|
+
*/
|
|
59
205
|
filePath: string;
|
|
206
|
+
/**
|
|
207
|
+
* The command's category.
|
|
208
|
+
*/
|
|
60
209
|
category: string | null;
|
|
61
210
|
[key: string]: any;
|
|
62
211
|
};
|
|
63
212
|
declare enum ReloadType {
|
|
213
|
+
/**
|
|
214
|
+
* Reload developer/guild commands.
|
|
215
|
+
*/
|
|
64
216
|
Developer = "dev",
|
|
217
|
+
/**
|
|
218
|
+
* Reload global commands.
|
|
219
|
+
*/
|
|
65
220
|
Global = "global"
|
|
66
221
|
}
|
|
67
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Options for instantiating a CommandKit handler.
|
|
225
|
+
*/
|
|
68
226
|
interface CommandKitOptions {
|
|
69
227
|
/**
|
|
70
228
|
* The Discord.js client object to use with CommandKit.
|
|
@@ -103,10 +261,18 @@ interface CommandKitOptions {
|
|
|
103
261
|
*/
|
|
104
262
|
bulkRegister?: boolean;
|
|
105
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* A reload type for commands.
|
|
266
|
+
*/
|
|
106
267
|
type ReloadOptions = 'dev' | 'global' | ReloadType;
|
|
107
268
|
|
|
108
269
|
declare class CommandKit {
|
|
109
270
|
#private;
|
|
271
|
+
/**
|
|
272
|
+
* Create a new handler with CommandKit.
|
|
273
|
+
* @param options - Options to use (client, commandsPath, eventsPath, etc.)
|
|
274
|
+
* @see {@link https://commandkit.js.org/docs/commandkit-setup}
|
|
275
|
+
*/
|
|
110
276
|
constructor(options: CommandKitOptions);
|
|
111
277
|
/**
|
|
112
278
|
* Updates application commands with the latest from "commandsPath".
|
|
@@ -196,6 +362,54 @@ declare class ButtonKit extends ButtonBuilder {
|
|
|
196
362
|
onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
|
|
197
363
|
}
|
|
198
364
|
|
|
365
|
+
interface CommandKitConfig {
|
|
366
|
+
/**
|
|
367
|
+
* The source directory of the project.
|
|
368
|
+
*/
|
|
369
|
+
src: string;
|
|
370
|
+
/**
|
|
371
|
+
* The main "javascript" file of the project.
|
|
372
|
+
*/
|
|
373
|
+
main: string;
|
|
374
|
+
/**
|
|
375
|
+
* Whether or not to use the watch mode. Defaults to `true`.
|
|
376
|
+
*/
|
|
377
|
+
watch: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* The output directory of the project. Defaults to `dist`.
|
|
380
|
+
*/
|
|
381
|
+
outDir: string;
|
|
382
|
+
/**
|
|
383
|
+
* Whether or not to include extra env utilities. Defaults to `true`.
|
|
384
|
+
*/
|
|
385
|
+
envExtra: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Node.js cli options.
|
|
388
|
+
*/
|
|
389
|
+
nodeOptions: string[];
|
|
390
|
+
/**
|
|
391
|
+
* Whether or not to clear default restart logs. Defaults to `true`.
|
|
392
|
+
*/
|
|
393
|
+
clearRestartLogs: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Whether or not to minify the output. Defaults to `false`.
|
|
396
|
+
*/
|
|
397
|
+
minify: boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Whether or not to include sourcemaps in production build. Defaults to `false`.
|
|
400
|
+
*/
|
|
401
|
+
sourcemap: boolean | 'inline';
|
|
402
|
+
/**
|
|
403
|
+
* Whether or not to include anti-crash handler in production. Defaults to `true`.
|
|
404
|
+
*/
|
|
405
|
+
antiCrash: boolean;
|
|
406
|
+
}
|
|
407
|
+
declare function getConfig(): CommandKitConfig;
|
|
408
|
+
declare const requiredProps: readonly ["src", "main"];
|
|
409
|
+
type R = (typeof requiredProps)[number];
|
|
410
|
+
type PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> & Pick<T, R>;
|
|
411
|
+
declare function defineConfig(config: PartialConfig<CommandKitConfig>): Partial<CommandKitConfig>;
|
|
412
|
+
|
|
199
413
|
type CommandKitEffectCallback = () => void;
|
|
200
414
|
type CommandKitSignalInitializer<T> = T | (() => T);
|
|
201
415
|
type CommandKitSignalUpdater<T> = T | ((prev: T) => T);
|
|
@@ -204,7 +418,16 @@ type CommandKitSignal<T> = readonly [
|
|
|
204
418
|
(value: CommandKitSignalUpdater<T>) => void,
|
|
205
419
|
() => void
|
|
206
420
|
];
|
|
421
|
+
/**
|
|
422
|
+
* Creates a new signal.
|
|
423
|
+
* @param value - The initial value to use.
|
|
424
|
+
* @returns An array of functions: a getter, a setter, and a disposer.
|
|
425
|
+
*/
|
|
207
426
|
declare function createSignal<T = unknown>(value?: CommandKitSignalInitializer<T>): CommandKitSignal<T>;
|
|
427
|
+
/**
|
|
428
|
+
* Creates a new effect.
|
|
429
|
+
* @param callback - The callback function to execute.
|
|
430
|
+
*/
|
|
208
431
|
declare function createEffect(callback: CommandKitEffectCallback): void;
|
|
209
432
|
|
|
210
|
-
export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal };
|
|
433
|
+
export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitConfig, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal, defineConfig, getConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,70 +1,228 @@
|
|
|
1
1
|
import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionsString, APIApplicationCommandOption, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Base props for commands.
|
|
5
|
+
*/
|
|
3
6
|
interface CommandProps {
|
|
7
|
+
/**
|
|
8
|
+
* Represents the command's interaction.
|
|
9
|
+
*/
|
|
4
10
|
interaction: CommandInteraction;
|
|
11
|
+
/**
|
|
12
|
+
* The client created in your main file.
|
|
13
|
+
*/
|
|
5
14
|
client: Client<true>;
|
|
15
|
+
/**
|
|
16
|
+
* The main CommandKit handler that instantiated this.
|
|
17
|
+
*/
|
|
6
18
|
handler: CommandKit;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Props for slash command run functions.
|
|
22
|
+
*/
|
|
8
23
|
interface SlashCommandProps {
|
|
24
|
+
/**
|
|
25
|
+
* Represents the command's interaction.
|
|
26
|
+
*/
|
|
9
27
|
interaction: ChatInputCommandInteraction;
|
|
28
|
+
/**
|
|
29
|
+
* The client created in your main file.
|
|
30
|
+
*/
|
|
10
31
|
client: Client<true>;
|
|
32
|
+
/**
|
|
33
|
+
* The CommandKit handler that instantiated this.
|
|
34
|
+
*/
|
|
11
35
|
handler: CommandKit;
|
|
12
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Props for context menu command run functions.
|
|
39
|
+
*/
|
|
13
40
|
interface ContextMenuCommandProps {
|
|
41
|
+
/**
|
|
42
|
+
* Represents the command's interaction.
|
|
43
|
+
*/
|
|
14
44
|
interaction: ContextMenuCommandInteraction;
|
|
45
|
+
/**
|
|
46
|
+
* The client created in your main file.
|
|
47
|
+
*/
|
|
15
48
|
client: Client<true>;
|
|
49
|
+
/**
|
|
50
|
+
* The CommandKit handler that instantiated this.
|
|
51
|
+
*/
|
|
16
52
|
handler: CommandKit;
|
|
17
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Props for command validations.
|
|
56
|
+
*/
|
|
18
57
|
interface ValidationFunctionProps {
|
|
58
|
+
/**
|
|
59
|
+
* Represents the command's interaction.
|
|
60
|
+
* Either a slash command or a context menu command interaction.
|
|
61
|
+
*/
|
|
19
62
|
interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction;
|
|
63
|
+
/**
|
|
64
|
+
* The client created in your main file.
|
|
65
|
+
* Represented as a ready client (`Client<true>`).
|
|
66
|
+
*/
|
|
20
67
|
client: Client<true>;
|
|
68
|
+
/**
|
|
69
|
+
* The command object that is being validated.
|
|
70
|
+
*/
|
|
21
71
|
commandObj: CommandObject;
|
|
72
|
+
/**
|
|
73
|
+
* The CommandKit handler that instantiated this.
|
|
74
|
+
*/
|
|
22
75
|
handler: CommandKit;
|
|
23
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Configuration for commands.
|
|
79
|
+
*/
|
|
24
80
|
interface CommandOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Boolean indicating whether the command is guild-only.
|
|
83
|
+
* @deprecated - Use `dm_permission` in the command's data instead.
|
|
84
|
+
*/
|
|
25
85
|
guildOnly?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Boolean indicating whether the command is developer only.
|
|
88
|
+
*/
|
|
26
89
|
devOnly?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Boolean indicating whether the command is deleted and should not be registered.
|
|
92
|
+
*/
|
|
27
93
|
deleted?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* An array of user permissions.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* userPermissions: ['BanMembers']
|
|
99
|
+
*/
|
|
28
100
|
userPermissions?: PermissionsString[];
|
|
101
|
+
/**
|
|
102
|
+
* An array of bot permissions.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* botPermissions: ['BanMembers']
|
|
106
|
+
*/
|
|
29
107
|
botPermissions?: PermissionsString[];
|
|
30
108
|
[key: string]: any;
|
|
31
109
|
}
|
|
32
110
|
declare enum CommandType {
|
|
111
|
+
/**
|
|
112
|
+
* Slash commands.
|
|
113
|
+
*/
|
|
33
114
|
'ChatInput' = 1,
|
|
115
|
+
/**
|
|
116
|
+
* Message context menu commands.
|
|
117
|
+
*/
|
|
34
118
|
'Message' = 3,
|
|
119
|
+
/**
|
|
120
|
+
* User context menu commands.
|
|
121
|
+
*/
|
|
35
122
|
'User' = 2
|
|
36
123
|
}
|
|
37
124
|
type LocaleString = 'id' | `en-${'GB' | 'US'}` | 'bg' | `zh-${'CN' | 'TW'}` | 'hr' | 'cs' | 'da' | 'nl' | 'fi' | 'fr' | 'de' | 'el' | 'hi' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'ru' | 'es-ES' | 'sv-SE' | 'th' | 'tr' | 'uk' | 'vi';
|
|
125
|
+
/**
|
|
126
|
+
* Common items for command data.
|
|
127
|
+
*/
|
|
38
128
|
type BaseCommandData = {
|
|
129
|
+
/**
|
|
130
|
+
* The name of the command.
|
|
131
|
+
*/
|
|
39
132
|
name: string;
|
|
133
|
+
/**
|
|
134
|
+
* The type of the command.
|
|
135
|
+
*/
|
|
40
136
|
type?: CommandType;
|
|
137
|
+
/**
|
|
138
|
+
* i18n for the command name.
|
|
139
|
+
*/
|
|
41
140
|
name_localizations?: Partial<Record<LocaleString, string | null>>;
|
|
141
|
+
/**
|
|
142
|
+
* Whether to allow this command in DMs.
|
|
143
|
+
*/
|
|
42
144
|
dm_permission?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Default permissions for members for the command.
|
|
147
|
+
*/
|
|
43
148
|
default_member_permissions?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Whether the command is age-restricted.
|
|
151
|
+
*/
|
|
44
152
|
nsfw?: boolean;
|
|
45
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* Data for chat input commands.
|
|
156
|
+
*/
|
|
46
157
|
type ChatInputCommandData = BaseCommandData & {
|
|
158
|
+
/**
|
|
159
|
+
* The command's type.
|
|
160
|
+
*/
|
|
47
161
|
type?: CommandType.ChatInput;
|
|
162
|
+
/**
|
|
163
|
+
* The description of the command.
|
|
164
|
+
*/
|
|
48
165
|
description: string;
|
|
166
|
+
/**
|
|
167
|
+
* i18n for the command description.
|
|
168
|
+
*/
|
|
49
169
|
description_localizations?: Partial<Record<LocaleString, string | null>>;
|
|
170
|
+
/**
|
|
171
|
+
* Chat input command options.
|
|
172
|
+
*/
|
|
50
173
|
options?: Array<APIApplicationCommandOption>;
|
|
51
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* Represents any context menu command data.
|
|
177
|
+
*/
|
|
52
178
|
type UserOrMessageCommandData = BaseCommandData & {
|
|
53
179
|
type: CommandType.User | CommandType.Message;
|
|
54
180
|
};
|
|
55
181
|
type CommandData = ChatInputCommandData | UserOrMessageCommandData;
|
|
56
182
|
type CommandObject = {
|
|
183
|
+
/**
|
|
184
|
+
* Command data which is a slash command builder or raw JSON data.
|
|
185
|
+
* @example
|
|
186
|
+
* {
|
|
187
|
+
* name: 'ping',
|
|
188
|
+
* description: 'Replies with Pong!'
|
|
189
|
+
* }
|
|
190
|
+
*/
|
|
57
191
|
data: CommandData;
|
|
192
|
+
/**
|
|
193
|
+
* CommandKit command options.
|
|
194
|
+
* @example
|
|
195
|
+
* {
|
|
196
|
+
* devOnly: true,
|
|
197
|
+
* userPermissions: ['ManageGuild'],
|
|
198
|
+
* botPermissions: ['ManageGuild'],
|
|
199
|
+
* }
|
|
200
|
+
*/
|
|
58
201
|
options?: CommandOptions;
|
|
202
|
+
/**
|
|
203
|
+
* The path to the command file.
|
|
204
|
+
*/
|
|
59
205
|
filePath: string;
|
|
206
|
+
/**
|
|
207
|
+
* The command's category.
|
|
208
|
+
*/
|
|
60
209
|
category: string | null;
|
|
61
210
|
[key: string]: any;
|
|
62
211
|
};
|
|
63
212
|
declare enum ReloadType {
|
|
213
|
+
/**
|
|
214
|
+
* Reload developer/guild commands.
|
|
215
|
+
*/
|
|
64
216
|
Developer = "dev",
|
|
217
|
+
/**
|
|
218
|
+
* Reload global commands.
|
|
219
|
+
*/
|
|
65
220
|
Global = "global"
|
|
66
221
|
}
|
|
67
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Options for instantiating a CommandKit handler.
|
|
225
|
+
*/
|
|
68
226
|
interface CommandKitOptions {
|
|
69
227
|
/**
|
|
70
228
|
* The Discord.js client object to use with CommandKit.
|
|
@@ -103,10 +261,18 @@ interface CommandKitOptions {
|
|
|
103
261
|
*/
|
|
104
262
|
bulkRegister?: boolean;
|
|
105
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* A reload type for commands.
|
|
266
|
+
*/
|
|
106
267
|
type ReloadOptions = 'dev' | 'global' | ReloadType;
|
|
107
268
|
|
|
108
269
|
declare class CommandKit {
|
|
109
270
|
#private;
|
|
271
|
+
/**
|
|
272
|
+
* Create a new handler with CommandKit.
|
|
273
|
+
* @param options - Options to use (client, commandsPath, eventsPath, etc.)
|
|
274
|
+
* @see {@link https://commandkit.js.org/docs/commandkit-setup}
|
|
275
|
+
*/
|
|
110
276
|
constructor(options: CommandKitOptions);
|
|
111
277
|
/**
|
|
112
278
|
* Updates application commands with the latest from "commandsPath".
|
|
@@ -196,6 +362,54 @@ declare class ButtonKit extends ButtonBuilder {
|
|
|
196
362
|
onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
|
|
197
363
|
}
|
|
198
364
|
|
|
365
|
+
interface CommandKitConfig {
|
|
366
|
+
/**
|
|
367
|
+
* The source directory of the project.
|
|
368
|
+
*/
|
|
369
|
+
src: string;
|
|
370
|
+
/**
|
|
371
|
+
* The main "javascript" file of the project.
|
|
372
|
+
*/
|
|
373
|
+
main: string;
|
|
374
|
+
/**
|
|
375
|
+
* Whether or not to use the watch mode. Defaults to `true`.
|
|
376
|
+
*/
|
|
377
|
+
watch: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* The output directory of the project. Defaults to `dist`.
|
|
380
|
+
*/
|
|
381
|
+
outDir: string;
|
|
382
|
+
/**
|
|
383
|
+
* Whether or not to include extra env utilities. Defaults to `true`.
|
|
384
|
+
*/
|
|
385
|
+
envExtra: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Node.js cli options.
|
|
388
|
+
*/
|
|
389
|
+
nodeOptions: string[];
|
|
390
|
+
/**
|
|
391
|
+
* Whether or not to clear default restart logs. Defaults to `true`.
|
|
392
|
+
*/
|
|
393
|
+
clearRestartLogs: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Whether or not to minify the output. Defaults to `false`.
|
|
396
|
+
*/
|
|
397
|
+
minify: boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Whether or not to include sourcemaps in production build. Defaults to `false`.
|
|
400
|
+
*/
|
|
401
|
+
sourcemap: boolean | 'inline';
|
|
402
|
+
/**
|
|
403
|
+
* Whether or not to include anti-crash handler in production. Defaults to `true`.
|
|
404
|
+
*/
|
|
405
|
+
antiCrash: boolean;
|
|
406
|
+
}
|
|
407
|
+
declare function getConfig(): CommandKitConfig;
|
|
408
|
+
declare const requiredProps: readonly ["src", "main"];
|
|
409
|
+
type R = (typeof requiredProps)[number];
|
|
410
|
+
type PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> & Pick<T, R>;
|
|
411
|
+
declare function defineConfig(config: PartialConfig<CommandKitConfig>): Partial<CommandKitConfig>;
|
|
412
|
+
|
|
199
413
|
type CommandKitEffectCallback = () => void;
|
|
200
414
|
type CommandKitSignalInitializer<T> = T | (() => T);
|
|
201
415
|
type CommandKitSignalUpdater<T> = T | ((prev: T) => T);
|
|
@@ -204,7 +418,16 @@ type CommandKitSignal<T> = readonly [
|
|
|
204
418
|
(value: CommandKitSignalUpdater<T>) => void,
|
|
205
419
|
() => void
|
|
206
420
|
];
|
|
421
|
+
/**
|
|
422
|
+
* Creates a new signal.
|
|
423
|
+
* @param value - The initial value to use.
|
|
424
|
+
* @returns An array of functions: a getter, a setter, and a disposer.
|
|
425
|
+
*/
|
|
207
426
|
declare function createSignal<T = unknown>(value?: CommandKitSignalInitializer<T>): CommandKitSignal<T>;
|
|
427
|
+
/**
|
|
428
|
+
* Creates a new effect.
|
|
429
|
+
* @param callback - The callback function to execute.
|
|
430
|
+
*/
|
|
208
431
|
declare function createEffect(callback: CommandKitEffectCallback): void;
|
|
209
432
|
|
|
210
|
-
export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal };
|
|
433
|
+
export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitConfig, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal, defineConfig, getConfig };
|