trivious 1.6.18 → 2.0.0

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 (128) hide show
  1. package/README.md +53 -66
  2. package/dist/{core/builders/util.builders.d.ts → features/builders/utility.builders.d.ts} +0 -9
  3. package/dist/{core/builders/util.builders.js → features/builders/utility.builders.js} +2 -2
  4. package/dist/features/builders/utility.builders.js.map +1 -0
  5. package/dist/features/client/client.types.d.ts +85 -0
  6. package/dist/features/client/client.types.js +3 -0
  7. package/dist/{shared/typings/client.js.map → features/client/client.types.js.map} +1 -1
  8. package/dist/features/client/deploy.client.d.ts +7 -0
  9. package/dist/features/client/deploy.client.js +43 -0
  10. package/dist/features/client/deploy.client.js.map +1 -0
  11. package/dist/features/client/trivious.client.d.ts +3 -0
  12. package/dist/features/client/trivious.client.js +62 -0
  13. package/dist/features/client/trivious.client.js.map +1 -0
  14. package/dist/features/commands/commands.types.d.ts +3 -0
  15. package/dist/features/commands/commands.types.js +3 -0
  16. package/dist/{shared/typings/commands.js.map → features/commands/commands.types.js.map} +1 -1
  17. package/dist/features/commands/methods.commands.d.ts +13 -0
  18. package/dist/features/commands/methods.commands.js +70 -0
  19. package/dist/features/commands/methods.commands.js.map +1 -0
  20. package/dist/features/commands/registry.commands.d.ts +7 -0
  21. package/dist/features/commands/registry.commands.js +84 -0
  22. package/dist/features/commands/registry.commands.js.map +1 -0
  23. package/dist/features/components/components.types.d.ts +3 -0
  24. package/dist/features/components/components.types.js +10 -0
  25. package/dist/features/components/components.types.js.map +1 -0
  26. package/dist/features/components/registry.components.d.ts +7 -0
  27. package/dist/features/components/registry.components.js +23 -0
  28. package/dist/features/components/registry.components.js.map +1 -0
  29. package/dist/features/customId/customid.types.d.ts +13 -0
  30. package/dist/features/customId/customid.types.js +3 -0
  31. package/dist/features/customId/customid.types.js.map +1 -0
  32. package/dist/features/customId/methods.customid.d.ts +20 -0
  33. package/dist/features/customId/methods.customid.js +24 -0
  34. package/dist/features/customId/methods.customid.js.map +1 -0
  35. package/dist/features/events/events.types.d.ts +3 -0
  36. package/dist/features/events/events.types.js +3 -0
  37. package/dist/{shared/typings/events.js.map → features/events/events.types.js.map} +1 -1
  38. package/dist/features/events/presets/clientReady.d.ts +11 -0
  39. package/dist/{core/events → features/events/presets}/clientReady.js +1 -1
  40. package/dist/features/events/presets/clientReady.js.map +1 -0
  41. package/dist/features/events/presets/interactionCreate.d.ts +10 -0
  42. package/dist/features/events/presets/interactionCreate.js +49 -0
  43. package/dist/features/events/presets/interactionCreate.js.map +1 -0
  44. package/dist/features/events/registry.events.d.ts +8 -0
  45. package/dist/features/events/registry.events.js +45 -0
  46. package/dist/features/events/registry.events.js.map +1 -0
  47. package/dist/features/modules/modules.types.d.ts +3 -0
  48. package/dist/features/modules/modules.types.js +3 -0
  49. package/dist/{shared/typings/module.js.map → features/modules/modules.types.js.map} +1 -1
  50. package/dist/features/modules/registry.modules.d.ts +8 -0
  51. package/dist/features/modules/registry.modules.js +30 -0
  52. package/dist/features/modules/registry.modules.js.map +1 -0
  53. package/dist/features/structure/index.structure.d.ts +10 -0
  54. package/dist/features/structure/index.structure.js +51 -0
  55. package/dist/features/structure/index.structure.js.map +1 -0
  56. package/dist/index.d.ts +6 -5
  57. package/dist/index.js +4 -10
  58. package/dist/modules.types-Bn4HfuVk.d.ts +165 -0
  59. package/dist/shared/registries.d.ts +26 -0
  60. package/dist/shared/registries.js +25 -0
  61. package/dist/shared/registries.js.map +1 -0
  62. package/dist/shared/typings.d.ts +4 -0
  63. package/dist/shared/typings.js +9 -0
  64. package/dist/shared/typings.js.map +1 -0
  65. package/dist/utility/errors.d.ts +15 -0
  66. package/dist/utility/errors.js +24 -0
  67. package/dist/utility/errors.js.map +1 -0
  68. package/dist/utility/functions.d.ts +4 -0
  69. package/dist/utility/functions.js +32 -0
  70. package/dist/utility/functions.js.map +1 -0
  71. package/package.json +7 -3
  72. package/dist/core/builders/util.builders.js.map +0 -1
  73. package/dist/core/client/trivious.client.d.ts +0 -6
  74. package/dist/core/client/trivious.client.js +0 -115
  75. package/dist/core/client/trivious.client.js.map +0 -1
  76. package/dist/core/commands/methods.command.d.ts +0 -6
  77. package/dist/core/commands/methods.command.js +0 -90
  78. package/dist/core/commands/methods.command.js.map +0 -1
  79. package/dist/core/events/clientReady.d.ts +0 -14
  80. package/dist/core/events/clientReady.js.map +0 -1
  81. package/dist/core/events/interactionCreate.d.ts +0 -14
  82. package/dist/core/events/interactionCreate.js +0 -84
  83. package/dist/core/events/interactionCreate.js.map +0 -1
  84. package/dist/core/registry/command.registry.d.ts +0 -6
  85. package/dist/core/registry/command.registry.js +0 -54
  86. package/dist/core/registry/command.registry.js.map +0 -1
  87. package/dist/core/registry/component.registry.d.ts +0 -6
  88. package/dist/core/registry/component.registry.js +0 -41
  89. package/dist/core/registry/component.registry.js.map +0 -1
  90. package/dist/core/registry/event.registry.d.ts +0 -6
  91. package/dist/core/registry/event.registry.js +0 -71
  92. package/dist/core/registry/event.registry.js.map +0 -1
  93. package/dist/core/registry/index.d.ts +0 -22
  94. package/dist/core/registry/index.js +0 -39
  95. package/dist/core/registry/index.js.map +0 -1
  96. package/dist/core/registry/module.registry.d.ts +0 -6
  97. package/dist/core/registry/module.registry.js +0 -55
  98. package/dist/core/registry/module.registry.js.map +0 -1
  99. package/dist/index-DbWA_10I.d.ts +0 -439
  100. package/dist/shared/typings/client.d.ts +0 -74
  101. package/dist/shared/typings/client.js +0 -3
  102. package/dist/shared/typings/commands.d.ts +0 -6
  103. package/dist/shared/typings/commands.js +0 -3
  104. package/dist/shared/typings/components.d.ts +0 -6
  105. package/dist/shared/typings/components.js +0 -10
  106. package/dist/shared/typings/components.js.map +0 -1
  107. package/dist/shared/typings/events.d.ts +0 -6
  108. package/dist/shared/typings/events.js +0 -3
  109. package/dist/shared/typings/index.d.ts +0 -6
  110. package/dist/shared/typings/index.js +0 -9
  111. package/dist/shared/typings/index.js.map +0 -1
  112. package/dist/shared/typings/module.d.ts +0 -6
  113. package/dist/shared/typings/module.js +0 -3
  114. package/dist/shared/typings/permissions.d.ts +0 -16
  115. package/dist/shared/typings/permissions.js +0 -13
  116. package/dist/shared/typings/permissions.js.map +0 -1
  117. package/dist/shared/typings/registry.d.ts +0 -51
  118. package/dist/shared/typings/registry.js +0 -61
  119. package/dist/shared/typings/registry.js.map +0 -1
  120. package/dist/shared/utility/components.utility.d.ts +0 -6
  121. package/dist/shared/utility/components.utility.js +0 -17
  122. package/dist/shared/utility/components.utility.js.map +0 -1
  123. package/dist/shared/utility/functions.d.ts +0 -60
  124. package/dist/shared/utility/functions.js +0 -81
  125. package/dist/shared/utility/functions.js.map +0 -1
  126. package/dist/shared/utility/permissions.utility.d.ts +0 -6
  127. package/dist/shared/utility/permissions.utility.js +0 -12
  128. package/dist/shared/utility/permissions.utility.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/events/clientReady.ts"],"names":[],"mappings":"AAEA,IAAO,mBAAA,GAAQ;AAAA,EACd,IAAA,EAAM,aAAA;AAAA,EACN,IAAA,EAAM,IAAA;AAAA,EACN,OAAA,EAAS,OAAO,MAAA,EAAQ,CAAA,KAAM;AAC7B,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,yBAAA,EAA4B,MAAA,CAAO,IAAA,EAAM,QAAQ,CAAA,CAAE,CAAA;AAAA,EAChE;AACD","file":"clientReady.js","sourcesContent":["import { Event } from \"src/shared/typings/index.js\";\n\nexport default {\n\tname: \"clientReady\",\n\tonce: true,\n\texecute: async (client, _) => {\n\t\tconsole.log(`Successfully logged into ${client.user?.username}`);\n\t},\n} satisfies Event<\"clientReady\">;\n"]}
