commandkit 0.1.10 → 0.1.11-dev.20240202064607
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/index.cjs +3 -0
- package/package.json +66 -55
- package/bin/build.mjs +0 -107
- package/bin/common.mjs +0 -102
- package/bin/development.mjs +0 -168
- package/bin/index.mjs +0 -39
- package/bin/parse-env.mjs +0 -61
- package/bin/production.mjs +0 -83
- package/dist/index.d.mts +0 -379
- package/dist/index.d.ts +0 -379
- package/dist/index.js +0 -1122
- package/dist/index.mjs +0 -1092
package/dist/index.d.ts
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction, PermissionsString, RESTPostAPIApplicationCommandsJSONBody, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Options for instantiating a CommandKit handler.
|
|
5
|
-
*/
|
|
6
|
-
interface CommandKitOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The Discord.js client object to use with CommandKit.
|
|
9
|
-
*/
|
|
10
|
-
client: Client;
|
|
11
|
-
/**
|
|
12
|
-
* The path to your commands directory.
|
|
13
|
-
*/
|
|
14
|
-
commandsPath?: string;
|
|
15
|
-
/**
|
|
16
|
-
* The path to your events directory.
|
|
17
|
-
*/
|
|
18
|
-
eventsPath?: string;
|
|
19
|
-
/**
|
|
20
|
-
* The path to the validations directory.
|
|
21
|
-
*/
|
|
22
|
-
validationsPath?: string;
|
|
23
|
-
/**
|
|
24
|
-
* List of development guild IDs to restrict devOnly commands to.
|
|
25
|
-
*/
|
|
26
|
-
devGuildIds?: string[];
|
|
27
|
-
/**
|
|
28
|
-
* List of developer user IDs to restrict devOnly commands to.
|
|
29
|
-
*/
|
|
30
|
-
devUserIds?: string[];
|
|
31
|
-
/**
|
|
32
|
-
* List of developer role IDs to restrict devOnly commands to.
|
|
33
|
-
*/
|
|
34
|
-
devRoleIds?: string[];
|
|
35
|
-
/**
|
|
36
|
-
* Skip CommandKit's built-in validations (for devOnly commands).
|
|
37
|
-
*/
|
|
38
|
-
skipBuiltInValidations?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Bulk register application commands instead of one-by-one.
|
|
41
|
-
*/
|
|
42
|
-
bulkRegister?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* A reload type for commands.
|
|
46
|
-
*/
|
|
47
|
-
type ReloadOptions = 'dev' | 'global' | ReloadType;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Props for command run functions.
|
|
51
|
-
*/
|
|
52
|
-
interface CommandProps {
|
|
53
|
-
/**
|
|
54
|
-
* The current command interaction object.
|
|
55
|
-
*/
|
|
56
|
-
interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction | UserContextMenuCommandInteraction | MessageContextMenuCommandInteraction | AutocompleteInteraction;
|
|
57
|
-
/**
|
|
58
|
-
* The Discord.js client object that CommandKit is handling.
|
|
59
|
-
*/
|
|
60
|
-
client: Client<true>;
|
|
61
|
-
/**
|
|
62
|
-
* The current CommandKit handler instance.
|
|
63
|
-
*/
|
|
64
|
-
handler: CommandKit;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Props for autocomplete command run functions.
|
|
68
|
-
*/
|
|
69
|
-
interface AutocompleteProps extends CommandProps {
|
|
70
|
-
/**
|
|
71
|
-
* The current autocomplete command interaction object.
|
|
72
|
-
*/
|
|
73
|
-
interaction: AutocompleteInteraction;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Props for slash (chat input) command run functions.
|
|
77
|
-
*/
|
|
78
|
-
interface SlashCommandProps extends CommandProps {
|
|
79
|
-
/**
|
|
80
|
-
* The current slash (chat input) command interaction object.
|
|
81
|
-
*/
|
|
82
|
-
interaction: ChatInputCommandInteraction;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Props for context menu command run functions.
|
|
86
|
-
*/
|
|
87
|
-
interface ContextMenuCommandProps extends CommandProps {
|
|
88
|
-
/**
|
|
89
|
-
* The current context menu command interaction object.
|
|
90
|
-
*/
|
|
91
|
-
interaction: ContextMenuCommandInteraction;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Props for user context menu command run functions.
|
|
95
|
-
*/
|
|
96
|
-
interface UserContextMenuCommandProps extends CommandProps {
|
|
97
|
-
interaction: UserContextMenuCommandInteraction;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Props for message context menu command run functions.
|
|
101
|
-
*/
|
|
102
|
-
interface MessageContextMenuCommandProps extends CommandProps {
|
|
103
|
-
interaction: MessageContextMenuCommandInteraction;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Props for command validation functions.
|
|
107
|
-
*/
|
|
108
|
-
interface ValidationProps {
|
|
109
|
-
/**
|
|
110
|
-
* The current command interaction object.
|
|
111
|
-
*/
|
|
112
|
-
interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction | AutocompleteInteraction;
|
|
113
|
-
/**
|
|
114
|
-
* The Discord.js client object that CommandKit is handling.
|
|
115
|
-
*/
|
|
116
|
-
client: Client<true>;
|
|
117
|
-
/**
|
|
118
|
-
* The current (local) target command object.
|
|
119
|
-
*/
|
|
120
|
-
commandObj: CommandObject;
|
|
121
|
-
/**
|
|
122
|
-
* The current CommandKit handler instance.
|
|
123
|
-
*/
|
|
124
|
-
handler: CommandKit;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Additional command configuration options.
|
|
128
|
-
*/
|
|
129
|
-
interface CommandOptions {
|
|
130
|
-
/**
|
|
131
|
-
* A boolean indicating whether the command is guild-only.
|
|
132
|
-
* Used for built-in validation.
|
|
133
|
-
*
|
|
134
|
-
* @deprecated Use `dm_permission` in the command's `data` object instead.
|
|
135
|
-
*/
|
|
136
|
-
guildOnly?: boolean;
|
|
137
|
-
/**
|
|
138
|
-
* A boolean indicating whether the command is developer-only.
|
|
139
|
-
* Used for registration and built-in validation.
|
|
140
|
-
*/
|
|
141
|
-
devOnly?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* A boolean indicating whether the command is deleted/ignored on restart/reload.
|
|
144
|
-
*/
|
|
145
|
-
deleted?: boolean;
|
|
146
|
-
/**
|
|
147
|
-
* A string or array of permissions that a user needs for the current command to be executed.
|
|
148
|
-
* Used for built-in validation.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* userPermissions: 'BanMembers'
|
|
152
|
-
* or
|
|
153
|
-
* userPermissions: ['BanMembers', 'KickMembers']
|
|
154
|
-
*/
|
|
155
|
-
userPermissions?: PermissionsString | PermissionsString[];
|
|
156
|
-
/**
|
|
157
|
-
* A string or array of permissions that the bot needs to execute the current command.
|
|
158
|
-
* Used for built-in validation.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* botPermissions: 'BanMembers'
|
|
162
|
-
* or
|
|
163
|
-
* botPermissions: ['BanMembers', 'KickMembers']
|
|
164
|
-
*/
|
|
165
|
-
botPermissions?: PermissionsString | PermissionsString[];
|
|
166
|
-
[key: string]: any;
|
|
167
|
-
}
|
|
168
|
-
type CommandData = RESTPostAPIApplicationCommandsJSONBody;
|
|
169
|
-
type CommandObject = {
|
|
170
|
-
/**
|
|
171
|
-
* An object which defines the structure of the application command.
|
|
172
|
-
*/
|
|
173
|
-
data: CommandData;
|
|
174
|
-
/**
|
|
175
|
-
* Additional command configuration options.
|
|
176
|
-
*/
|
|
177
|
-
options?: CommandOptions;
|
|
178
|
-
/**
|
|
179
|
-
* The path to the command file.
|
|
180
|
-
*/
|
|
181
|
-
filePath: string;
|
|
182
|
-
/**
|
|
183
|
-
* The command's category. Determined based on the command folder.
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```txt
|
|
187
|
-
* "/src/commands/ping.js" -> null
|
|
188
|
-
* "/src/commands/Misc/ping.js" -> "Misc"
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
category: string | null;
|
|
192
|
-
[key: string]: any;
|
|
193
|
-
};
|
|
194
|
-
declare enum ReloadType {
|
|
195
|
-
/**
|
|
196
|
-
* Reload developer/guild commands.
|
|
197
|
-
*/
|
|
198
|
-
Developer = "dev",
|
|
199
|
-
/**
|
|
200
|
-
* Reload global commands.
|
|
201
|
-
*/
|
|
202
|
-
Global = "global"
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
declare class CommandKit {
|
|
206
|
-
#private;
|
|
207
|
-
/**
|
|
208
|
-
* Create a new command and event handler with CommandKit.
|
|
209
|
-
*
|
|
210
|
-
* @param options - The default CommandKit configuration.
|
|
211
|
-
* @see {@link https://commandkit.js.org/docs/commandkit-setup}
|
|
212
|
-
*/
|
|
213
|
-
constructor(options: CommandKitOptions);
|
|
214
|
-
/**
|
|
215
|
-
* Updates application commands with the latest from "commandsPath".
|
|
216
|
-
*/
|
|
217
|
-
reloadCommands(type?: ReloadOptions): Promise<void>;
|
|
218
|
-
/**
|
|
219
|
-
* Updates application events with the latest from "eventsPath".
|
|
220
|
-
*/
|
|
221
|
-
reloadEvents(): Promise<void>;
|
|
222
|
-
/**
|
|
223
|
-
* Updates application command validations with the latest from "validationsPath".
|
|
224
|
-
*/
|
|
225
|
-
reloadValidations(): Promise<void>;
|
|
226
|
-
/**
|
|
227
|
-
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
228
|
-
*/
|
|
229
|
-
get commands(): CommandObject[];
|
|
230
|
-
/**
|
|
231
|
-
* @returns The path to the commands folder which was set when instantiating CommandKit.
|
|
232
|
-
*/
|
|
233
|
-
get commandsPath(): string | undefined;
|
|
234
|
-
/**
|
|
235
|
-
* @returns The path to the events folder which was set when instantiating CommandKit.
|
|
236
|
-
*/
|
|
237
|
-
get eventsPath(): string | undefined;
|
|
238
|
-
/**
|
|
239
|
-
* @returns The path to the validations folder which was set when instantiating CommandKit.
|
|
240
|
-
*/
|
|
241
|
-
get validationsPath(): string | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* @returns An array of all the developer user IDs which was set when instantiating CommandKit.
|
|
244
|
-
*/
|
|
245
|
-
get devUserIds(): string[];
|
|
246
|
-
/**
|
|
247
|
-
* @returns An array of all the developer guild IDs which was set when instantiating CommandKit.
|
|
248
|
-
*/
|
|
249
|
-
get devGuildIds(): string[];
|
|
250
|
-
/**
|
|
251
|
-
* @returns An array of all the developer role IDs which was set when instantiating CommandKit.
|
|
252
|
-
*/
|
|
253
|
-
get devRoleIds(): string[];
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* The handler to run when a button is clicked. This handler is called with the interaction as the first argument.
|
|
258
|
-
* If the first argument is null, it means that the interaction collector has been destroyed.
|
|
259
|
-
*/
|
|
260
|
-
type CommandKitButtonBuilderInteractionCollectorDispatch = (interaction: ButtonInteraction) => Awaitable<void>;
|
|
261
|
-
type CommandKitButtonBuilderOnEnd = () => Awaitable<void>;
|
|
262
|
-
type CommandKitButtonBuilderInteractionCollectorDispatchContextData = {
|
|
263
|
-
/**
|
|
264
|
-
* The message to listen for button interactions on.
|
|
265
|
-
*/
|
|
266
|
-
message: Message;
|
|
267
|
-
/**
|
|
268
|
-
* The duration (in ms) that the collector should run for.
|
|
269
|
-
*/
|
|
270
|
-
time?: number;
|
|
271
|
-
/**
|
|
272
|
-
* If the collector should automatically reset the timer when a button is clicked.
|
|
273
|
-
*/
|
|
274
|
-
autoReset?: boolean;
|
|
275
|
-
} & Omit<InteractionCollectorOptions<ButtonInteraction>, 'filter' | 'componentType'>;
|
|
276
|
-
declare class ButtonKit extends ButtonBuilder {
|
|
277
|
-
#private;
|
|
278
|
-
/**
|
|
279
|
-
* Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
|
|
280
|
-
* If unused, this expires after 24 hours or custom time if specified.
|
|
281
|
-
* @param handler The handler to run when the button is clicked
|
|
282
|
-
* @param data The context data to use for the interaction collector
|
|
283
|
-
* @returns This button
|
|
284
|
-
* @example
|
|
285
|
-
* ```ts
|
|
286
|
-
* const button = new ButtonKit()
|
|
287
|
-
* .setLabel('Click me')
|
|
288
|
-
* .setStyle(ButtonStyle.Primary)
|
|
289
|
-
* .setCustomId('click_me');
|
|
290
|
-
*
|
|
291
|
-
* const row = new ActionRowBuilder().addComponents(button);
|
|
292
|
-
*
|
|
293
|
-
* const message = await channel.send({ content: 'Click the button', components: [row] });
|
|
294
|
-
*
|
|
295
|
-
* button.onClick(async (interaction) => {
|
|
296
|
-
* await interaction.reply('You clicked me!');
|
|
297
|
-
* }, { message });
|
|
298
|
-
*
|
|
299
|
-
* // Remove onClick handler and destroy the interaction collector
|
|
300
|
-
* button.onClick(null);
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
onClick(handler: CommandKitButtonBuilderInteractionCollectorDispatch, data?: CommandKitButtonBuilderInteractionCollectorDispatchContextData): this;
|
|
304
|
-
onEnd(handler: CommandKitButtonBuilderOnEnd): this;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
interface CommandKitConfig {
|
|
308
|
-
/**
|
|
309
|
-
* The source directory of the project.
|
|
310
|
-
*/
|
|
311
|
-
src: string;
|
|
312
|
-
/**
|
|
313
|
-
* The main "javascript" file of the project.
|
|
314
|
-
*/
|
|
315
|
-
main: string;
|
|
316
|
-
/**
|
|
317
|
-
* Whether or not to use the watch mode. Defaults to `true`.
|
|
318
|
-
*/
|
|
319
|
-
watch: boolean;
|
|
320
|
-
/**
|
|
321
|
-
* The output directory of the project. Defaults to `dist`.
|
|
322
|
-
*/
|
|
323
|
-
outDir: string;
|
|
324
|
-
/**
|
|
325
|
-
* Whether or not to include extra env utilities. Defaults to `true`.
|
|
326
|
-
*/
|
|
327
|
-
envExtra: boolean;
|
|
328
|
-
/**
|
|
329
|
-
* Node.js cli options.
|
|
330
|
-
*/
|
|
331
|
-
nodeOptions: string[];
|
|
332
|
-
/**
|
|
333
|
-
* Whether or not to clear default restart logs. Defaults to `true`.
|
|
334
|
-
*/
|
|
335
|
-
clearRestartLogs: boolean;
|
|
336
|
-
/**
|
|
337
|
-
* Whether or not to minify the output. Defaults to `false`.
|
|
338
|
-
*/
|
|
339
|
-
minify: boolean;
|
|
340
|
-
/**
|
|
341
|
-
* Whether or not to include sourcemaps in production build. Defaults to `false`.
|
|
342
|
-
*/
|
|
343
|
-
sourcemap: boolean | 'inline';
|
|
344
|
-
/**
|
|
345
|
-
* Whether or not to include anti-crash handler in production. Defaults to `true`.
|
|
346
|
-
*/
|
|
347
|
-
antiCrash: boolean;
|
|
348
|
-
/**
|
|
349
|
-
* Whether or not to polyfill `require` function. Defaults to `true`.
|
|
350
|
-
*/
|
|
351
|
-
requirePolyfill: boolean;
|
|
352
|
-
}
|
|
353
|
-
declare function getConfig(): CommandKitConfig;
|
|
354
|
-
declare const requiredProps: readonly ["src", "main"];
|
|
355
|
-
type R = (typeof requiredProps)[number];
|
|
356
|
-
type PartialConfig<T extends CommandKitConfig> = Partial<Omit<T, R>> & Pick<T, R>;
|
|
357
|
-
declare function defineConfig(config: PartialConfig<CommandKitConfig>): Partial<CommandKitConfig>;
|
|
358
|
-
|
|
359
|
-
type CommandKitEffectCallback = () => void;
|
|
360
|
-
type CommandKitSignalInitializer<T> = T | (() => T);
|
|
361
|
-
type CommandKitSignalUpdater<T> = T | ((prev: T) => T);
|
|
362
|
-
type CommandKitSignal<T> = readonly [
|
|
363
|
-
() => T,
|
|
364
|
-
(value: CommandKitSignalUpdater<T>) => void,
|
|
365
|
-
() => void
|
|
366
|
-
];
|
|
367
|
-
/**
|
|
368
|
-
* Creates a new signal.
|
|
369
|
-
* @param value - The initial value to use.
|
|
370
|
-
* @returns An array of functions: a getter, a setter, and a disposer.
|
|
371
|
-
*/
|
|
372
|
-
declare function createSignal<T = unknown>(value?: CommandKitSignalInitializer<T>): CommandKitSignal<T>;
|
|
373
|
-
/**
|
|
374
|
-
* Creates a new effect.
|
|
375
|
-
* @param callback - The callback function to execute.
|
|
376
|
-
*/
|
|
377
|
-
declare function createEffect(callback: CommandKitEffectCallback): void;
|
|
378
|
-
|
|
379
|
-
export { AutocompleteProps, ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitButtonBuilderOnEnd, CommandKitConfig, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, ContextMenuCommandProps, MessageContextMenuCommandProps, ReloadType, SlashCommandProps, UserContextMenuCommandProps, ValidationProps, createEffect, createSignal, defineConfig, getConfig };
|