commandkit 0.1.6-dev.20231004121943 → 0.1.6-dev.20231006183935

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/README.md CHANGED
@@ -99,8 +99,11 @@ new CommandKit({
99
99
  // Array of developer role IDs (used for devOnly commands)
100
100
  devRoleIds: ['1234567890', '0987654321'],
101
101
 
102
- // A property that disables CommandKit's built-in validations
102
+ // Disable CommandKit's built-in validations
103
103
  skipBuiltInValidations: true,
104
+
105
+ // Update command registration/reload behaviour to register all commands at once
106
+ bulkRegister: true,
104
107
  });
105
108
 
106
109
  client.login('YOUR_TOKEN_HERE');
package/dist/index.d.mts CHANGED
@@ -34,7 +34,7 @@ declare enum CommandType {
34
34
  'Message' = 3,
35
35
  'User' = 2
36
36
  }
37
- type LocaleString = 'id' | 'en-US' | 'en-GB' | 'bg' | 'zh-CN' | 'zh-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';
37
+ 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';
38
38
  type BaseCommandData = {
39
39
  name: string;
40
40
  type?: CommandType;
@@ -61,8 +61,8 @@ type CommandObject = {
61
61
  [key: string]: any;
62
62
  };
63
63
  declare enum ReloadType {
64
- 'Developer' = "dev",
65
- 'Global' = "global"
64
+ Developer = "dev",
65
+ Global = "global"
66
66
  }
67
67
 
68
68
  interface CommandKitOptions {
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@ declare enum CommandType {
34
34
  'Message' = 3,
35
35
  'User' = 2
36
36
  }
37
- type LocaleString = 'id' | 'en-US' | 'en-GB' | 'bg' | 'zh-CN' | 'zh-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';
37
+ 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';
38
38
  type BaseCommandData = {
39
39
  name: string;
40
40
  type?: CommandType;
@@ -61,8 +61,8 @@ type CommandObject = {
61
61
  [key: string]: any;
62
62
  };
63
63
  declare enum ReloadType {
64
- 'Developer' = "dev",
65
- 'Global' = "global"
64
+ Developer = "dev",
65
+ Global = "global"
66
66
  }
67
67
 
68
68
  interface CommandKitOptions {
package/dist/index.js CHANGED
@@ -38,34 +38,34 @@ module.exports = __toCommonJS(src_exports);
38
38
 
39
39
  // src/utils/get-paths.ts
40
40
  var import_path = __toESM(require("path"));
41
- var import_fs = __toESM(require("fs"));
42
- function getFilePaths(directory, nesting) {
41
+ var import_promises = __toESM(require("fs/promises"));
42
+ async function getFilePaths(directory, nesting) {
43
43
  let filePaths = [];
44
44
  if (!directory)
45
45
  return filePaths;
46
- const files = import_fs.default.readdirSync(directory, { withFileTypes: true });
46
+ const files = await import_promises.default.readdir(directory, { withFileTypes: true });
47
47
  for (const file of files) {
48
48
  const filePath = import_path.default.join(directory, file.name);
49
49
  if (file.isFile()) {
50
50
  filePaths.push(filePath);
51
51
  }
52
52
  if (nesting && file.isDirectory()) {
53
- filePaths = [...filePaths, ...getFilePaths(filePath, true)];
53
+ filePaths = [...filePaths, ...await getFilePaths(filePath, true)];
54
54
  }
55
55
  }
56
56
  return filePaths;
57
57
  }
58
- function getFolderPaths(directory, nesting) {
58
+ async function getFolderPaths(directory, nesting) {
59
59
  let folderPaths = [];
60
60
  if (!directory)
61
61
  return folderPaths;
62
- const folders = import_fs.default.readdirSync(directory, { withFileTypes: true });
62
+ const folders = await import_promises.default.readdir(directory, { withFileTypes: true });
63
63
  for (const folder of folders) {
64
64
  const folderPath = import_path.default.join(directory, folder.name);
65
65
  if (folder.isDirectory()) {
66
66
  folderPaths.push(folderPath);
67
67
  if (nesting) {
68
- folderPaths = [...folderPaths, ...getFolderPaths(folderPath, true)];
68
+ folderPaths = [...folderPaths, ...await getFolderPaths(folderPath, true)];
69
69
  }
70
70
  }
71
71
  }
@@ -505,9 +505,8 @@ var CommandHandler = class {
505
505
  }
506
506
  async #buildCommands() {
507
507
  const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
508
- const commandFilePaths = getFilePaths(this.#data.commandsPath, true).filter(
509
- (path3) => allowedExtensions.test(path3)
510
- );
508
+ const paths = await getFilePaths(this.#data.commandsPath, true);
509
+ const commandFilePaths = paths.filter((path3) => allowedExtensions.test(path3));
511
510
  for (const commandFilePath of commandFilePaths) {
512
511
  const modulePath = toFileURL(commandFilePath);
513
512
  let importedObj = await import(`${modulePath}?t=${Date.now()}`);
@@ -669,13 +668,12 @@ var EventHandler = class {
669
668
  this.#registerEvents();
670
669
  }
671
670
  async #buildEvents() {
672
- const eventFolderPaths = getFolderPaths(this.#data.eventsPath);
671
+ const eventFolderPaths = await getFolderPaths(this.#data.eventsPath);
673
672
  for (const eventFolderPath of eventFolderPaths) {
674
673
  const eventName = eventFolderPath.replace(/\\\\|\\/g, "/").split("/").pop();
675
674
  const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
676
- const eventFilePaths = getFilePaths(eventFolderPath, true).filter(
677
- (path3) => allowedExtensions.test(path3)
678
- );
675
+ const eventPaths = await getFilePaths(eventFolderPath, true);
676
+ const eventFilePaths = eventPaths.filter((path3) => allowedExtensions.test(path3));
679
677
  const eventObj = {
680
678
  name: eventName,
681
679
  functions: []
@@ -746,9 +744,8 @@ var ValidationHandler = class {
746
744
  }
747
745
  async #buildValidations() {
748
746
  const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
749
- const validationFilePaths = getFilePaths(this.#data.validationsPath, true).filter(
750
- (path3) => allowedExtensions.test(path3)
751
- );
747
+ const validationPaths = await getFilePaths(this.#data.validationsPath, true);
748
+ const validationFilePaths = validationPaths.filter((path3) => allowedExtensions.test(path3));
752
749
  for (const validationFilePath of validationFilePaths) {
753
750
  const modulePath = toFileURL(validationFilePath);
754
751
  let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
package/dist/index.mjs CHANGED
@@ -8,34 +8,34 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
 
9
9
  // src/utils/get-paths.ts
10
10
  import path from "path";
11
- import fs from "fs";
12
- function getFilePaths(directory, nesting) {
11
+ import fs from "fs/promises";
12
+ async function getFilePaths(directory, nesting) {
13
13
  let filePaths = [];
14
14
  if (!directory)
15
15
  return filePaths;
16
- const files = fs.readdirSync(directory, { withFileTypes: true });
16
+ const files = await fs.readdir(directory, { withFileTypes: true });
17
17
  for (const file of files) {
18
18
  const filePath = path.join(directory, file.name);
19
19
  if (file.isFile()) {
20
20
  filePaths.push(filePath);
21
21
  }
22
22
  if (nesting && file.isDirectory()) {
23
- filePaths = [...filePaths, ...getFilePaths(filePath, true)];
23
+ filePaths = [...filePaths, ...await getFilePaths(filePath, true)];
24
24
  }
25
25
  }
26
26
  return filePaths;
27
27
  }
28
- function getFolderPaths(directory, nesting) {
28
+ async function getFolderPaths(directory, nesting) {
29
29
  let folderPaths = [];
30
30
  if (!directory)
31
31
  return folderPaths;
32
- const folders = fs.readdirSync(directory, { withFileTypes: true });
32
+ const folders = await fs.readdir(directory, { withFileTypes: true });
33
33
  for (const folder of folders) {
34
34
  const folderPath = path.join(directory, folder.name);
35
35
  if (folder.isDirectory()) {
36
36
  folderPaths.push(folderPath);
37
37
  if (nesting) {
38
- folderPaths = [...folderPaths, ...getFolderPaths(folderPath, true)];
38
+ folderPaths = [...folderPaths, ...await getFolderPaths(folderPath, true)];
39
39
  }
40
40
  }
41
41
  }
@@ -475,9 +475,8 @@ var CommandHandler = class {
475
475
  }
476
476
  async #buildCommands() {
477
477
  const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
478
- const commandFilePaths = getFilePaths(this.#data.commandsPath, true).filter(
479
- (path3) => allowedExtensions.test(path3)
480
- );
478
+ const paths = await getFilePaths(this.#data.commandsPath, true);
479
+ const commandFilePaths = paths.filter((path3) => allowedExtensions.test(path3));
481
480
  for (const commandFilePath of commandFilePaths) {
482
481
  const modulePath = toFileURL(commandFilePath);
483
482
  let importedObj = await import(`${modulePath}?t=${Date.now()}`);
@@ -639,13 +638,12 @@ var EventHandler = class {
639
638
  this.#registerEvents();
640
639
  }
641
640
  async #buildEvents() {
642
- const eventFolderPaths = getFolderPaths(this.#data.eventsPath);
641
+ const eventFolderPaths = await getFolderPaths(this.#data.eventsPath);
643
642
  for (const eventFolderPath of eventFolderPaths) {
644
643
  const eventName = eventFolderPath.replace(/\\\\|\\/g, "/").split("/").pop();
645
644
  const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
646
- const eventFilePaths = getFilePaths(eventFolderPath, true).filter(
647
- (path3) => allowedExtensions.test(path3)
648
- );
645
+ const eventPaths = await getFilePaths(eventFolderPath, true);
646
+ const eventFilePaths = eventPaths.filter((path3) => allowedExtensions.test(path3));
649
647
  const eventObj = {
650
648
  name: eventName,
651
649
  functions: []
@@ -716,9 +714,8 @@ var ValidationHandler = class {
716
714
  }
717
715
  async #buildValidations() {
718
716
  const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
719
- const validationFilePaths = getFilePaths(this.#data.validationsPath, true).filter(
720
- (path3) => allowedExtensions.test(path3)
721
- );
717
+ const validationPaths = await getFilePaths(this.#data.validationsPath, true);
718
+ const validationFilePaths = validationPaths.filter((path3) => allowedExtensions.test(path3));
722
719
  for (const validationFilePath of validationFilePaths) {
723
720
  const modulePath = toFileURL(validationFilePath);
724
721
  let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "commandkit",
3
3
  "description": "Beginner friendly command & event handler for Discord.js",
4
- "version": "0.1.6-dev.20231004121943",
4
+ "version": "0.1.6-dev.20231006183935",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",