trivious 1.3.17 → 1.3.18

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.
Files changed (129) hide show
  1. package/dist/core/client/trivious.client.cjs +90 -0
  2. package/dist/core/client/trivious.client.cjs.map +1 -0
  3. package/dist/core/client/trivious.client.d.cts +3 -0
  4. package/dist/core/client/trivious.client.d.ts +3 -0
  5. package/dist/core/client/trivious.client.js +88 -0
  6. package/dist/core/client/trivious.client.js.map +1 -0
  7. package/dist/core/commands/command.base.cjs +224 -0
  8. package/dist/core/commands/command.base.cjs.map +1 -0
  9. package/dist/core/commands/command.base.d.cts +3 -0
  10. package/dist/core/commands/command.base.d.ts +3 -0
  11. package/dist/core/commands/command.base.js +214 -0
  12. package/dist/core/commands/command.base.js.map +1 -0
  13. package/dist/core/commands/contextcommand.base.cjs +98 -0
  14. package/dist/core/commands/contextcommand.base.cjs.map +1 -0
  15. package/dist/core/commands/contextcommand.base.d.cts +3 -0
  16. package/dist/core/commands/contextcommand.base.d.ts +3 -0
  17. package/dist/core/commands/contextcommand.base.js +93 -0
  18. package/dist/core/commands/contextcommand.base.js.map +1 -0
  19. package/dist/core/commands/subcommand.base.cjs +96 -0
  20. package/dist/core/commands/subcommand.base.cjs.map +1 -0
  21. package/dist/core/commands/subcommand.base.d.cts +3 -0
  22. package/dist/core/commands/subcommand.base.d.ts +3 -0
  23. package/dist/core/commands/subcommand.base.js +91 -0
  24. package/dist/core/commands/subcommand.base.js.map +1 -0
  25. package/dist/core/components/component.base.cjs +111 -0
  26. package/dist/core/components/component.base.cjs.map +1 -0
  27. package/dist/core/components/component.base.d.cts +3 -0
  28. package/dist/core/components/component.base.d.ts +3 -0
  29. package/dist/core/components/component.base.js +106 -0
  30. package/dist/core/components/component.base.js.map +1 -0
  31. package/dist/core/events/interactionCreate.cjs +68 -0
  32. package/dist/core/events/interactionCreate.cjs.map +1 -0
  33. package/dist/core/events/interactionCreate.d.cts +10 -0
  34. package/dist/core/events/interactionCreate.d.ts +10 -0
  35. package/dist/core/events/interactionCreate.js +66 -0
  36. package/dist/core/events/interactionCreate.js.map +1 -0
  37. package/dist/core/registry/command.registry.cjs +56 -0
  38. package/dist/core/registry/command.registry.cjs.map +1 -0
  39. package/dist/core/registry/command.registry.d.cts +3 -0
  40. package/dist/core/registry/command.registry.d.ts +3 -0
  41. package/dist/core/registry/command.registry.js +54 -0
  42. package/dist/core/registry/command.registry.js.map +1 -0
  43. package/dist/core/registry/component.registry.cjs +42 -0
  44. package/dist/core/registry/component.registry.cjs.map +1 -0
  45. package/dist/core/registry/component.registry.d.cts +3 -0
  46. package/dist/core/registry/component.registry.d.ts +3 -0
  47. package/dist/core/registry/component.registry.js +40 -0
  48. package/dist/core/registry/component.registry.js.map +1 -0
  49. package/dist/core/registry/event.registry.cjs +57 -0
  50. package/dist/core/registry/event.registry.cjs.map +1 -0
  51. package/dist/core/registry/event.registry.d.cts +3 -0
  52. package/dist/core/registry/event.registry.d.ts +3 -0
  53. package/dist/core/registry/event.registry.js +51 -0
  54. package/dist/core/registry/event.registry.js.map +1 -0
  55. package/dist/core/registry/index.cjs +49 -0
  56. package/dist/core/registry/index.cjs.map +1 -0
  57. package/dist/core/registry/index.d.cts +19 -0
  58. package/dist/core/registry/index.d.ts +19 -0
  59. package/dist/core/registry/index.js +39 -0
  60. package/dist/core/registry/index.js.map +1 -0
  61. package/dist/core/registry/module.registry.cjs +57 -0
  62. package/dist/core/registry/module.registry.cjs.map +1 -0
  63. package/dist/core/registry/module.registry.d.cts +3 -0
  64. package/dist/core/registry/module.registry.d.ts +3 -0
  65. package/dist/core/registry/module.registry.js +55 -0
  66. package/dist/core/registry/module.registry.js.map +1 -0
  67. package/dist/index-BCF4f686.d.cts +927 -0
  68. package/dist/index-uczj1Waw.d.ts +927 -0
  69. package/dist/index.cjs +67 -1446
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.d.cts +2 -974
  72. package/dist/index.d.ts +2 -974
  73. package/dist/index.js +10 -1436
  74. package/dist/index.js.map +1 -1
  75. package/dist/shared/typings/client.cjs +4 -0
  76. package/dist/shared/typings/client.cjs.map +1 -0
  77. package/dist/shared/typings/client.d.cts +3 -0
  78. package/dist/shared/typings/client.d.ts +3 -0
  79. package/dist/shared/typings/client.js +3 -0
  80. package/dist/shared/typings/client.js.map +1 -0
  81. package/dist/shared/typings/commands.cjs +4 -0
  82. package/dist/shared/typings/commands.cjs.map +1 -0
  83. package/dist/shared/typings/commands.d.cts +3 -0
  84. package/dist/shared/typings/commands.d.ts +3 -0
  85. package/dist/shared/typings/commands.js +3 -0
  86. package/dist/shared/typings/commands.js.map +1 -0
  87. package/dist/shared/typings/components.cjs +22 -0
  88. package/dist/shared/typings/components.cjs.map +1 -0
  89. package/dist/shared/typings/components.d.cts +3 -0
  90. package/dist/shared/typings/components.d.ts +3 -0
  91. package/dist/shared/typings/components.js +19 -0
  92. package/dist/shared/typings/components.js.map +1 -0
  93. package/dist/shared/typings/events.cjs +4 -0
  94. package/dist/shared/typings/events.cjs.map +1 -0
  95. package/dist/shared/typings/events.d.cts +3 -0
  96. package/dist/shared/typings/events.d.ts +3 -0
  97. package/dist/shared/typings/events.js +3 -0
  98. package/dist/shared/typings/events.js.map +1 -0
  99. package/dist/shared/typings/index.cjs +56 -0
  100. package/dist/shared/typings/index.cjs.map +1 -0
  101. package/dist/shared/typings/index.d.cts +3 -0
  102. package/dist/shared/typings/index.d.ts +3 -0
  103. package/dist/shared/typings/index.js +9 -0
  104. package/dist/shared/typings/index.js.map +1 -0
  105. package/dist/shared/typings/module.cjs +4 -0
  106. package/dist/shared/typings/module.cjs.map +1 -0
  107. package/dist/shared/typings/module.d.cts +3 -0
  108. package/dist/shared/typings/module.d.ts +3 -0
  109. package/dist/shared/typings/module.js +3 -0
  110. package/dist/shared/typings/module.js.map +1 -0
  111. package/dist/shared/typings/permissions.cjs +22 -0
  112. package/dist/shared/typings/permissions.cjs.map +1 -0
  113. package/dist/shared/typings/permissions.d.cts +3 -0
  114. package/dist/shared/typings/permissions.d.ts +3 -0
  115. package/dist/shared/typings/permissions.js +19 -0
  116. package/dist/shared/typings/permissions.js.map +1 -0
  117. package/dist/shared/typings/registry.cjs +63 -0
  118. package/dist/shared/typings/registry.cjs.map +1 -0
  119. package/dist/shared/typings/registry.d.cts +51 -0
  120. package/dist/shared/typings/registry.d.ts +51 -0
  121. package/dist/shared/typings/registry.js +61 -0
  122. package/dist/shared/typings/registry.js.map +1 -0
  123. package/dist/shared/utility/functions.cjs +81 -0
  124. package/dist/shared/utility/functions.cjs.map +1 -0
  125. package/dist/shared/utility/functions.d.cts +56 -0
  126. package/dist/shared/utility/functions.d.ts +56 -0
  127. package/dist/shared/utility/functions.js +74 -0
  128. package/dist/shared/utility/functions.js.map +1 -0
  129. package/package.json +2 -2
