commandkit 0.1.3-dev.20231002185336 → 0.1.3-dev.20231002200254
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +76 -35
- package/dist/index.mjs +76 -35
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -34,10 +34,9 @@ interface CommandKitOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
skipBuiltInValidations?: boolean;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @experimental
|
|
37
|
+
* Bulk register application commands instead of one-by-one.
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
bulkRegister?: boolean;
|
|
41
40
|
}
|
|
42
41
|
interface CommandFileObject {
|
|
43
42
|
data: CommandData;
|
|
@@ -117,9 +116,16 @@ declare class CommandKit {
|
|
|
117
116
|
constructor(options: CommandKitOptions);
|
|
118
117
|
/**
|
|
119
118
|
* Updates application commands with the latest from "commandsPath".
|
|
120
|
-
* @experimental
|
|
121
119
|
*/
|
|
122
120
|
reloadCommands(type?: ReloadOptions): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Updates application events with the latest from "eventsPath".
|
|
123
|
+
*/
|
|
124
|
+
reloadEvents(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Updates application command validations with the latest from "validationsPath".
|
|
127
|
+
*/
|
|
128
|
+
reloadValidations(): Promise<void>;
|
|
123
129
|
/**
|
|
124
130
|
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
125
131
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -34,10 +34,9 @@ interface CommandKitOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
skipBuiltInValidations?: boolean;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @experimental
|
|
37
|
+
* Bulk register application commands instead of one-by-one.
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
bulkRegister?: boolean;
|
|
41
40
|
}
|
|
42
41
|
interface CommandFileObject {
|
|
43
42
|
data: CommandData;
|
|
@@ -117,9 +116,16 @@ declare class CommandKit {
|
|
|
117
116
|
constructor(options: CommandKitOptions);
|
|
118
117
|
/**
|
|
119
118
|
* Updates application commands with the latest from "commandsPath".
|
|
120
|
-
* @experimental
|
|
121
119
|
*/
|
|
122
120
|
reloadCommands(type?: ReloadOptions): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Updates application events with the latest from "eventsPath".
|
|
123
|
+
*/
|
|
124
|
+
reloadEvents(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Updates application command validations with the latest from "validationsPath".
|
|
127
|
+
*/
|
|
128
|
+
reloadValidations(): Promise<void>;
|
|
123
129
|
/**
|
|
124
130
|
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
125
131
|
*/
|
package/dist/index.js
CHANGED
|
@@ -239,22 +239,20 @@ async function registerGlobalCommands(client, commands) {
|
|
|
239
239
|
)
|
|
240
240
|
);
|
|
241
241
|
} else {
|
|
242
|
-
targetCommand.delete().
|
|
242
|
+
await targetCommand.delete().catch((error) => {
|
|
243
243
|
console.log(
|
|
244
|
-
colors_default.
|
|
244
|
+
colors_default.red(`\u274C Failed to delete command "${command.data.name}" globally.`)
|
|
245
245
|
);
|
|
246
|
+
console.error(error);
|
|
246
247
|
});
|
|
248
|
+
console.log(colors_default.green(`\u{1F6AE} Deleted command "${command.data.name}" globally.`));
|
|
247
249
|
}
|
|
248
250
|
continue;
|
|
249
251
|
}
|
|
250
252
|
if (targetCommand) {
|
|
251
253
|
const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
|
|
252
254
|
if (commandsAreDifferent) {
|
|
253
|
-
targetCommand.edit(command.data).
|
|
254
|
-
console.log(
|
|
255
|
-
colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`)
|
|
256
|
-
);
|
|
257
|
-
}).catch((error) => {
|
|
255
|
+
await targetCommand.edit(command.data).catch((error) => {
|
|
258
256
|
console.log(
|
|
259
257
|
colors_default.red(
|
|
260
258
|
`\u274C Failed to edit command "${command.data.name}" globally.`
|
|
@@ -262,19 +260,19 @@ async function registerGlobalCommands(client, commands) {
|
|
|
262
260
|
);
|
|
263
261
|
console.error(error);
|
|
264
262
|
});
|
|
263
|
+
console.log(colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`));
|
|
265
264
|
continue;
|
|
266
265
|
}
|
|
267
266
|
}
|
|
268
267
|
if (targetCommand)
|
|
269
268
|
continue;
|
|
270
|
-
appCommandsManager.create(command.data).
|
|
271
|
-
console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`));
|
|
272
|
-
}).catch((error) => {
|
|
269
|
+
await appCommandsManager.create(command.data).catch((error) => {
|
|
273
270
|
console.log(
|
|
274
271
|
colors_default.red(`\u274C Failed to register command "${command.data.name}" globally.`)
|
|
275
272
|
);
|
|
276
273
|
console.error(error);
|
|
277
274
|
});
|
|
275
|
+
console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`));
|
|
278
276
|
}
|
|
279
277
|
}
|
|
280
278
|
async function registerDevCommands(client, commands, guildIds) {
|
|
@@ -308,26 +306,26 @@ async function registerDevCommands(client, commands, guildIds) {
|
|
|
308
306
|
)
|
|
309
307
|
);
|
|
310
308
|
} else {
|
|
311
|
-
targetCommand.delete().
|
|
309
|
+
await targetCommand.delete().catch((error) => {
|
|
312
310
|
console.log(
|
|
313
|
-
colors_default.
|
|
314
|
-
`\
|
|
311
|
+
colors_default.red(
|
|
312
|
+
`\u274C Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
315
313
|
)
|
|
316
314
|
);
|
|
315
|
+
console.error(error);
|
|
317
316
|
});
|
|
317
|
+
console.log(
|
|
318
|
+
colors_default.green(
|
|
319
|
+
`\u{1F6AE} Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
320
|
+
)
|
|
321
|
+
);
|
|
318
322
|
}
|
|
319
323
|
continue;
|
|
320
324
|
}
|
|
321
325
|
if (targetCommand) {
|
|
322
326
|
const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
|
|
323
327
|
if (commandsAreDifferent) {
|
|
324
|
-
targetCommand.edit(command.data).
|
|
325
|
-
console.log(
|
|
326
|
-
colors_default.green(
|
|
327
|
-
`\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
328
|
-
)
|
|
329
|
-
);
|
|
330
|
-
}).catch((error) => {
|
|
328
|
+
await targetCommand.edit(command.data).catch((error) => {
|
|
331
329
|
console.log(
|
|
332
330
|
colors_default.red(
|
|
333
331
|
`\u274C Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
@@ -335,18 +333,17 @@ async function registerDevCommands(client, commands, guildIds) {
|
|
|
335
333
|
);
|
|
336
334
|
console.error(error);
|
|
337
335
|
});
|
|
336
|
+
console.log(
|
|
337
|
+
colors_default.green(
|
|
338
|
+
`\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
339
|
+
)
|
|
340
|
+
);
|
|
338
341
|
continue;
|
|
339
342
|
}
|
|
340
343
|
}
|
|
341
344
|
if (targetCommand)
|
|
342
345
|
continue;
|
|
343
|
-
guildCommands.create(command.data).
|
|
344
|
-
console.log(
|
|
345
|
-
colors_default.green(
|
|
346
|
-
`\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
347
|
-
)
|
|
348
|
-
);
|
|
349
|
-
}).catch((error) => {
|
|
346
|
+
await guildCommands.create(command.data).catch((error) => {
|
|
350
347
|
console.log(
|
|
351
348
|
colors_default.red(
|
|
352
349
|
`\u274C Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
@@ -354,6 +351,11 @@ async function registerDevCommands(client, commands, guildIds) {
|
|
|
354
351
|
);
|
|
355
352
|
console.error(error);
|
|
356
353
|
});
|
|
354
|
+
console.log(
|
|
355
|
+
colors_default.green(
|
|
356
|
+
`\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
357
|
+
)
|
|
358
|
+
);
|
|
357
359
|
}
|
|
358
360
|
}
|
|
359
361
|
}
|
|
@@ -485,7 +487,7 @@ var CommandHandler = class {
|
|
|
485
487
|
)
|
|
486
488
|
);
|
|
487
489
|
}
|
|
488
|
-
if (this.#data.
|
|
490
|
+
if (this.#data.bulkRegister) {
|
|
489
491
|
await loadCommandsWithRest({
|
|
490
492
|
client: this.#data.client,
|
|
491
493
|
devGuildIds: this.#data.devGuildIds,
|
|
@@ -620,7 +622,7 @@ var CommandHandler = class {
|
|
|
620
622
|
async reloadCommands(type) {
|
|
621
623
|
this.#data.commands = [];
|
|
622
624
|
await this.#buildCommands();
|
|
623
|
-
if (this.#data.
|
|
625
|
+
if (this.#data.bulkRegister) {
|
|
624
626
|
await loadCommandsWithRest({
|
|
625
627
|
client: this.#data.client,
|
|
626
628
|
devGuildIds: this.#data.devGuildIds,
|
|
@@ -641,6 +643,8 @@ var CommandHandler = class {
|
|
|
641
643
|
};
|
|
642
644
|
|
|
643
645
|
// src/handlers/event-handler/EventHandler.ts
|
|
646
|
+
var import_rfdc2 = __toESM(require("rfdc"));
|
|
647
|
+
var clone2 = (0, import_rfdc2.default)();
|
|
644
648
|
var EventHandler = class {
|
|
645
649
|
#data;
|
|
646
650
|
constructor({ ...options }) {
|
|
@@ -657,8 +661,9 @@ var EventHandler = class {
|
|
|
657
661
|
const eventFolderPaths = getFolderPaths(this.#data.eventsPath);
|
|
658
662
|
for (const eventFolderPath of eventFolderPaths) {
|
|
659
663
|
const eventName = eventFolderPath.replace(/\\\\|\\/g, "/").split("/").pop();
|
|
664
|
+
const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
|
|
660
665
|
const eventFilePaths = getFilePaths(eventFolderPath, true).filter(
|
|
661
|
-
(path3) =>
|
|
666
|
+
(path3) => allowedExtensions.test(path3)
|
|
662
667
|
);
|
|
663
668
|
const eventObj = {
|
|
664
669
|
name: eventName,
|
|
@@ -667,7 +672,11 @@ var EventHandler = class {
|
|
|
667
672
|
this.#data.events.push(eventObj);
|
|
668
673
|
for (const eventFilePath of eventFilePaths) {
|
|
669
674
|
const modulePath = toFileURL(eventFilePath);
|
|
670
|
-
let
|
|
675
|
+
let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
|
|
676
|
+
let eventFunction = clone2(importedFunction);
|
|
677
|
+
if (typeof module !== "undefined" && typeof require !== "undefined") {
|
|
678
|
+
delete require.cache[require.resolve(eventFilePath)];
|
|
679
|
+
}
|
|
671
680
|
if (eventFunction?.default) {
|
|
672
681
|
eventFunction = eventFunction.default;
|
|
673
682
|
}
|
|
@@ -701,9 +710,17 @@ var EventHandler = class {
|
|
|
701
710
|
get events() {
|
|
702
711
|
return this.#data.events;
|
|
703
712
|
}
|
|
713
|
+
async reloadEvents() {
|
|
714
|
+
await this.#buildEvents();
|
|
715
|
+
this.#data.events = [];
|
|
716
|
+
this.#data.client.removeAllListeners();
|
|
717
|
+
this.#registerEvents();
|
|
718
|
+
}
|
|
704
719
|
};
|
|
705
720
|
|
|
706
721
|
// src/handlers/validation-handler/ValidationHandler.ts
|
|
722
|
+
var import_rfdc3 = __toESM(require("rfdc"));
|
|
723
|
+
var clone3 = (0, import_rfdc3.default)();
|
|
707
724
|
var ValidationHandler = class {
|
|
708
725
|
#data;
|
|
709
726
|
constructor({ ...options }) {
|
|
@@ -716,12 +733,17 @@ var ValidationHandler = class {
|
|
|
716
733
|
await this.#buildValidations();
|
|
717
734
|
}
|
|
718
735
|
async #buildValidations() {
|
|
736
|
+
const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
|
|
719
737
|
const validationFilePaths = getFilePaths(this.#data.validationsPath, true).filter(
|
|
720
|
-
(path3) =>
|
|
738
|
+
(path3) => allowedExtensions.test(path3)
|
|
721
739
|
);
|
|
722
740
|
for (const validationFilePath of validationFilePaths) {
|
|
723
741
|
const modulePath = toFileURL(validationFilePath);
|
|
724
|
-
let
|
|
742
|
+
let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
|
|
743
|
+
let validationFunction = clone3(importedFunction);
|
|
744
|
+
if (typeof module !== "undefined" && typeof require !== "undefined") {
|
|
745
|
+
delete require.cache[require.resolve(validationFilePath)];
|
|
746
|
+
}
|
|
725
747
|
if (validationFunction?.default) {
|
|
726
748
|
validationFunction = validationFunction.default;
|
|
727
749
|
}
|
|
@@ -740,6 +762,10 @@ var ValidationHandler = class {
|
|
|
740
762
|
get validations() {
|
|
741
763
|
return this.#data.validations;
|
|
742
764
|
}
|
|
765
|
+
async reloadValidations() {
|
|
766
|
+
this.#data.validations = [];
|
|
767
|
+
await this.#buildValidations();
|
|
768
|
+
}
|
|
743
769
|
};
|
|
744
770
|
|
|
745
771
|
// src/CommandKit.ts
|
|
@@ -786,7 +812,7 @@ var CommandKit = class {
|
|
|
786
812
|
customValidations: validationFunctions,
|
|
787
813
|
skipBuiltInValidations: this.#data.skipBuiltInValidations || false,
|
|
788
814
|
handler: this,
|
|
789
|
-
|
|
815
|
+
bulkRegister: this.#data.bulkRegister || false
|
|
790
816
|
});
|
|
791
817
|
await commandHandler.init();
|
|
792
818
|
this.#data.commandHandler = commandHandler;
|
|
@@ -794,13 +820,28 @@ var CommandKit = class {
|
|
|
794
820
|
}
|
|
795
821
|
/**
|
|
796
822
|
* Updates application commands with the latest from "commandsPath".
|
|
797
|
-
* @experimental
|
|
798
823
|
*/
|
|
799
824
|
async reloadCommands(type) {
|
|
800
825
|
if (!this.#data.commandHandler)
|
|
801
826
|
return;
|
|
802
827
|
await this.#data.commandHandler.reloadCommands(type);
|
|
803
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* Updates application events with the latest from "eventsPath".
|
|
831
|
+
*/
|
|
832
|
+
async reloadEvents() {
|
|
833
|
+
if (!this.#data.eventHandler)
|
|
834
|
+
return;
|
|
835
|
+
await this.#data.eventHandler.reloadEvents();
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Updates application command validations with the latest from "validationsPath".
|
|
839
|
+
*/
|
|
840
|
+
async reloadValidations() {
|
|
841
|
+
if (!this.#data.validationHandler)
|
|
842
|
+
return;
|
|
843
|
+
await this.#data.validationHandler.reloadValidations();
|
|
844
|
+
}
|
|
804
845
|
/**
|
|
805
846
|
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
806
847
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -209,22 +209,20 @@ async function registerGlobalCommands(client, commands) {
|
|
|
209
209
|
)
|
|
210
210
|
);
|
|
211
211
|
} else {
|
|
212
|
-
targetCommand.delete().
|
|
212
|
+
await targetCommand.delete().catch((error) => {
|
|
213
213
|
console.log(
|
|
214
|
-
colors_default.
|
|
214
|
+
colors_default.red(`\u274C Failed to delete command "${command.data.name}" globally.`)
|
|
215
215
|
);
|
|
216
|
+
console.error(error);
|
|
216
217
|
});
|
|
218
|
+
console.log(colors_default.green(`\u{1F6AE} Deleted command "${command.data.name}" globally.`));
|
|
217
219
|
}
|
|
218
220
|
continue;
|
|
219
221
|
}
|
|
220
222
|
if (targetCommand) {
|
|
221
223
|
const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
|
|
222
224
|
if (commandsAreDifferent) {
|
|
223
|
-
targetCommand.edit(command.data).
|
|
224
|
-
console.log(
|
|
225
|
-
colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`)
|
|
226
|
-
);
|
|
227
|
-
}).catch((error) => {
|
|
225
|
+
await targetCommand.edit(command.data).catch((error) => {
|
|
228
226
|
console.log(
|
|
229
227
|
colors_default.red(
|
|
230
228
|
`\u274C Failed to edit command "${command.data.name}" globally.`
|
|
@@ -232,19 +230,19 @@ async function registerGlobalCommands(client, commands) {
|
|
|
232
230
|
);
|
|
233
231
|
console.error(error);
|
|
234
232
|
});
|
|
233
|
+
console.log(colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`));
|
|
235
234
|
continue;
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
237
|
if (targetCommand)
|
|
239
238
|
continue;
|
|
240
|
-
appCommandsManager.create(command.data).
|
|
241
|
-
console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`));
|
|
242
|
-
}).catch((error) => {
|
|
239
|
+
await appCommandsManager.create(command.data).catch((error) => {
|
|
243
240
|
console.log(
|
|
244
241
|
colors_default.red(`\u274C Failed to register command "${command.data.name}" globally.`)
|
|
245
242
|
);
|
|
246
243
|
console.error(error);
|
|
247
244
|
});
|
|
245
|
+
console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`));
|
|
248
246
|
}
|
|
249
247
|
}
|
|
250
248
|
async function registerDevCommands(client, commands, guildIds) {
|
|
@@ -278,26 +276,26 @@ async function registerDevCommands(client, commands, guildIds) {
|
|
|
278
276
|
)
|
|
279
277
|
);
|
|
280
278
|
} else {
|
|
281
|
-
targetCommand.delete().
|
|
279
|
+
await targetCommand.delete().catch((error) => {
|
|
282
280
|
console.log(
|
|
283
|
-
colors_default.
|
|
284
|
-
`\
|
|
281
|
+
colors_default.red(
|
|
282
|
+
`\u274C Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
285
283
|
)
|
|
286
284
|
);
|
|
285
|
+
console.error(error);
|
|
287
286
|
});
|
|
287
|
+
console.log(
|
|
288
|
+
colors_default.green(
|
|
289
|
+
`\u{1F6AE} Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
290
|
+
)
|
|
291
|
+
);
|
|
288
292
|
}
|
|
289
293
|
continue;
|
|
290
294
|
}
|
|
291
295
|
if (targetCommand) {
|
|
292
296
|
const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
|
|
293
297
|
if (commandsAreDifferent) {
|
|
294
|
-
targetCommand.edit(command.data).
|
|
295
|
-
console.log(
|
|
296
|
-
colors_default.green(
|
|
297
|
-
`\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
298
|
-
)
|
|
299
|
-
);
|
|
300
|
-
}).catch((error) => {
|
|
298
|
+
await targetCommand.edit(command.data).catch((error) => {
|
|
301
299
|
console.log(
|
|
302
300
|
colors_default.red(
|
|
303
301
|
`\u274C Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
@@ -305,18 +303,17 @@ async function registerDevCommands(client, commands, guildIds) {
|
|
|
305
303
|
);
|
|
306
304
|
console.error(error);
|
|
307
305
|
});
|
|
306
|
+
console.log(
|
|
307
|
+
colors_default.green(
|
|
308
|
+
`\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
309
|
+
)
|
|
310
|
+
);
|
|
308
311
|
continue;
|
|
309
312
|
}
|
|
310
313
|
}
|
|
311
314
|
if (targetCommand)
|
|
312
315
|
continue;
|
|
313
|
-
guildCommands.create(command.data).
|
|
314
|
-
console.log(
|
|
315
|
-
colors_default.green(
|
|
316
|
-
`\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
317
|
-
)
|
|
318
|
-
);
|
|
319
|
-
}).catch((error) => {
|
|
316
|
+
await guildCommands.create(command.data).catch((error) => {
|
|
320
317
|
console.log(
|
|
321
318
|
colors_default.red(
|
|
322
319
|
`\u274C Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
@@ -324,6 +321,11 @@ async function registerDevCommands(client, commands, guildIds) {
|
|
|
324
321
|
);
|
|
325
322
|
console.error(error);
|
|
326
323
|
});
|
|
324
|
+
console.log(
|
|
325
|
+
colors_default.green(
|
|
326
|
+
`\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
|
|
327
|
+
)
|
|
328
|
+
);
|
|
327
329
|
}
|
|
328
330
|
}
|
|
329
331
|
}
|
|
@@ -455,7 +457,7 @@ var CommandHandler = class {
|
|
|
455
457
|
)
|
|
456
458
|
);
|
|
457
459
|
}
|
|
458
|
-
if (this.#data.
|
|
460
|
+
if (this.#data.bulkRegister) {
|
|
459
461
|
await loadCommandsWithRest({
|
|
460
462
|
client: this.#data.client,
|
|
461
463
|
devGuildIds: this.#data.devGuildIds,
|
|
@@ -590,7 +592,7 @@ var CommandHandler = class {
|
|
|
590
592
|
async reloadCommands(type) {
|
|
591
593
|
this.#data.commands = [];
|
|
592
594
|
await this.#buildCommands();
|
|
593
|
-
if (this.#data.
|
|
595
|
+
if (this.#data.bulkRegister) {
|
|
594
596
|
await loadCommandsWithRest({
|
|
595
597
|
client: this.#data.client,
|
|
596
598
|
devGuildIds: this.#data.devGuildIds,
|
|
@@ -611,6 +613,8 @@ var CommandHandler = class {
|
|
|
611
613
|
};
|
|
612
614
|
|
|
613
615
|
// src/handlers/event-handler/EventHandler.ts
|
|
616
|
+
import rdfc2 from "rfdc";
|
|
617
|
+
var clone2 = rdfc2();
|
|
614
618
|
var EventHandler = class {
|
|
615
619
|
#data;
|
|
616
620
|
constructor({ ...options }) {
|
|
@@ -627,8 +631,9 @@ var EventHandler = class {
|
|
|
627
631
|
const eventFolderPaths = getFolderPaths(this.#data.eventsPath);
|
|
628
632
|
for (const eventFolderPath of eventFolderPaths) {
|
|
629
633
|
const eventName = eventFolderPath.replace(/\\\\|\\/g, "/").split("/").pop();
|
|
634
|
+
const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
|
|
630
635
|
const eventFilePaths = getFilePaths(eventFolderPath, true).filter(
|
|
631
|
-
(path3) =>
|
|
636
|
+
(path3) => allowedExtensions.test(path3)
|
|
632
637
|
);
|
|
633
638
|
const eventObj = {
|
|
634
639
|
name: eventName,
|
|
@@ -637,7 +642,11 @@ var EventHandler = class {
|
|
|
637
642
|
this.#data.events.push(eventObj);
|
|
638
643
|
for (const eventFilePath of eventFilePaths) {
|
|
639
644
|
const modulePath = toFileURL(eventFilePath);
|
|
640
|
-
let
|
|
645
|
+
let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
|
|
646
|
+
let eventFunction = clone2(importedFunction);
|
|
647
|
+
if (typeof module !== "undefined" && typeof __require !== "undefined") {
|
|
648
|
+
delete __require.cache[__require.resolve(eventFilePath)];
|
|
649
|
+
}
|
|
641
650
|
if (eventFunction?.default) {
|
|
642
651
|
eventFunction = eventFunction.default;
|
|
643
652
|
}
|
|
@@ -671,9 +680,17 @@ var EventHandler = class {
|
|
|
671
680
|
get events() {
|
|
672
681
|
return this.#data.events;
|
|
673
682
|
}
|
|
683
|
+
async reloadEvents() {
|
|
684
|
+
await this.#buildEvents();
|
|
685
|
+
this.#data.events = [];
|
|
686
|
+
this.#data.client.removeAllListeners();
|
|
687
|
+
this.#registerEvents();
|
|
688
|
+
}
|
|
674
689
|
};
|
|
675
690
|
|
|
676
691
|
// src/handlers/validation-handler/ValidationHandler.ts
|
|
692
|
+
import rdfc3 from "rfdc";
|
|
693
|
+
var clone3 = rdfc3();
|
|
677
694
|
var ValidationHandler = class {
|
|
678
695
|
#data;
|
|
679
696
|
constructor({ ...options }) {
|
|
@@ -686,12 +703,17 @@ var ValidationHandler = class {
|
|
|
686
703
|
await this.#buildValidations();
|
|
687
704
|
}
|
|
688
705
|
async #buildValidations() {
|
|
706
|
+
const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
|
|
689
707
|
const validationFilePaths = getFilePaths(this.#data.validationsPath, true).filter(
|
|
690
|
-
(path3) =>
|
|
708
|
+
(path3) => allowedExtensions.test(path3)
|
|
691
709
|
);
|
|
692
710
|
for (const validationFilePath of validationFilePaths) {
|
|
693
711
|
const modulePath = toFileURL(validationFilePath);
|
|
694
|
-
let
|
|
712
|
+
let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
|
|
713
|
+
let validationFunction = clone3(importedFunction);
|
|
714
|
+
if (typeof module !== "undefined" && typeof __require !== "undefined") {
|
|
715
|
+
delete __require.cache[__require.resolve(validationFilePath)];
|
|
716
|
+
}
|
|
695
717
|
if (validationFunction?.default) {
|
|
696
718
|
validationFunction = validationFunction.default;
|
|
697
719
|
}
|
|
@@ -710,6 +732,10 @@ var ValidationHandler = class {
|
|
|
710
732
|
get validations() {
|
|
711
733
|
return this.#data.validations;
|
|
712
734
|
}
|
|
735
|
+
async reloadValidations() {
|
|
736
|
+
this.#data.validations = [];
|
|
737
|
+
await this.#buildValidations();
|
|
738
|
+
}
|
|
713
739
|
};
|
|
714
740
|
|
|
715
741
|
// src/CommandKit.ts
|
|
@@ -756,7 +782,7 @@ var CommandKit = class {
|
|
|
756
782
|
customValidations: validationFunctions,
|
|
757
783
|
skipBuiltInValidations: this.#data.skipBuiltInValidations || false,
|
|
758
784
|
handler: this,
|
|
759
|
-
|
|
785
|
+
bulkRegister: this.#data.bulkRegister || false
|
|
760
786
|
});
|
|
761
787
|
await commandHandler.init();
|
|
762
788
|
this.#data.commandHandler = commandHandler;
|
|
@@ -764,13 +790,28 @@ var CommandKit = class {
|
|
|
764
790
|
}
|
|
765
791
|
/**
|
|
766
792
|
* Updates application commands with the latest from "commandsPath".
|
|
767
|
-
* @experimental
|
|
768
793
|
*/
|
|
769
794
|
async reloadCommands(type) {
|
|
770
795
|
if (!this.#data.commandHandler)
|
|
771
796
|
return;
|
|
772
797
|
await this.#data.commandHandler.reloadCommands(type);
|
|
773
798
|
}
|
|
799
|
+
/**
|
|
800
|
+
* Updates application events with the latest from "eventsPath".
|
|
801
|
+
*/
|
|
802
|
+
async reloadEvents() {
|
|
803
|
+
if (!this.#data.eventHandler)
|
|
804
|
+
return;
|
|
805
|
+
await this.#data.eventHandler.reloadEvents();
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Updates application command validations with the latest from "validationsPath".
|
|
809
|
+
*/
|
|
810
|
+
async reloadValidations() {
|
|
811
|
+
if (!this.#data.validationHandler)
|
|
812
|
+
return;
|
|
813
|
+
await this.#data.validationHandler.reloadValidations();
|
|
814
|
+
}
|
|
774
815
|
/**
|
|
775
816
|
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
776
817
|
*/
|
package/package.json
CHANGED