@@ -1,14 +0,0 @@
1
- import * as discord_js from 'discord.js';
2
- import { CacheType } from 'discord.js';
3
- import { T as TriviousClient } from '../../index-DbWA_10I.js';
4
- import '../../shared/typings/permissions.js';
5
- import '../../shared/typings/registry.js';
6
- import '../../shared/typings/client.js';
7
- import '../builders/util.builders.js';
8
-
9
- declare const _default: {
10
- name: "interactionCreate";
11
- execute: (client: TriviousClient, interaction: discord_js.Interaction<CacheType>) => Promise<void>;
12
- };
13
-
14
- export { _default as default };
@@ -1,84 +0,0 @@
1
- import { ButtonInteraction, ModalSubmitInteraction } from 'discord.js';
2
- import { PermissionLevel, ComponentType } from '../../shared/typings/index.js';
3
- import { hasPermission } from '../../shared/utility/functions.js';
4
- import { interactionReply, verifyGuildPermission, handleSlashCommand } from '../commands/methods.command.js';
5
- import { deconstructCustomId } from '../../shared/utility/components.utility.js';
6
-
7
- async function validateComponentGuildPermission(client, interaction, permission) {
8
- if (interaction.guild) {
9
- const member = interaction.member;
10
- const memberHasPermission = hasPermission(client, { permission, member });
11
- return memberHasPermission;
12
- }
13
- return false;
14
- }
15
- var interactionCreate_default = {
16
- name: "interactionCreate",
17
- execute: async (client, interaction) => {
18
- if (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {
19
- const { commandName } = interaction;
20
- const registeredCommands = client.registries.commands.get();
21
- const command = registeredCommands.get(commandName);
22
- if (!command) {
23
- await interactionReply({
24
- flags: ["EphemeralReply"],
25
- interaction,
26
- options: {
27
- content: `Command is outdated, inactive or does not have a handler!`
28
- }
29
- });
30
- return;
31
- }
32
- const requiredPermission = command.permission;
33
- const hasPermission2 = await verifyGuildPermission(
34
- client,
35
- interaction,
36
- command,
37
- requiredPermission || PermissionLevel.USER
38
- );
39
- if (!hasPermission2) return;
40
- if (command.context === "SlashCommand" && "data" in command) {
41
- await handleSlashCommand(
42
- client,
43
- command,
44
- interaction
45
- );
46
- } else if (command.context === "ContextMenu") {
47
- await command.execute(
48
- client,
49
- interaction
50
- );
51
- }
52
- } else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
53
- const { compType, tags, data } = deconstructCustomId(interaction.customId);
54
- if (compType === ComponentType.Button && !(interaction instanceof ButtonInteraction)) return;
55
- if (compType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))
56
- return;
57
- if (tags && tags.includes("awaited")) return;
58
- const registeredComponents = client.registries.components.get();
59
- const component = registeredComponents.get(data);
60
- if (!component) {
61
- await interactionReply({
62
- flags: ["EphemeralReply"],
63
- interaction,
64
- options: {
65
- content: `Command is outdated, inactive or does not have a handler!`
66
- }
67
- });
68
- return;
69
- }
70
- const requiredPermission = component.permission;
71
- const hasPermission2 = await validateComponentGuildPermission(
72
- client,
73
- interaction,
74
- requiredPermission
75
- );
76
- if (!hasPermission2) return;
77
- await component.execute(client, interaction);
78
- }
79
- }
80
- };
81
-
82
- export { interactionCreate_default as default };
83
- //# sourceMappingURL=interactionCreate.js.map
84
- //# sourceMappingURL=interactionCreate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/events/interactionCreate.ts"],"names":["hasPermission"],"mappings":";;;;;;AA0BA,eAAe,gCAAA,CACd,MAAA,EACA,WAAA,EACA,UAAA,EACC;AACD,EAAA,IAAI,YAAY,KAAA,EAAO;AACtB,IAAA,MAAM,SAAS,WAAA,CAAY,MAAA;AAC3B,IAAA,MAAM,sBAAsB,aAAA,CAAc,MAAA,EAAQ,EAAE,UAAA,EAAY,QAAQ,CAAA;AACxE,IAAA,OAAO,mBAAA;AAAA,EACR;AAEA,EAAA,OAAO,KAAA;AACR;AAEA,IAAO,yBAAA,GAAQ;AAAA,EACd,IAAA,EAAM,mBAAA;AAAA,EACN,OAAA,EAAS,OAAO,MAAA,EAAQ,WAAA,KAAgB;AACvC,IAAA,IAAI,WAAA,CAAY,kBAAA,EAAmB,IAAK,WAAA,CAAY,sBAAqB,EAAG;AAC3E,MAAA,MAAM,EAAE,aAAY,GAAI,WAAA;AAExB,MAAA,MAAM,kBAAA,GAAqB,MAAA,CAAO,UAAA,CAAW,QAAA,CAAS,GAAA,EAAI;AAC1D,MAAA,MAAM,OAAA,GAAU,kBAAA,CAAmB,GAAA,CAAI,WAAW,CAAA;AAClD,MAAA,IAAI,CAAC,OAAA,EAAS;AACb,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,KAAA,E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AA,CAAqB,GAAA,CAAI,IAAI,CAAA;AAC/C,MAAA,IAAI,CAAC,SAAA,EAAW;AACf,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,KAAA,EAAO,CAAC,gBAAgB,CAAA;AAAA,UACxB,WAAA;AAAA,UACA,OAAA,EAAS;AAAA,YACR,OAAA,EAAS,CAAA,yDAAA;AAAA;AACV,SACA,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,qBAAqB,SAAA,CAAU,UAAA;AACrC,MAAA,MAAMA,iBAAgB,MAAM,gCAAA;AAAA,QAC3B,MAAA;AAAA,QACA,WAAA;AAAA,QACA;AAAA,OACD;AACA,MAAA,IAAI,CAACA,cAAAA,EAAe;AAEpB,MAAA,MAAM,SAAA,CAAU,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,IAC5C;AAAA,EACD;AACD","file":"interactionCreate.js","sourcesContent":["import {\n\tButtonInteraction,\n\tCacheType,\n\tGuildMember,\n\tMessageContextMenuCommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\nimport {\n\tComponentInteraction,\n\tComponentType,\n\tContextMenuCommand,\n\tEvent,\n\tPermissionLevel,\n\tSlashCommand,\n} from \"src/shared/typings/index.js\";\nimport { hasPermission } from \"src/shared/utility/functions.js\";\nimport {\n\thandleSlashCommand,\n\tinteractionReply,\n\tverifyGuildPermission,\n} from \"../commands/methods.command.js\";\nimport { ChatInputCommandInteraction } from \"src/index.js\";\nimport { deconstructCustomId } from \"src/shared/utility/components.utility.js\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\nasync function validateComponentGuildPermission(\n\tclient: TriviousClient,\n\tinteraction: ComponentInteraction,\n\tpermission: PermissionLevel\n) {\n\tif (interaction.guild) {\n\t\tconst member = interaction.member as GuildMember;\n\t\tconst memberHasPermission = hasPermission(client, { permission, member });\n\t\treturn memberHasPermission;\n\t}\n\n\treturn false;\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\texecute: async (client, interaction) => {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst registeredCommands = client.registries.commands.get();\n\t\t\tconst command = registeredCommands.get(commandName);\n\t\t\tif (!command) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t\tinteraction,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = command.permission;\n\t\t\tconst hasPermission = await verifyGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\tcommand,\n\t\t\t\trequiredPermission || PermissionLevel.USER\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tif (command.context === \"SlashCommand\" && \"data\" in command) {\n\t\t\t\tawait handleSlashCommand(\n\t\t\t\t\tclient,\n\t\t\t\t\tcommand as SlashCommand,\n\t\t\t\t\tinteraction as ChatInputCommandInteraction\n\t\t\t\t);\n\t\t\t} else if (command.context === \"ContextMenu\") {\n\t\t\t\tawait (command as ContextMenuCommand).execute(\n\t\t\t\t\tclient,\n\t\t\t\t\tinteraction as\n\t\t\t\t\t\t| UserContextMenuCommandInteraction<CacheType>\n\t\t\t\t\t\t| MessageContextMenuCommandInteraction<CacheType>\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { compType, tags, data } = deconstructCustomId(interaction.customId);\n\n\t\t\tif (compType === ComponentType.Button && !(interaction instanceof ButtonInteraction)) return;\n\t\t\tif (compType === ComponentType.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst registeredComponents = client.registries.components.get();\n\t\t\tconst component = registeredComponents.get(data);\n\t\t\tif (!component) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t\tinteraction,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcontent: `Command is outdated, inactive or does not have a handler!`,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst requiredPermission = component.permission;\n\t\t\tconst hasPermission = await validateComponentGuildPermission(\n\t\t\t\tclient,\n\t\t\t\tinteraction,\n\t\t\t\trequiredPermission\n\t\t\t);\n\t\t\tif (!hasPermission) return;\n\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
@@ -1,6 +0,0 @@
1
- import 'discord.js';
2
- import '../../shared/typings/registry.js';
3
- export { C as default } from '../../index-DbWA_10I.js';
4
- import '../../shared/typings/permissions.js';
5
- import '../../shared/typings/client.js';
6
- import '../builders/util.builders.js';
@@ -1,54 +0,0 @@
1
- import { Collection, SlashCommandSubcommandBuilder } from 'discord.js';
2
- import { BaseRegistry } from '../../shared/typings/index.js';
3
- import { resolveUserPath, exists } from '../../shared/utility/functions.js';
4
- import { promises } from 'fs';
5
- import path, { join } from 'node:path';
6
-
7
- class CommandRegistry extends BaseRegistry {
8
- items = new Collection();
9
- /**
10
- * Load all commands and their subcommands
11
- *
12
- * @async
13
- * @param {string} [directory=getCorePath({ coreDirectory: "commands" })]
14
- * @returns {unknown}
15
- */
16
- async load(directory = resolveUserPath(path.join("src", "commands"))) {
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 indexFile = join(fullPath, "index.ts");
25
- const indexJs = join(fullPath, "index.js");
26
- let commandFile = "";
27
- if (await exists(indexFile)) commandFile = indexFile;
28
- else if (await exists(indexJs)) commandFile = indexJs;
29
- else continue;
30
- const command = await this.importFile(commandFile);
31
- if (!command || !command.active || !("data" in command)) continue;
32
- if (command.context === "SlashCommand" && "addSubcommand" in command.data) {
33
- const subcommandFiles = (await promises.readdir(fullPath)).filter(
34
- (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
35
- );
36
- for (const file of subcommandFiles) {
37
- const subcommand = await this.importFile(join(fullPath, file));
38
- if (!subcommand) continue;
39
- if (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))
40
- continue;
41
- if (!command.subcommands) command.subcommands = new Collection();
42
- command.subcommands.set(subcommand.data.name, subcommand);
43
- command.data.addSubcommand(subcommand.data);
44
- }
45
- }
46
- this.items.set(command.data.name, command);
47
- }
48
- return this;
49
- }
50
- }
51
-
52
- export { CommandRegistry as default };
53
- //# sourceMappingURL=command.registry.js.map
54
- //# sourceMappingURL=command.registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/registry/command.registry.ts"],"names":["fs"],"mappings":";;;;;;AAoBA,MAAO,wBAAsC,YAAA,CAAsB;AAAA,EACxD,KAAA,GAAQ,IAAI,UAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlD,MAAM,KAAK,SAAA,GAAoB,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,UAAU,CAAC,CAAA,EAAG;AAC7E,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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c,IAAI,UAAA,EAAoC;AACxF,UAAA,OAAA,CAAQ,WAAA,CAAY,GAAA,CAAI,UAAA,CAAW,IAAA,CAAK,MAAM,UAAU,CAAA;AACxD,UAAA,OAAA,CAAQ,IAAA,CAAK,aAAA,CAAc,UAAA,CAAW,IAAI,CAAA;AAAA,QAC3C;AAAA,MACD;AAEA,MAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,OAAA,CAAQ,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,IAC1C;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"command.registry.js","sourcesContent":["import { Collection, SlashCommandSubcommandBuilder } from \"discord.js\";\nimport {\n\tBaseRegistry,\n\tCommand,\n\tContextMenuCommand,\n\tSlashCommand,\n\tSlashSubcommand,\n} from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\n\n/**\n * Registry to load and get all commands.\n *\n * @export\n * @class CommandRegistry\n * @typedef {CommandRegistry}\n * @extends {BaseRegistry<AnyCommand>}\n */\nexport default class CommandRegistry extends BaseRegistry<Command> {\n\tprotected items = new Collection<string, Command>();\n\n\t/**\n\t * Load all commands and their subcommands\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"commands\" })]\n\t * @returns {unknown}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"commands\"))) {\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 indexFile = join(fullPath, \"index.ts\");\n\t\t\tconst indexJs = join(fullPath, \"index.js\");\n\n\t\t\tlet commandFile = \"\";\n\t\t\tif (await exists(indexFile)) commandFile = indexFile;\n\t\t\telse if (await exists(indexJs)) commandFile = indexJs;\n\t\t\telse continue;\n\n\t\t\tconst command = (await this.importFile<Command>(commandFile)) as\n\t\t\t\t| SlashCommand\n\t\t\t\t| ContextMenuCommand\n\t\t\t\t| null;\n\t\t\tif (!command || !command.active || !(\"data\" in command)) continue;\n\n\t\t\tif (command.context === \"SlashCommand\" && \"addSubcommand\" in command.data) {\n\t\t\t\tconst subcommandFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\t\tfile =>\n\t\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t\t);\n\n\t\t\t\tfor (const file of subcommandFiles) {\n\t\t\t\t\tconst subcommand = await this.importFile<SlashSubcommand>(join(fullPath, file));\n\t\t\t\t\tif (!subcommand) continue;\n\t\t\t\t\tif (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tif (!command.subcommands) command.subcommands = new Collection<string, SlashSubcommand>();\n\t\t\t\t\tcommand.subcommands.set(subcommand.data.name, subcommand);\n\t\t\t\t\tcommand.data.addSubcommand(subcommand.data);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.items.set(command.data.name, command);\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
@@ -1,6 +0,0 @@
1
- import 'discord.js';
2
- import '../../shared/typings/registry.js';
3
- export { a as default } from '../../index-DbWA_10I.js';
4
- import '../../shared/typings/permissions.js';
5
- import '../../shared/typings/client.js';
6
- import '../builders/util.builders.js';
@@ -1,41 +0,0 @@
1
- import { Collection } from 'discord.js';
2
- import { BaseRegistry } from '../../shared/typings/index.js';
3
- import { resolveUserPath, exists } from '../../shared/utility/functions.js';
4
- import { promises } from 'fs';
5
- import path, { join } from 'node:path';
6
-
7
- class ComponentRegistry extends BaseRegistry {
8
- items = new Collection();
9
- /**
10
- * Load all components.
11
- *
12
- * @async
13
- * @param {string} [directory=getCorePath({ coreDirectory: "components" })]
14
- * @returns {Promise<this>}
15
- */
16
- async load(directory = resolveUserPath(path.join("src", "components"))) {
17
- if (!await exists(directory)) return this;
18
- const entries = await promises.readdir(directory, { withFileTypes: true });
19
- for (const entry of entries) {
20
- const fullPath = join(directory, entry.name);
21
- if (entry.isDirectory()) {
22
- await this.load(fullPath);
23
- continue;
24
- }
25
- if (entry.isFile() && entry.name.endsWith(".js")) {
26
- const event = await this.importFile(fullPath);
27
- if (!event || !("component" in event)) continue;
28
- if (!(event.customId || event.customIdData)) {
29
- console.error(`Component from ${entry.name} does not return customId nor customIdData!`);
30
- continue;
31
- }
32
- this.items.set(event.customId || event.customIdData, event);
33
- }
34
- }
35
- return this;
36
- }
37
- }
38
-
39
- export { ComponentRegistry as default };
40
- //# sourceMappingURL=component.registry.js.map
41
- //# sourceMappingURL=component.registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/registry/component.registry.ts"],"names":["fs"],"mappings":";;;;;;AAcA,MAAO,0BAAwC,YAAA,CAAwB;AAAA,EAC5D,KAAA,GAAQ,IAAI,UAAA,EAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpD,MAAM,KAAK,SAAA,GAAoB,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,YAAY,CAAC,CAAA,EAAkB;AAC9F,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,CAAsB,QAAQ,CAAA;AACvD,QAAA,IAAI,CAAC,KAAA,IAAS,EAAE,WAAA,IAAe,KAAA,CAAA,EAAQ;AAEvC,QAAA,IAAI,EAAE,KAAA,CAAM,QAAA,IAAY,KAAA,CAAM,YAAA,CAAA,EAAe;AAC5C,UAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,eAAA,EAAkB,KAAA,CAAM,IAAI,CAAA,2CAAA,CAA6C,CAAA;AACvF,UAAA;AAAA,QACD;AAEA,QAAA,IAAA,CAAK,MAAM,GAAA,CAAK,KAAA,CAAM,QAAA,IAAY,KAAA,CAAM,cAAyB,KAAK,CAAA;AAAA,MACvE;AAAA,IACD;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"component.registry.js","sourcesContent":["import { Collection } from \"discord.js\";\nimport { BaseRegistry, Component } from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\n\n/**\n * Registry to load and get all components.\n *\n * @export\n * @class ComponentRegistry\n * @typedef {ComponentRegistry}\n * @extends {BaseRegistry<Component>}\n */\nexport default class ComponentRegistry extends BaseRegistry<Component> {\n\tprotected items = new Collection<string, Component>();\n\n\t/**\n\t * Load all components.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"components\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"components\"))): 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<Component>(fullPath);\n\t\t\t\tif (!event || !(\"component\" in event)) continue;\n\n\t\t\t\tif (!(event.customId || event.customIdData)) {\n\t\t\t\t\tconsole.error(`Component from ${entry.name} does not return customId nor customIdData!`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthis.items.set((event.customId || event.customIdData) as string, event);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
@@ -1,6 +0,0 @@
1
- import 'discord.js';
2
- import '../../shared/typings/registry.js';
3
- export { E as default } from '../../index-DbWA_10I.js';
4
- import '../../shared/typings/permissions.js';
5
- import '../../shared/typings/client.js';
6
- import '../builders/util.builders.js';
@@ -1,71 +0,0 @@
1
- import { Collection } from 'discord.js';
2
- import { getCorePath, resolveUserPath, exists } from '../../shared/utility/functions.js';
3
- import { BaseRegistry } from '../../shared/typings/index.js';
4
- import { promises } from 'fs';
5
- import path, { join } from 'node:path';
6
-
7
- class EventRegistry extends BaseRegistry {
8
- items = new Collection();
9
- /**
10
- * Load all preset events, can be overridden by user-provided events.
11
- *
12
- * @async
13
- * @protected
14
- * @returns {Promise<this>}
15
- */
16
- async loadPresetEvents() {
17
- const directory = getCorePath({ coreDirectory: "core/events" });
18
- if (!directory) return;
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.isFile() || !entry.name.endsWith(".js")) continue;
23
- const event = await this.importFile(fullPath);
24
- if (!event) continue;
25
- if (this.items.has(event.name)) continue;
26
- this.items.set(event.name, event);
27
- }
28
- return this;
29
- }
30
- /**
31
- * Load all events.
32
- *
33
- * @async
34
- * @param {string} [directory=getCorePath({ coreDirectory: "events" })]
35
- * @returns {Promise<this>}
36
- */
37
- async load(directory = resolveUserPath(path.join("src", "events"))) {
38
- if (!await exists(directory)) return this;
39
- const entries = await promises.readdir(directory, { withFileTypes: true });
40
- for (const entry of entries) {
41
- const fullPath = join(directory, entry.name);
42
- if (entry.isDirectory()) {
43
- await this.load(fullPath);
44
- continue;
45
- }
46
- if (entry.isFile() && entry.name.endsWith(".js")) {
47
- const event = await this.importFile(fullPath);
48
- if (!event || !("name" in event && "execute" in event)) continue;
49
- this.items.set(event.name, event);
50
- }
51
- }
52
- await this.loadPresetEvents();
53
- return this;
54
- }
55
- /**
56
- * Bind loaded events to their client events respectively.
57
- *
58
- * @param {TriviousClient} client
59
- */
60
- bind(client) {
61
- for (const event of this.items.values()) {
62
- const handler = (...args) => void event.execute(client, ...args);
63
- if (event.once) client.once(event.name, handler);
64
- else client.on(event.name, handler);
65
- }
66
- }
67
- }
68
-
69
- export { EventRegistry as default };
70
- //# sourceMappingURL=event.registry.js.map
71
- //# sourceMappingURL=event.registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/registry/event.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,sBAAoC,YAAA,CAAoB;AAAA,EACpD,KAAA,GAAQ,IAAI,UAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShD,MAAgB,gBAAA,GAAmB;AAClC,IAAA,MAAM,SAAA,GAAY,WAAA,CAAY,EAAE,aAAA,EAAe,eAAe,CAAA;AAC9D,IAAA,IAAI,CAAC,SAAA,EAAW;AAEhB,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;AAC3C,MAAA,IAAI,CAAC,MAAM,MAAA,EAAO,IAAK,CAAC,KAA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CAAI,KAAA,CAAM,IAAA,EAAM,KAAK,CAAA;AAAA,MACjC;AAAA,IACD;AAEA,IAAA,MAAM,KAAK,gBAAA,EAAiB;AAC5B,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, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Event } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.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 preset events, can be overridden by user-provided events.\n\t *\n\t * @async\n\t * @protected\n\t * @returns {Promise<this>}\n\t */\n\tprotected async loadPresetEvents() {\n\t\tconst directory = getCorePath({ coreDirectory: \"core/events\" });\n\t\tif (!directory) return;\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\t\t\tif (!entry.isFile() || !entry.name.endsWith(\".js\")) continue;\n\n\t\t\tconst event = await this.importFile<Event>(fullPath);\n\t\t\tif (!event) continue;\n\n\t\t\tif (this.items.has(event.name)) continue;\n\t\t\tthis.items.set(event.name, event);\n\t\t}\n\n\t\treturn this;\n\t}\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 = resolveUserPath(path.join(\"src\", \"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 || !(\"name\" in event && \"execute\" in event)) continue;\n\n\t\t\t\tthis.items.set(event.name, event);\n\t\t\t}\n\t\t}\n\n\t\tawait this.loadPresetEvents();\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"]}
@@ -1,22 +0,0 @@
1
- import { TriviousClientOptions } from '../../shared/typings/client.js';
2
- import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, T as TriviousClient } from '../../index-DbWA_10I.js';
3
- import 'discord.js';
4
- import '../../shared/typings/permissions.js';
5
- import '../../shared/typings/registry.js';
6
- import '../builders/util.builders.js';
7
-
8
- /**
9
- * Create new registries.
10
- *
11
- * @returns {{ commands: CommandRegistry; components: ComponentRegistry; events: EventRegistry; modules: any; loadAll(options: TriviousClientOptions): any; bind(client: TriviousClient): void; }}
12
- */
13
- declare const registries: () => {
14
- commands: CommandRegistry;
15
- components: ComponentRegistry;
16
- events: EventRegistry;
17
- modules: ModuleRegistry;
18
- loadAll(options: TriviousClientOptions): Promise<void>;
19
- bind(client: TriviousClient): void;
20
- };
21
-
22
- export { registries };
@@ -1,39 +0,0 @@
1
- import { resolveUserPath } from '../../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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/registry/index.ts"],"names":[],"mappings":";;;;;;;AAcO,MAAM,aAA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,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"]}
@@ -1,6 +0,0 @@
1
- import 'discord.js';
2
- import '../../shared/typings/registry.js';
3
- export { M as default } from '../../index-DbWA_10I.js';
4
- import '../../shared/typings/permissions.js';
5
- import '../../shared/typings/client.js';
6
- import '../builders/util.builders.js';
@@ -1,55 +0,0 @@
1
- import { Collection } from 'discord.js';
2
- import { resolveUserPath, exists } from '../../shared/utility/functions.js';
3
- import { BaseRegistry } from '../../shared/typings/index.js';
4
- import { promises } from 'fs';
5
- import path, { 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 = resolveUserPath(path.join("src", "modules"))) {
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()) {
24
- await this.load(fullPath);
25
- continue;
26
- }
27
- if (entry.isFile() && entry.name.endsWith(".js")) {
28
- const moduleEvent = await this.importFile(fullPath);
29
- if (!moduleEvent || !("events" in moduleEvent && "name" in moduleEvent)) 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 [moduleName, 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(moduleName, listener);
48
- }
49
- }
50
- }
51
- }
52
-
53
- export { ModuleRegistry as default };
54
- //# sourceMappingURL=module.registry.js.map
55
- //# sourceMappingURL=module.registry.js.map
@@ -1 +0,0 @@
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,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,SAAS,CAAC,CAAA,EAAkB;AAC3F,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;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,WAAA,GAAc,MAAM,IAAA,CAAK,UAAA,CAAmB,QAAQ,CAAA;AAC1D,QAAA,IAAI,CAAC,WAAA,IAAe,EAAE,QAAA,IAAY,WAAA,IAAe,UAAU,WAAA,CAAA,EAAc;AAEzE,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,YAAY,OAAO,CAAA,IAAK,OAAO,OAAA,CAAQ,GAAA,CAAI,MAAO,CAAA,EAAG;AAChE,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,UAAA,EAAY,QAAQ,CAAA;AAAA,MACxC;AAAA,IACD;AAAA,EACD;AACD","file":"module.registry.js","sourcesContent":["import { Collection } from \"discord.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Module } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport path, { 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 = resolveUserPath(path.join(\"src\", \"modules\"))): 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\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 moduleEvent = await this.importFile<Module>(fullPath);\n\t\t\t\tif (!moduleEvent || !(\"events\" in moduleEvent && \"name\" in moduleEvent)) 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 [moduleName, 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)(moduleName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}