@@ -0,0 +1,51 @@
1
+ import { Collection } from 'discord.js';
2
+ import { getCorePath, exists } from 'src/shared/utility/functions.js';
3
+ import { BaseRegistry } from 'src/shared/typings/index.js';
4
+ import { promises } from 'fs';
5
+ import { join } from 'node:path';
6
+ import interactionCreate from '../events/interactionCreate.js';
7
+
8
+ class EventRegistry extends BaseRegistry {
9
+ items = new Collection();
10
+ /**
11
+ * Load all events.
12
+ *
13
+ * @async
14
+ * @param {string} [directory=getCorePath({ coreDirectory: "events" })]
15
+ * @returns {Promise<this>}
16
+ */
17
+ async load(directory = getCorePath({ coreDirectory: "events" })) {
18
+ if (!await exists(directory)) return this;
19
+ const entries = await promises.readdir(directory, { withFileTypes: true });
20
+ for (const entry of entries) {
21
+ const fullPath = join(directory, entry.name);
22
+ if (entry.isDirectory()) {
23
+ await this.load(fullPath);
24
+ continue;
25
+ }
26
+ if (entry.isFile() && entry.name.endsWith(".js")) {
27
+ const event = await this.importFile(fullPath);
28
+ if (!event) continue;
29
+ this.items.set(event.name, event);
30
+ }
31
+ }
32
+ this.items.set(interactionCreate.name, interactionCreate);
33
+ return this;
34
+ }
35
+ /**
36
+ * Bind loaded events to their client events respectively.
37
+ *
38
+ * @param {TriviousClient} client
39
+ */
40
+ bind(client) {
41
+ for (const event of this.items.values()) {
42
+ const handler = (...args) => void event.execute(client, ...args);
43
+ if (event.once) client.once(event.name, handler);
44
+ else client.on(event.name, handler);
45
+ }
46
+ }
47
+ }
48
+
49
+ export { EventRegistry as default };
50
+ //# sourceMappingURL=event.registry.js.map
51
+ //# sourceMappingURL=event.registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/registry/event.registry.ts"],"names":["fs"],"mappings":";;;;;;;AAgBA,MAAO,sBAAoC,YAAA,CAAoB;AAAA,EACpD,KAAA,GAAQ,IAAI,UAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShD,MAAM,KAAK,SAAA,GAAoB,WAAA,CAAY,EAAE,aAAA,EAAe,QAAA,EAAU,CAAA,EAAkB;AACvF,IAAA,IAAI,CAAE,MAAM,MAAA,CAAO,SAAS,GAAI,OAAO,IAAA;AAEvC,IAAA,MAAM,OAAA,GAAU,MAAMA,QAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AACnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAE3C,MAAA,IAAI,KAAA,CAAM,aAAY,EAAG;AACxB,QAAA,MAAM,IAAA,CAAK,KAAK,QAAQ,CAAA;AACxB,QAAA;AAAA,MACD;AAEA,MAAA,IAAI,MAAM,MAAA,EAAO,IAAK,MAAM,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,EAAG;AACjD,QAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,UAAA,CAAkB,QAAQ,CAAA;AACnD,QAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,QAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,KAAA,CAAM,IAAA,EAAM,KAAK,CAAA;AAAA,MACjC;AAAA,IACD;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,iBAAA,CAAkB,IAAA,EAAM,iBAA0B,CAAA;AACjE,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,MAAA,EAAwB;AAC5B,IAAA,KAAA,MAAW,KAAA,IAAS,IAAA,CAAK,KAAA,CAAM,MAAA,EAAO,EAAG;AACxC,MAAA,MAAM,OAAA,GAAU,IAAI,IAAA,KACnB,KAAK,MAAM,OAAA,CAAQ,MAAA,EAAQ,GAAG,IAAI,CAAA;AAEnC,MAAA,IAAI,MAAM,IAAA,EAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,MAAM,OAAO,CAAA;AAAA,WAC1C,MAAA,CAAO,EAAA,CAAG,KAAA,CAAM,IAAA,EAAM,OAAO,CAAA;AAAA,IACnC;AAAA,EACD;AACD","file":"event.registry.js","sourcesContent":["import { ClientEvents, Collection } from \"discord.js\";\nimport { exists, getCorePath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Event } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.js\";\nimport interactionCreate from \"../events/interactionCreate.js\";\n\n/**\n * Registry to load, get and bind events.\n *\n * @export\n * @class EventRegistry\n * @typedef {EventRegistry}\n * @extends {BaseRegistry<Event>}\n */\nexport default class EventRegistry extends BaseRegistry<Event> {\n\tprotected items = new Collection<string, Event>();\n\n\t/**\n\t * Load all events.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"events\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = getCorePath({ coreDirectory: \"events\" })): Promise<this> {\n\t\tif (!(await exists(directory))) return this;\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait this.load(fullPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isFile() && entry.name.endsWith(\".js\")) {\n\t\t\t\tconst event = await this.importFile<Event>(fullPath);\n\t\t\t\tif (!event) continue;\n\n\t\t\t\tthis.items.set(event.name, event);\n\t\t\t}\n\t\t}\n\n\t\tthis.items.set(interactionCreate.name, interactionCreate as Event);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Bind loaded events to their client events respectively.\n\t *\n\t * @param {TriviousClient} client\n\t */\n\tbind(client: TriviousClient) {\n\t\tfor (const event of this.items.values()) {\n\t\t\tconst handler = (...args: ClientEvents[typeof event.name]) =>\n\t\t\t\tvoid event.execute(client, ...args);\n\n\t\t\tif (event.once) client.once(event.name, handler);\n\t\t\telse client.on(event.name, handler);\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var functions_js = require('src/shared/utility/functions.js');
4
+ var CommandRegistry = require('./command.registry.js');
5
+ var ComponentRegistry = require('./component.registry.js');
6
+ var EventRegistry = require('./event.registry.js');
7
+ var ModuleRegistry = require('./module.registry.js');
8
+ var path = require('node:path');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var CommandRegistry__default = /*#__PURE__*/_interopDefault(CommandRegistry);
13
+ var ComponentRegistry__default = /*#__PURE__*/_interopDefault(ComponentRegistry);
14
+ var EventRegistry__default = /*#__PURE__*/_interopDefault(EventRegistry);
15
+ var ModuleRegistry__default = /*#__PURE__*/_interopDefault(ModuleRegistry);
16
+ var path__default = /*#__PURE__*/_interopDefault(path);
17
+
18
+ const registries = () => ({
19
+ commands: new CommandRegistry__default.default(),
20
+ components: new ComponentRegistry__default.default(),
21
+ events: new EventRegistry__default.default(),
22
+ modules: new ModuleRegistry__default.default(),
23
+ async loadAll(options) {
24
+ const corePaths = options.corePaths;
25
+ const corePath = options.corePath;
26
+ await Promise.all([
27
+ this.commands.load(
28
+ corePath ? functions_js.resolveUserPath(path__default.default.join(corePath, "commands")) : corePaths?.commandsPath ? functions_js.resolveUserPath(corePaths.commandsPath) : void 0
29
+ ),
30
+ this.components.load(
31
+ corePath ? functions_js.resolveUserPath(path__default.default.join(corePath, "components")) : corePaths?.componentsPath ? functions_js.resolveUserPath(corePaths.componentsPath) : void 0
32
+ ),
33
+ this.events.load(
34
+ corePath ? functions_js.resolveUserPath(path__default.default.join(corePath, "events")) : corePaths?.eventsPath ? functions_js.resolveUserPath(corePaths.eventsPath) : void 0
35
+ ),
36
+ this.modules.load(
37
+ corePath ? functions_js.resolveUserPath(path__default.default.join(corePath, "modules")) : corePaths?.modulesPath ? functions_js.resolveUserPath(corePaths.modulesPath) : void 0
38
+ )
39
+ ]);
40
+ },
41
+ bind(client) {
42
+ this.events.bind(client);
43
+ this.modules.bind(client);
44
+ }
45
+ });
46
+
47
+ exports.registries = registries;
48
+ //# sourceMappingURL=index.cjs.map
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/registry/index.ts"],"names":["CommandRegistry","ComponentRegistry","EventRegistry","ModuleRegistry","resolveUserPath","path"],"mappings":";;;;;;;;;;;;;;;;;AAcO,MAAM,aAAa,OAAO;AAAA,EAChC,QAAA,EAAU,IAAIA,gCAAA,EAAgB;AAAA,EAC9B,UAAA,EAAY,IAAIC,kCAAA,EAAkB;AAAA,EAClC,MAAA,EAAQ,IAAIC,8BAAA,EAAc;AAAA,EAC1B,OAAA,EAAS,IAAIC,+BAAA,EAAe;AAAA,EAE5B,MAAM,QAAQ,OAAA,EAAgC;AAC7C,IAAA,MAAM,YAAY,OAAA,CAAQ,SAAA;AAC1B,IAAA,MAAM,WAAW,OAAA,CAAQ,QAAA;AAEzB,IAAA,MAAM,QAAQ,GAAA,CAAI;AAAA,MACjB,KAAK,QAAA,CAAS,IAAA;AAAA,QACb,QAAA,GACGC,4BAAA,CAAgBC,qBAAA,CAAK,IAAA,CAAK,QAAA,EAAU,UAAU,CAAC,CAAA,GAC/C,SAAA,EAAW,YAAA,GACVD,4BAAA,CAAgB,SAAA,CAAU,YAAY,CAAA,GACtC;AAAA,OACL;AAAA,MACA,KAAK,UAAA,CAAW,IAAA;AAAA,QACf,QAAA,GACGA,4BAAA,CAAgBC,qBAAA,CAAK,IAAA,CAAK,QAAA,EAAU,YAAY,CAAC,CAAA,GACjD,SAAA,EAAW,cAAA,GACVD,4BAAA,CAAgB,SAAA,CAAU,cAAc,CAAA,GACxC;AAAA,OACL;AAAA,MACA,KAAK,MAAA,CAAO,IAAA;AAAA,QACX,QAAA,GACGA,4BAAA,CAAgBC,qBAAA,CAAK,IAAA,CAAK,QAAA,EAAU,QAAQ,CAAC,CAAA,GAC7C,SAAA,EAAW,UAAA,GACVD,4BAAA,CAAgB,SAAA,CAAU,UAAU,CAAA,GACpC;AAAA,OACL;AAAA,MACA,KAAK,OAAA,CAAQ,IAAA;AAAA,QACZ,QAAA,GACGA,4BAAA,CAAgBC,qBAAA,CAAK,IAAA,CAAK,QAAA,EAAU,SAAS,CAAC,CAAA,GAC9C,SAAA,EAAW,WAAA,GACVD,4BAAA,CAAgB,SAAA,CAAU,WAAW,CAAA,GACrC;AAAA;AACL,KACA,CAAA;AAAA,EACF,CAAA;AAAA,EAEA,KAAK,MAAA,EAAwB;AAC5B,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,MAAM,CAAA;AACvB,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAK,MAAM,CAAA;AAAA,EACzB;AACD,CAAA","file":"index.cjs","sourcesContent":["import { TriviousClientOptions } from \"src/shared/typings/client.js\";\nimport { resolveUserPath } from \"src/shared/utility/functions.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\nimport CommandRegistry from \"./command.registry.js\";\nimport ComponentRegistry from \"./component.registry.js\";\nimport EventRegistry from \"./event.registry.js\";\nimport ModuleRegistry from \"./module.registry.js\";\nimport path from \"node:path\";\n\n/**\n * Create new registries.\n *\n * @returns {{ commands: CommandRegistry; components: ComponentRegistry; events: EventRegistry; modules: any; loadAll(options: TriviousClientOptions): any; bind(client: TriviousClient): void; }}\n */\nexport const registries = () => ({\n\tcommands: new CommandRegistry(),\n\tcomponents: new ComponentRegistry(),\n\tevents: new EventRegistry(),\n\tmodules: new ModuleRegistry(),\n\n\tasync loadAll(options: TriviousClientOptions) {\n\t\tconst corePaths = options.corePaths;\n\t\tconst corePath = options.corePath;\n\n\t\tawait Promise.all([\n\t\t\tthis.commands.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"commands\"))\n\t\t\t\t\t: corePaths?.commandsPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.commandsPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t\tthis.components.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"components\"))\n\t\t\t\t\t: corePaths?.componentsPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.componentsPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t\tthis.events.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"events\"))\n\t\t\t\t\t: corePaths?.eventsPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.eventsPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t\tthis.modules.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"modules\"))\n\t\t\t\t\t: corePaths?.modulesPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.modulesPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t]);\n\t},\n\n\tbind(client: TriviousClient) {\n\t\tthis.events.bind(client);\n\t\tthis.modules.bind(client);\n\t},\n});\n"]}
@@ -0,0 +1,19 @@
1
+ import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-BCF4f686.cjs';
2
+ import '../../shared/typings/registry.cjs';
3
+ import 'discord.js';
4
+
5
+ /**
6
+ * Create new registries.
7
+ *
8
+ * @returns {{ commands: CommandRegistry; components: ComponentRegistry; events: EventRegistry; modules: any; loadAll(options: TriviousClientOptions): any; bind(client: TriviousClient): void; }}
9
+ */
10
+ declare const registries: () => {
11
+ commands: CommandRegistry;
12
+ components: ComponentRegistry;
13
+ events: EventRegistry;
14
+ modules: ModuleRegistry;
15
+ loadAll(options: TriviousClientOptions): Promise<void>;
16
+ bind(client: TriviousClient): void;
17
+ };
18
+
19
+ export { registries };
@@ -0,0 +1,19 @@
1
+ import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-uczj1Waw.js';
2
+ import '../../shared/typings/registry.js';
3
+ import 'discord.js';
4
+
5
+ /**
6
+ * Create new registries.
7
+ *
8
+ * @returns {{ commands: CommandRegistry; components: ComponentRegistry; events: EventRegistry; modules: any; loadAll(options: TriviousClientOptions): any; bind(client: TriviousClient): void; }}
9
+ */
10
+ declare const registries: () => {
11
+ commands: CommandRegistry;
12
+ components: ComponentRegistry;
13
+ events: EventRegistry;
14
+ modules: ModuleRegistry;
15
+ loadAll(options: TriviousClientOptions): Promise<void>;
16
+ bind(client: TriviousClient): void;
17
+ };
18
+
19
+ export { registries };
@@ -0,0 +1,39 @@
1
+ import { resolveUserPath } from 'src/shared/utility/functions.js';
2
+ import CommandRegistry from './command.registry.js';
3
+ import ComponentRegistry from './component.registry.js';
4
+ import EventRegistry from './event.registry.js';
5
+ import ModuleRegistry from './module.registry.js';
6
+ import path from 'node:path';
7
+
8
+ const registries = () => ({
9
+ commands: new CommandRegistry(),
10
+ components: new ComponentRegistry(),
11
+ events: new EventRegistry(),
12
+ modules: new ModuleRegistry(),
13
+ async loadAll(options) {
14
+ const corePaths = options.corePaths;
15
+ const corePath = options.corePath;
16
+ await Promise.all([
17
+ this.commands.load(
18
+ corePath ? resolveUserPath(path.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
19
+ ),
20
+ this.components.load(
21
+ corePath ? resolveUserPath(path.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
22
+ ),
23
+ this.events.load(
24
+ corePath ? resolveUserPath(path.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
25
+ ),
26
+ this.modules.load(
27
+ corePath ? resolveUserPath(path.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
28
+ )
29
+ ]);
30
+ },
31
+ bind(client) {
32
+ this.events.bind(client);
33
+ this.modules.bind(client);
34
+ }
35
+ });
36
+
37
+ export { registries };
38
+ //# sourceMappingURL=index.js.map
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/registry/index.ts"],"names":[],"mappings":";;;;;;;AAcO,MAAM,aAAa,OAAO;AAAA,EAChC,QAAA,EAAU,IAAI,eAAA,EAAgB;AAAA,EAC9B,UAAA,EAAY,IAAI,iBAAA,EAAkB;AAAA,EAClC,MAAA,EAAQ,IAAI,aAAA,EAAc;AAAA,EAC1B,OAAA,EAAS,IAAI,cAAA,EAAe;AAAA,EAE5B,MAAM,QAAQ,OAAA,EAAgC;AAC7C,IAAA,MAAM,YAAY,OAAA,CAAQ,SAAA;AAC1B,IAAA,MAAM,WAAW,OAAA,CAAQ,QAAA;AAEzB,IAAA,MAAM,QAAQ,GAAA,CAAI;AAAA,MACjB,KAAK,QAAA,CAAS,IAAA;AAAA,QACb,QAAA,GACG,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,QAAA,EAAU,UAAU,CAAC,CAAA,GAC/C,SAAA,EAAW,YAAA,GACV,eAAA,CAAgB,SAAA,CAAU,YAAY,CAAA,GACtC;AAAA,OACL;AAAA,MACA,KAAK,UAAA,CAAW,IAAA;AAAA,QACf,QAAA,GACG,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,QAAA,EAAU,YAAY,CAAC,CAAA,GACjD,SAAA,EAAW,cAAA,GACV,eAAA,CAAgB,SAAA,CAAU,cAAc,CAAA,GACxC;AAAA,OACL;AAAA,MACA,KAAK,MAAA,CAAO,IAAA;AAAA,QACX,QAAA,GACG,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,QAAA,EAAU,QAAQ,CAAC,CAAA,GAC7C,SAAA,EAAW,UAAA,GACV,eAAA,CAAgB,SAAA,CAAU,UAAU,CAAA,GACpC;AAAA,OACL;AAAA,MACA,KAAK,OAAA,CAAQ,IAAA;AAAA,QACZ,QAAA,GACG,eAAA,CAAgB,IAAA,CAAK,IAAA,CAAK,QAAA,EAAU,SAAS,CAAC,CAAA,GAC9C,SAAA,EAAW,WAAA,GACV,eAAA,CAAgB,SAAA,CAAU,WAAW,CAAA,GACrC;AAAA;AACL,KACA,CAAA;AAAA,EACF,CAAA;AAAA,EAEA,KAAK,MAAA,EAAwB;AAC5B,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,MAAM,CAAA;AACvB,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAK,MAAM,CAAA;AAAA,EACzB;AACD,CAAA","file":"index.js","sourcesContent":["import { TriviousClientOptions } from \"src/shared/typings/client.js\";\nimport { resolveUserPath } from \"src/shared/utility/functions.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\nimport CommandRegistry from \"./command.registry.js\";\nimport ComponentRegistry from \"./component.registry.js\";\nimport EventRegistry from \"./event.registry.js\";\nimport ModuleRegistry from \"./module.registry.js\";\nimport path from \"node:path\";\n\n/**\n * Create new registries.\n *\n * @returns {{ commands: CommandRegistry; components: ComponentRegistry; events: EventRegistry; modules: any; loadAll(options: TriviousClientOptions): any; bind(client: TriviousClient): void; }}\n */\nexport const registries = () => ({\n\tcommands: new CommandRegistry(),\n\tcomponents: new ComponentRegistry(),\n\tevents: new EventRegistry(),\n\tmodules: new ModuleRegistry(),\n\n\tasync loadAll(options: TriviousClientOptions) {\n\t\tconst corePaths = options.corePaths;\n\t\tconst corePath = options.corePath;\n\n\t\tawait Promise.all([\n\t\t\tthis.commands.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"commands\"))\n\t\t\t\t\t: corePaths?.commandsPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.commandsPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t\tthis.components.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"components\"))\n\t\t\t\t\t: corePaths?.componentsPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.componentsPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t\tthis.events.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"events\"))\n\t\t\t\t\t: corePaths?.eventsPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.eventsPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t\tthis.modules.load(\n\t\t\t\tcorePath\n\t\t\t\t\t? resolveUserPath(path.join(corePath, \"modules\"))\n\t\t\t\t\t: corePaths?.modulesPath\n\t\t\t\t\t\t? resolveUserPath(corePaths.modulesPath)\n\t\t\t\t\t\t: undefined\n\t\t\t),\n\t\t]);\n\t},\n\n\tbind(client: TriviousClient) {\n\t\tthis.events.bind(client);\n\t\tthis.modules.bind(client);\n\t},\n});\n"]}
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var discord_js = require('discord.js');
4
+ var functions_js = require('src/shared/utility/functions.js');
5
+ var index_js = require('src/shared/typings/index.js');
6
+ var fs = require('fs');
7
+ var node_path = require('node:path');
8
+
9
+ class ModuleRegistry extends index_js.BaseRegistry {
10
+ items = new discord_js.Collection();
11
+ /**
12
+ * Load all modules.
13
+ *
14
+ * @async
15
+ * @param {string} [directory=getCorePath({ coreDirectory: "module" })]
16
+ * @returns {Promise<this>}
17
+ */
18
+ async load(directory = functions_js.getCorePath({ coreDirectory: "module" })) {
19
+ if (!await functions_js.exists(directory)) {
20
+ return this;
21
+ }
22
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
23
+ for (const entry of entries) {
24
+ const fullPath = node_path.join(directory, entry.name);
25
+ if (!entry.isDirectory()) continue;
26
+ const moduleFiles = (await fs.promises.readdir(fullPath)).filter(
27
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
28
+ );
29
+ for (const file of moduleFiles) {
30
+ const moduleEvent = await this.importFile(node_path.join(fullPath, file));
31
+ if (!moduleEvent || !moduleEvent.events) continue;
32
+ this.items.set(moduleEvent.name, moduleEvent);
33
+ }
34
+ }
35
+ return this;
36
+ }
37
+ /**
38
+ * Bind all loaded modules to their client event respectively.
39
+ *
40
+ * @param {TriviousClient} client
41
+ */
42
+ bind(client) {
43
+ for (const mod of this.items.values()) {
44
+ for (const [eventName, handler] of Object.entries(mod.events)) {
45
+ if (typeof handler !== "function") continue;
46
+ const listener = (...args) => {
47
+ void handler(client, ...args);
48
+ };
49
+ client.on(eventName, listener);
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ module.exports = ModuleRegistry;
56
+ //# sourceMappingURL=module.registry.cjs.map
57
+ //# sourceMappingURL=module.registry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/registry/module.registry.ts"],"names":["BaseRegistry","Collection","getCorePath","exists","fs","join"],"mappings":";;;;;;;;AAeA,MAAO,uBAAqCA,qBAAA,CAAqB;AAAA,EACtD,KAAA,GAAQ,IAAIC,qBAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjD,MAAM,KAAK,SAAA,GAAoBC,wBAAA,CAAY,EAAE,aAAA,EAAe,QAAA,EAAU,CAAA,EAAkB;AACvF,IAAA,IAAI,CAAE,MAAMC,mBAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMC,WAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAWC,cAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,WAAA,GAAA,CAAe,MAAMD,WAAA,CAAG,OAAA,CAAQ,QAAQ,CAAA,EAAG,MAAA;AAAA,QAChD,WACE,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,IAAK,KAAK,QAAA,CAAS,KAAK,CAAA,KAC5C,CAAC,KAAK,UAAA,CAAW,QAAQ,KACzB,CAAC,IAAA,CAAK,SAAS,OAAO;AAAA,OACxB;AAEA,MAAA,KAAA,MAAW,QAAQ,WAAA,EAAa;AAC/B,QAAA,MAAM,cAAc,MAAM,IAAA,CAAK,WAAmBC,cAAA,CAAK,QAAA,EAAU,IAAI,CAAC,CAAA;AACtE,QAAA,IAAI,CAAC,WAAA,IAAe,CAAC,WAAA,CAAY,MAAA,EAAQ;AAEzC,QAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,WAAA,CAAY,IAAA,EAAM,WAAW,CAAA;AAAA,MAC7C;AAAA,IACD;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,MAAA,EAAwB;AAC5B,IAAA,KAAA,MAAW,GAAA,IAAO,IAAA,CAAK,KAAA,CAAM,MAAA,EAAO,EAAG;AACtC,MAAA,KAAA,MAAW,CAAC,WAAW,OAAO,CAAA,IAAK,OAAO,OAAA,CAAQ,GAAA,CAAI,MAAO,CAAA,EAAG;AAC/D,QAAA,IAAI,OAAO,YAAY,UAAA,EAAY;AAEnC,QAAA,MAAM,QAAA,GAAW,IAAI,IAAA,KAAoB;AACxC,UAAA,KAAM,OAAA,CAAgE,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,QACtF,CAAA;AAEA,QAAC,MAAA,CAAO,EAAA,CAAW,SAAA,EAAW,QAAQ,CAAA;AAAA,MACvC;AAAA,IACD;AAAA,EACD;AACD","file":"module.registry.cjs","sourcesContent":["import { Collection } from \"discord.js\";\nimport { exists, getCorePath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Module } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\n/**\n * Registry to load, get and bind modules.\n *\n * @export\n * @class ModuleRegistry\n * @typedef {ModuleRegistry}\n * @extends {BaseRegistry<Module>}\n */\nexport default class ModuleRegistry extends BaseRegistry<Module> {\n\tprotected items = new Collection<string, Module>();\n\n\t/**\n\t * Load all modules.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"module\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = getCorePath({ coreDirectory: \"module\" })): Promise<this> {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst moduleFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\tfile =>\n\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t);\n\n\t\t\tfor (const file of moduleFiles) {\n\t\t\t\tconst moduleEvent = await this.importFile<Module>(join(fullPath, file));\n\t\t\t\tif (!moduleEvent || !moduleEvent.events) continue;\n\n\t\t\t\tthis.items.set(moduleEvent.name, moduleEvent);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Bind all loaded modules to their client event respectively.\n\t *\n\t * @param {TriviousClient} client\n\t */\n\tbind(client: TriviousClient) {\n\t\tfor (const mod of this.items.values()) {\n\t\t\tfor (const [eventName, handler] of Object.entries(mod.events!)) {\n\t\t\t\tif (typeof handler !== \"function\") continue;\n\n\t\t\t\tconst listener = (...args: unknown[]) => {\n\t\t\t\t\tvoid (handler as (client: TriviousClient, ...args: unknown[]) => any)(client, ...args);\n\t\t\t\t};\n\n\t\t\t\t(client.on as any)(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import 'discord.js';
2
+ export { M as default } from '../../index-BCF4f686.cjs';
3
+ import '../../shared/typings/registry.cjs';
@@ -0,0 +1,3 @@
1
+ import 'discord.js';
2
+ export { M as default } from '../../index-uczj1Waw.js';
3
+ import '../../shared/typings/registry.js';
@@ -0,0 +1,55 @@
1
+ import { Collection } from 'discord.js';
2
+ import { getCorePath, exists } from 'src/shared/utility/functions.js';
3
+ import { BaseRegistry } from 'src/shared/typings/index.js';
4
+ import { promises } from 'fs';
5
+ import { join } from 'node:path';
6
+
7
+ class ModuleRegistry extends BaseRegistry {
8
+ items = new Collection();
9
+ /**
10
+ * Load all modules.
11
+ *
12
+ * @async
13
+ * @param {string} [directory=getCorePath({ coreDirectory: "module" })]
14
+ * @returns {Promise<this>}
15
+ */
16
+ async load(directory = getCorePath({ coreDirectory: "module" })) {
17
+ if (!await exists(directory)) {
18
+ return this;
19
+ }
20
+ const entries = await promises.readdir(directory, { withFileTypes: true });
21
+ for (const entry of entries) {
22
+ const fullPath = join(directory, entry.name);
23
+ if (!entry.isDirectory()) continue;
24
+ const moduleFiles = (await promises.readdir(fullPath)).filter(
25
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
26
+ );
27
+ for (const file of moduleFiles) {
28
+ const moduleEvent = await this.importFile(join(fullPath, file));
29
+ if (!moduleEvent || !moduleEvent.events) continue;
30
+ this.items.set(moduleEvent.name, moduleEvent);
31
+ }
32
+ }
33
+ return this;
34
+ }
35
+ /**
36
+ * Bind all loaded modules to their client event respectively.
37
+ *
38
+ * @param {TriviousClient} client
39
+ */
40
+ bind(client) {
41
+ for (const mod of this.items.values()) {
42
+ for (const [eventName, handler] of Object.entries(mod.events)) {
43
+ if (typeof handler !== "function") continue;
44
+ const listener = (...args) => {
45
+ void handler(client, ...args);
46
+ };
47
+ client.on(eventName, listener);
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ export { ModuleRegistry as default };
54
+ //# sourceMappingURL=module.registry.js.map
55
+ //# sourceMappingURL=module.registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/registry/module.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,uBAAqC,YAAA,CAAqB;AAAA,EACtD,KAAA,GAAQ,IAAI,UAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjD,MAAM,KAAK,SAAA,GAAoB,WAAA,CAAY,EAAE,aAAA,EAAe,QAAA,EAAU,CAAA,EAAkB;AACvF,IAAA,IAAI,CAAE,MAAM,MAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMA,QAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,WAAA,GAAA,CAAe,MAAMA,QAAA,CAAG,OAAA,CAAQ,QAAQ,CAAA,EAAG,MAAA;AAAA,QAChD,WACE,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,IAAK,KAAK,QAAA,CAAS,KAAK,CAAA,KAC5C,CAAC,KAAK,UAAA,CAAW,QAAQ,KACzB,CAAC,IAAA,CAAK,SAAS,OAAO;AAAA,OACxB;AAEA,MAAA,KAAA,MAAW,QAAQ,WAAA,EAAa;AAC/B,QAAA,MAAM,cAAc,MAAM,IAAA,CAAK,WAAmB,IAAA,CAAK,QAAA,EAAU,IAAI,CAAC,CAAA;AACtE,QAAA,IAAI,CAAC,WAAA,IAAe,CAAC,WAAA,CAAY,MAAA,EAAQ;AAEzC,QAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,WAAA,CAAY,IAAA,EAAM,WAAW,CAAA;AAAA,MAC7C;AAAA,IACD;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,MAAA,EAAwB;AAC5B,IAAA,KAAA,MAAW,GAAA,IAAO,IAAA,CAAK,KAAA,CAAM,MAAA,EAAO,EAAG;AACtC,MAAA,KAAA,MAAW,CAAC,WAAW,OAAO,CAAA,IAAK,OAAO,OAAA,CAAQ,GAAA,CAAI,MAAO,CAAA,EAAG;AAC/D,QAAA,IAAI,OAAO,YAAY,UAAA,EAAY;AAEnC,QAAA,MAAM,QAAA,GAAW,IAAI,IAAA,KAAoB;AACxC,UAAA,KAAM,OAAA,CAAgE,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,QACtF,CAAA;AAEA,QAAC,MAAA,CAAO,EAAA,CAAW,SAAA,EAAW,QAAQ,CAAA;AAAA,MACvC;AAAA,IACD;AAAA,EACD;AACD","file":"module.registry.js","sourcesContent":["import { Collection } from \"discord.js\";\nimport { exists, getCorePath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Module } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\n/**\n * Registry to load, get and bind modules.\n *\n * @export\n * @class ModuleRegistry\n * @typedef {ModuleRegistry}\n * @extends {BaseRegistry<Module>}\n */\nexport default class ModuleRegistry extends BaseRegistry<Module> {\n\tprotected items = new Collection<string, Module>();\n\n\t/**\n\t * Load all modules.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"module\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = getCorePath({ coreDirectory: \"module\" })): Promise<this> {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst moduleFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\tfile =>\n\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t);\n\n\t\t\tfor (const file of moduleFiles) {\n\t\t\t\tconst moduleEvent = await this.importFile<Module>(join(fullPath, file));\n\t\t\t\tif (!moduleEvent || !moduleEvent.events) continue;\n\n\t\t\t\tthis.items.set(moduleEvent.name, moduleEvent);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Bind all loaded modules to their client event respectively.\n\t *\n\t * @param {TriviousClient} client\n\t */\n\tbind(client: TriviousClient) {\n\t\tfor (const mod of this.items.values()) {\n\t\t\tfor (const [eventName, handler] of Object.entries(mod.events!)) {\n\t\t\t\tif (typeof handler !== \"function\") continue;\n\n\t\t\t\tconst listener = (...args: unknown[]) => {\n\t\t\t\t\tvoid (handler as (client: TriviousClient, ...args: unknown[]) => any)(client, ...args);\n\t\t\t\t};\n\n\t\t\t\t(client.on as any)(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}