trivious 2.2.4 → 2.3.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 (85) hide show
  1. package/dist/features/builders/utility.builders.js +8 -5
  2. package/dist/features/builders/utility.builders.js.map +1 -1
  3. package/dist/features/client/client.types.js +0 -2
  4. package/dist/features/client/client.types.js.map +1 -1
  5. package/dist/features/client/deploy.client.d.ts +1 -1
  6. package/dist/features/client/deploy.client.js +8 -9
  7. package/dist/features/client/deploy.client.js.map +1 -1
  8. package/dist/features/client/trivious.client.d.ts +1 -1
  9. package/dist/features/client/trivious.client.js +8 -9
  10. package/dist/features/client/trivious.client.js.map +1 -1
  11. package/dist/features/commands/builders.commands.d.ts +5 -5
  12. package/dist/features/commands/builders.commands.js +10 -5
  13. package/dist/features/commands/builders.commands.js.map +1 -1
  14. package/dist/features/commands/commands.types.d.ts +1 -1
  15. package/dist/features/commands/commands.types.js +0 -2
  16. package/dist/features/commands/commands.types.js.map +1 -1
  17. package/dist/features/commands/methods.commands.d.ts +1 -1
  18. package/dist/features/commands/methods.commands.js +4 -3
  19. package/dist/features/commands/methods.commands.js.map +1 -1
  20. package/dist/features/commands/registry.commands.d.ts +1 -1
  21. package/dist/features/commands/registry.commands.js +92 -79
  22. package/dist/features/commands/registry.commands.js.map +1 -1
  23. package/dist/features/components/builders.components.d.ts +1 -1
  24. package/dist/features/components/builders.components.js +7 -5
  25. package/dist/features/components/builders.components.js.map +1 -1
  26. package/dist/features/components/components.types.d.ts +1 -1
  27. package/dist/features/components/components.types.js +3 -3
  28. package/dist/features/components/components.types.js.map +1 -1
  29. package/dist/features/components/registry.components.d.ts +1 -1
  30. package/dist/features/components/registry.components.js +9 -10
  31. package/dist/features/components/registry.components.js.map +1 -1
  32. package/dist/features/customId/customid.types.d.ts +1 -1
  33. package/dist/features/customId/customid.types.js +0 -2
  34. package/dist/features/customId/customid.types.js.map +1 -1
  35. package/dist/features/customId/methods.customid.d.ts +1 -1
  36. package/dist/features/customId/methods.customid.js +4 -5
  37. package/dist/features/customId/methods.customid.js.map +1 -1
  38. package/dist/features/events/builders.events.d.ts +1 -1
  39. package/dist/features/events/builders.events.js +4 -3
  40. package/dist/features/events/builders.events.js.map +1 -1
  41. package/dist/features/events/events.types.d.ts +1 -1
  42. package/dist/features/events/events.types.js +0 -2
  43. package/dist/features/events/events.types.js.map +1 -1
  44. package/dist/features/events/presets/clientReady.d.ts +1 -1
  45. package/dist/features/events/presets/clientReady.js +3 -3
  46. package/dist/features/events/presets/clientReady.js.map +1 -1
  47. package/dist/features/events/presets/interactionCreate.d.ts +1 -1
  48. package/dist/features/events/presets/interactionCreate.js +14 -9
  49. package/dist/features/events/presets/interactionCreate.js.map +1 -1
  50. package/dist/features/events/registry.events.d.ts +1 -1
  51. package/dist/features/events/registry.events.js +10 -10
  52. package/dist/features/events/registry.events.js.map +1 -1
  53. package/dist/features/modules/builders.modules.d.ts +1 -1
  54. package/dist/features/modules/builders.modules.js +3 -3
  55. package/dist/features/modules/builders.modules.js.map +1 -1
  56. package/dist/features/modules/modules.types.d.ts +1 -1
  57. package/dist/features/modules/modules.types.js +0 -2
  58. package/dist/features/modules/modules.types.js.map +1 -1
  59. package/dist/features/modules/registry.modules.d.ts +1 -1
  60. package/dist/features/modules/registry.modules.js +9 -9
  61. package/dist/features/modules/registry.modules.js.map +1 -1
  62. package/dist/features/permissions/methods.permissions.d.ts +1 -1
  63. package/dist/features/permissions/methods.permissions.js +4 -3
  64. package/dist/features/permissions/methods.permissions.js.map +1 -1
  65. package/dist/features/permissions/permissions.types.d.ts +1 -3
  66. package/dist/features/permissions/permissions.types.js +0 -2
  67. package/dist/features/permissions/permissions.types.js.map +1 -1
  68. package/dist/features/structure/index.structure.js +11 -12
  69. package/dist/features/structure/index.structure.js.map +1 -1
  70. package/dist/index.d.ts +1 -1
  71. package/dist/index.js +11 -9
  72. package/dist/index.js.map +1 -1
  73. package/dist/{modules.types-lYoNHt-m.d.ts → modules.types-STECtgbF.d.ts} +12 -6
  74. package/dist/shared/registries.d.ts +1 -1
  75. package/dist/shared/registries.js +7 -8
  76. package/dist/shared/registries.js.map +1 -1
  77. package/dist/shared/typings.d.ts +1 -1
  78. package/dist/shared/typings.js +11 -9
  79. package/dist/shared/typings.js.map +1 -1
  80. package/dist/utility/errors.d.ts +1 -1
  81. package/dist/utility/errors.js +4 -3
  82. package/dist/utility/errors.js.map +1 -1
  83. package/dist/utility/functions.js +7 -7
  84. package/dist/utility/functions.js.map +1 -1
  85. package/package.json +9 -5
@@ -1,12 +1,15 @@
1
- import { ActionRowBuilder, EmbedBuilder } from 'discord.js';
2
-
1
+ import {
2
+ ActionRowBuilder,
3
+ EmbedBuilder
4
+ } from "discord.js";
3
5
  function createActionRow(...builders) {
4
6
  return new ActionRowBuilder().setComponents(...builders);
5
7
  }
6
8
  function createEmbed(data) {
7
9
  return new EmbedBuilder(data);
8
10
  }
9
-
10
- export { createActionRow, createEmbed };
11
- //# sourceMappingURL=utility.builders.js.map
11
+ export {
12
+ createActionRow,
13
+ createEmbed
14
+ };
12
15
  //# sourceMappingURL=utility.builders.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/builders/utility.builders.ts"],"names":[],"mappings":";;AAWO,SAAS,mBAA+D,QAAA,EAAe;AAC7F,EAAA,OAAO,IAAI,gBAAA,EAAoB,CAAE,aAAA,CAAc,GAAG,QAAQ,CAAA;AAC3D;AAKO,SAAS,YAAY,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAI,aAAa,IAAI,CAAA;AAC7B","file":"utility.builders.js","sourcesContent":["import {\n\tActionRowBuilder,\n\tAPIEmbed,\n\tEmbedBuilder,\n\tEmbedData,\n\tMessageActionRowComponentBuilder,\n} from \"discord.js\";\n\n/**\n * Utility action row builder\n */\nexport function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]) {\n\treturn new ActionRowBuilder<T>().setComponents(...builders);\n}\n\n/**\n * Utility embed builder\n */\nexport function createEmbed(data?: EmbedData | APIEmbed) {\n\treturn new EmbedBuilder(data);\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/builders/utility.builders.ts"],"sourcesContent":["import {\n\tActionRowBuilder,\n\tAPIEmbed,\n\tEmbedBuilder,\n\tEmbedData,\n\tMessageActionRowComponentBuilder,\n} from \"discord.js\";\n\n/**\n * Utility action row builder\n */\nexport function createActionRow<T extends MessageActionRowComponentBuilder>(...builders: T[]) {\n\treturn new ActionRowBuilder<T>().setComponents(...builders);\n}\n\n/**\n * Utility embed builder\n */\nexport function createEmbed(data?: EmbedData | APIEmbed) {\n\treturn new EmbedBuilder(data);\n}\n"],"mappings":"AAAA;AAAA,EACC;AAAA,EAEA;AAAA,OAGM;AAKA,SAAS,mBAA+D,UAAe;AAC7F,SAAO,IAAI,iBAAoB,EAAE,cAAc,GAAG,QAAQ;AAC3D;AAKO,SAAS,YAAY,MAA6B;AACxD,SAAO,IAAI,aAAa,IAAI;AAC7B;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=client.types.js.map
3
1
  //# sourceMappingURL=client.types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"client.types.js"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
1
+ import { T as TriviousClient } from '../../modules.types-STECtgbF.js';
2
2
  import 'discord.js';
3
3
  import './client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,9 +1,8 @@
1
- import { createHash } from 'crypto';
2
- import { REST, Routes } from 'discord.js';
3
- import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
4
- import { join, dirname } from 'path';
5
- import { TriviousError } from '../../utility/errors.js';
6
-
1
+ import { TriviousError } from "../../utility/errors.js";
2
+ import { createHash } from "crypto";
3
+ import { REST, Routes } from "discord.js";
4
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
5
+ import { dirname, join } from "path";
7
6
  async function commandDeploy(client) {
8
7
  const { commandHashConfig } = client.trivious;
9
8
  const clientId = process.env[client.trivious.credentials.clientIdReference];
@@ -35,7 +34,7 @@ async function commandDeploy(client) {
35
34
  await rest.put(Routes.applicationCommands(clientId), { body });
36
35
  console.debug(`[Trivious] Deployed ${body.length} commands`);
37
36
  }
38
-
39
- export { commandDeploy as default };
40
- //# sourceMappingURL=deploy.client.js.map
37
+ export {
38
+ commandDeploy as default
39
+ };
41
40
  //# sourceMappingURL=deploy.client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/client/deploy.client.ts"],"names":[],"mappings":";;;;;;AAOA,eAAO,cAAqC,MAAA,EAAwB;AACnE,EAAA,MAAM,EAAE,iBAAA,EAAkB,GAAI,MAAA,CAAO,QAAA;AAErC,EAAA,MAAM,WAAW,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,QAAA,CAAS,YAAY,iBAAiB,CAAA;AAC1E,EAAA,MAAM,QAAQ,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,QAAA,CAAS,YAAY,cAAc,CAAA;AACpE,EAAA,IAAI,CAAC,YAAY,CAAC,KAAA;AACjB,IAAA,MAAM,IAAI,cAAc,gDAAgD,CAAA;AAEzE,EAAA,MAAM,QAAA,GAAW,OAAO,MAAA,CAAO,QAAA;AAC/B,EAAA,MAAM,IAAA,GAAO;AAAA,IACZ,GAAG,SAAS,SAAA,CAAU,GAAA,CAAI,CAAC,OAAA,KAAY,OAAA,CAAQ,IAAA,CAAK,MAAA,EAAQ,CAAA;AAAA,IAC5D,GAAG,SAAS,OAAA,CAAQ,GAAA,CAAI,CAAC,OAAA,KAAY,OAAA,CAAQ,IAAA,CAAK,MAAA,EAAQ;AAAA,GAC3D;AAEA,EAAA,IAAI,iBAAA,IAAqB,kBAAkB,OAAA,EAAS;AACnD,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,iBAAA,CAAkB,kBAAA,IAAsB,QAAQ,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\nimport { REST, Routes } from \"discord.js\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { TriviousError } from \"src/utility/errors.js\";\nimport TriviousClient from \"./trivious.client.js\";\n\nexport default async function commandDeploy(client: TriviousClient) {\n\tconst { commandHashConfig } = client.trivious;\n\n\tconst clientId = process.env[client.trivious.credentials.clientIdReference];\n\tconst token = process.env[client.trivious.credentials.tokenReference];\n\tif (!clientId || !token)\n\t\tthrow new TriviousError(\"Invalid clientId or token environment variable\");\n\n\tconst commands = client.stores.commands;\n\tconst body = [\n\t\t...commands.chatInput.map((command) => command.data.toJSON()),\n\t\t...commands.context.map((command) => command.data.toJSON()),\n\t];\n\n\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\tconst hashFile = join(commandHashConfig.persistentDataPath || \"data\", \"commands.hash\");\n\t\tconst newHash = createHash(\"sha256\")\n\t\t\t.update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString())\n\t\t\t.digest(\"hex\");\n\n\t\tlet oldHash = \"\";\n\t\tif (existsSync(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\n\t\tif (newHash === oldHash) {\n\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment.`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst hashDirectory = dirname(hashFile);\n\t\tif (!existsSync(hashDirectory)) {\n\t\t\tmkdirSync(hashDirectory, { recursive: true });\n\t\t}\n\n\t\twriteFileSync(hashFile, newHash, { encoding: \"utf-8\" });\n\t\tconsole.debug(`[Trivious] Created new command hash: ${hashFile}`);\n\t}\n\n\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\tconsole.debug(`[Trivious] Deployed ${body.length} commands`);\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/client/deploy.client.ts"],"sourcesContent":["import { TriviousError } from \"@utility/errors.js\";\nimport { createHash } from \"crypto\";\nimport { REST, Routes } from \"discord.js\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport TriviousClient from \"./trivious.client.js\";\n\nexport default async function commandDeploy(client: TriviousClient) {\n\tconst { commandHashConfig } = client.trivious;\n\n\tconst clientId = process.env[client.trivious.credentials.clientIdReference];\n\tconst token = process.env[client.trivious.credentials.tokenReference];\n\tif (!clientId || !token)\n\t\tthrow new TriviousError(\"Invalid clientId or token environment variable\");\n\n\tconst commands = client.stores.commands;\n\tconst body = [\n\t\t...commands.chatInput.map((command) => command.data.toJSON()),\n\t\t...commands.context.map((command) => command.data.toJSON()),\n\t];\n\n\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\tconst hashFile = join(commandHashConfig.persistentDataPath || \"data\", \"commands.hash\");\n\t\tconst newHash = createHash(\"sha256\")\n\t\t\t.update(JSON.stringify(body.sort((a, b) => a.name.localeCompare(b.name))).toString())\n\t\t\t.digest(\"hex\");\n\n\t\tlet oldHash = \"\";\n\t\tif (existsSync(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\n\t\tif (newHash === oldHash) {\n\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment.`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst hashDirectory = dirname(hashFile);\n\t\tif (!existsSync(hashDirectory)) {\n\t\t\tmkdirSync(hashDirectory, { recursive: true });\n\t\t}\n\n\t\twriteFileSync(hashFile, newHash, { encoding: \"utf-8\" });\n\t\tconsole.debug(`[Trivious] Created new command hash: ${hashFile}`);\n\t}\n\n\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\tconsole.debug(`[Trivious] Deployed ${body.length} commands`);\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,MAAM,cAAc;AAC7B,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,SAAS,YAAY;AAG9B,eAA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AM,uBAAuB,KAAK,MAAM,WAAW;AAC5D;","names":[]}
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
2
  import './client.types.js';
3
- export { T as default } from '../../modules.types-lYoNHt-m.js';
3
+ export { T as default } from '../../modules.types-STECtgbF.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,9 +1,8 @@
1
- import { Client, Collection } from 'discord.js';
2
- import registries from '../../shared/registries.js';
3
- import structure from '../structure/index.structure.js';
4
- import { TriviousError } from '../../utility/errors.js';
5
- import commandDeploy from './deploy.client.js';
6
-
1
+ import registries from "../../shared/registries.js";
2
+ import { Client, Collection } from "discord.js";
3
+ import structure from "../structure/index.structure.js";
4
+ import { TriviousError } from "../../utility/errors.js";
5
+ import commandDeploy from "./deploy.client.js";
7
6
  class TriviousClient extends Client {
8
7
  trivious;
9
8
  stores;
@@ -55,7 +54,7 @@ class TriviousClient extends Client {
55
54
  await commandDeploy(this);
56
55
  }
57
56
  }
58
-
59
- export { TriviousClient as default };
60
- //# sourceMappingURL=trivious.client.js.map
57
+ export {
58
+ TriviousClient as default
59
+ };
61
60
  //# sourceMappingURL=trivious.client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/client/trivious.client.ts"],"names":[],"mappings":";;;;;;AAeA,MAAO,uBAAqC,MAAA,CAAO;AAAA,EAClD,QAAA;AAAA,EACS,MAAA;AAAA,EAUT,YAAY,OAAA,EAAgC;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAEhB,IAAA,IAAA,CAAK,MAAA,GAAS;AAAA,MACb,QAAA,EAAU;AAAA,QACT,SAAA,EAAW,IAAI,UAAA,EAAW;AAAA,QAC1B,OAAA,EAAS,IAAI,UAAA;AAAW,OACzB;AAAA,MACA,UAAA,EAAY,IAAI,UAAA,EAAW;AAAA,MAC3B,MAAA,EAAQ,IAAI,UAAA,EAAW;AAAA,MACvB,OAAA,EAAS,IAAI,UAAA;AA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A,EAAM,GAAG,CAAA;AAAA,EAC/C;AAAA,EAEA,MAAM,MAAA,GAAS;AACd,IAAA,MAAM,cAAc,IAAI,CAAA;AAAA,EACzB;AACD","file":"trivious.client.js","sourcesContent":["import { Client, Collection } from \"discord.js\";\nimport registries from \"src/shared/registries.js\";\nimport structure from \"../structure/index.structure.js\";\n\nimport {\n\tComponent,\n\tContextCommandData,\n\tEvent,\n\tModule,\n\tSlashCommandData,\n\tTriviousClientOptions,\n} from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport commandDeploy from \"./deploy.client.js\";\n\nexport default class TriviousClient extends Client {\n\ttrivious: TriviousClientOptions;\n\treadonly stores: {\n\t\tcommands: {\n\t\t\tchatInput: Collection<string, SlashCommandData>;\n\t\t\tcontext: Collection<string, ContextCommandData>;\n\t\t};\n\t\tcomponents: Collection<string, Component>;\n\t\tevents: Collection<string, Event>;\n\t\tmodules: Collection<string, Module>;\n\t};\n\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis.trivious = options;\n\n\t\tthis.stores = {\n\t\t\tcommands: {\n\t\t\t\tchatInput: new Collection(),\n\t\t\t\tcontext: new Collection(),\n\t\t\t},\n\t\t\tcomponents: new Collection(),\n\t\t\tevents: new Collection(),\n\t\t\tmodules: new Collection(),\n\t\t};\n\t}\n\n\t/**\n\t * Register, deploy and log into the bot.\n\t *\n\t * @throws {TriviousError} If invalid bot token\n\t */\n\tasync start() {\n\t\tconst token = process.env[this.trivious.credentials.tokenReference];\n\t\tif (!token) {\n\t\t\tthrow new TriviousError(\n\t\t\t\t`Bot token environment variable '${this.trivious.credentials.tokenReference}' does not exist!`,\n\t\t\t\t\"Null environment variable\"\n\t\t\t);\n\t\t}\n\n\t\tawait this.register();\n\t\tawait this.deploy();\n\n\t\ttry {\n\t\t\tawait registries.events.bind(this);\n\t\t\tawait registries.modules.bind(this);\n\t\t} catch (err: any) {\n\t\t\tconst error = new TriviousError(err.message, \"Error during events and modules binds\");\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\tawait this.login(token);\n\t}\n\n\tasync register() {\n\t\tconst dir = structure.resolveRelativePath(this.trivious.corePath);\n\n\t\tawait registries.events.register(this, dir);\n\t\tawait registries.modules.register(this, dir);\n\t\tawait registries.commands.register(this, dir);\n\t\tawait registries.components.register(this, dir);\n\t}\n\n\tasync deploy() {\n\t\tawait commandDeploy(this);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/client/trivious.client.ts"],"sourcesContent":["import registries from \"@shared/registries.js\";\nimport { Client, Collection } from \"discord.js\";\nimport structure from \"../structure/index.structure.js\";\n\nimport {\n\tComponent,\n\tContextCommandData,\n\tEvent,\n\tModule,\n\tSlashCommandData,\n\tTriviousClientOptions,\n} from \"@typings\";\nimport { TriviousError } from \"@utility/errors.js\";\nimport commandDeploy from \"./deploy.client.js\";\n\nexport default class TriviousClient extends Client {\n\ttrivious: TriviousClientOptions;\n\treadonly stores: {\n\t\tcommands: {\n\t\t\tchatInput: Collection<string, SlashCommandData>;\n\t\t\tcontext: Collection<string, ContextCommandData>;\n\t\t};\n\t\tcomponents: Collection<string, Component>;\n\t\tevents: Collection<string, Event>;\n\t\tmodules: Collection<string, Module>;\n\t};\n\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis.trivious = options;\n\n\t\tthis.stores = {\n\t\t\tcommands: {\n\t\t\t\tchatInput: new Collection(),\n\t\t\t\tcontext: new Collection(),\n\t\t\t},\n\t\t\tcomponents: new Collection(),\n\t\t\tevents: new Collection(),\n\t\t\tmodules: new Collection(),\n\t\t};\n\t}\n\n\t/**\n\t * Register, deploy and log into the bot.\n\t *\n\t * @throws {TriviousError} If invalid bot token\n\t */\n\tasync start() {\n\t\tconst token = process.env[this.trivious.credentials.tokenReference];\n\t\tif (!token) {\n\t\t\tthrow new TriviousError(\n\t\t\t\t`Bot token environment variable '${this.trivious.credentials.tokenReference}' does not exist!`,\n\t\t\t\t\"Null environment variable\"\n\t\t\t);\n\t\t}\n\n\t\tawait this.register();\n\t\tawait this.deploy();\n\n\t\ttry {\n\t\t\tawait registries.events.bind(this);\n\t\t\tawait registries.modules.bind(this);\n\t\t} catch (err: any) {\n\t\t\tconst error = new TriviousError(err.message, \"Error during events and modules binds\");\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\tawait this.login(token);\n\t}\n\n\tasync register() {\n\t\tconst dir = structure.resolveRelativePath(this.trivious.corePath);\n\n\t\tawait registries.events.register(this, dir);\n\t\tawait registries.modules.register(this, dir);\n\t\tawait registries.commands.register(this, dir);\n\t\tawait registries.components.register(this, dir);\n\t}\n\n\tasync deploy() {\n\t\tawait commandDeploy(this);\n\t}\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,SAAS,QAAQ,kBAAkB;AACnC,OAAO,eAAe;AAUtB,SAAS,qBAAqB;AAC9B,OAAO,mBAAmB;AAE1B,MAAO,uBAAqC,OAAO;AAAA,EAClD;AAAA,EACS;AAAA,EAUT,YAAY,SAAgC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW;AAEhB,SAAK,SAAS;AAAA,MACb,UAAU;AAAA,QACT,WAAW,IAAI,WAAW;AAAA,QAC1B,SAAS,IAAI,WAAW;AAAA,MACzB;AAAA,MACA,YAAY,IAAI,WAAW;AAAA,MAC3B,QAAQ,IAAI,WAAW;AAAA,MACvB,SAAS,IAAI,WAAW;AAAA,IACzB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAQ;AACb,UAAM,QAAQ,QAAQ,IAAI,KAAK,SAAS,YAAY,cAAc;AAClE,QAAI,CAAC,OAAO;AACX,YAAM,IAAI;AAAA,QACT,mCAAmC,KAAK,SAAS,YAAY,cAAc;AAAA,QAC3E;AAAA,MACD;AAAA,IACD;AAEA,UAAM,KAAK,SAAS;AACpB,UAAM,KAAK,OAAO;AAElB,QAAI;AACH,YAAM,WAAW,OAAO,KAAK,IAAI;AACjC,YAAM,WAAW,QAAQ,KAAK,IAAI;AAAA,IACnC,SAAS,KAAU;AAClB,YAAM,QAAQ,IAAI,cAAc,IAAI,SAAS,uCAAuC;AACpF,cAAQ,MAAM,KAAK;AAAA,IACpB;AAEA,UAAM,KAAK,MAAM,KAAK;AAAA,EACvB;AAAA,EAEA,MAAM,WAAW;AAChB,UAAM,MAAM,UAAU,oBAAoB,KAAK,SAAS,QAAQ;AAEhE,UAAM,WAAW,OAAO,SAAS,MAAM,GAAG;AAC1C,UAAM,WAAW,QAAQ,SAAS,MAAM,GAAG;AAC3C,UAAM,WAAW,SAAS,SAAS,MAAM,GAAG;AAC5C,UAAM,WAAW,WAAW,SAAS,MAAM,GAAG;AAAA,EAC/C;AAAA,EAEA,MAAM,SAAS;AACd,UAAM,cAAc,IAAI;AAAA,EACzB;AACD;","names":[]}
@@ -1,4 +1,4 @@
1
- import { h as ContextCommandData, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData } from '../../modules.types-lYoNHt-m.js';
1
+ import { j as ContextCommandData, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData } from '../../modules.types-STECtgbF.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -7,13 +7,13 @@ declare function createSlashCommand(data: Omit<SlashCommandData, "context" | "co
7
7
  /**
8
8
  * @deprecated Use createSlashSubcommand instead
9
9
  */
10
- declare function createSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType" | "parent">): SlashSubcommandData;
11
- declare function createSlashSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType" | "parent">): SlashSubcommandData;
10
+ declare function createSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType">): SlashSubcommandData;
11
+ declare function createSlashSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType">): SlashSubcommandData;
12
12
  /**
13
13
  * @deprecated Use createSlashSubcommandGroup instead
14
14
  */
15
- declare function createSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "parent" | "subcommands">): SlashSubcommandGroupData;
16
- declare function createSlashSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "parent" | "subcommands">): SlashSubcommandGroupData;
15
+ declare function createSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "subcommands">): SlashSubcommandGroupData;
16
+ declare function createSlashSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "subcommands">): SlashSubcommandGroupData;
17
17
  declare function createMessageContextCommand(data: Omit<ContextCommandData<"Message">, "commandType">): ContextCommandData<"Message">;
18
18
  declare function createUserContextCommand(data: Omit<ContextCommandData<"User">, "commandType">): ContextCommandData<"User">;
19
19
 
@@ -1,5 +1,4 @@
1
- import { ApplicationCommandType, Collection } from 'discord.js';
2
-
1
+ import { ApplicationCommandType, Collection } from "discord.js";
3
2
  function createSlashCommand(data) {
4
3
  return {
5
4
  ...data,
@@ -47,7 +46,13 @@ function createUserContextCommand(data) {
47
46
  commandType: ApplicationCommandType.User
48
47
  };
49
48
  }
50
-
51
- export { createMessageContextCommand, createSlashCommand, createSlashSubcommand, createSlashSubcommandGroup, createSubcommand, createSubcommandGroup, createUserContextCommand };
52
- //# sourceMappingURL=builders.commands.js.map
49
+ export {
50
+ createMessageContextCommand,
51
+ createSlashCommand,
52
+ createSlashSubcommand,
53
+ createSlashSubcommandGroup,
54
+ createSubcommand,
55
+ createSubcommandGroup,
56
+ createUserContextCommand
57
+ };
53
58
  //# sourceMappingURL=builders.commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/commands/builders.commands.ts"],"names":[],"mappings":";;AAQO,SAAS,mBACf,IAAA,EACmB;AACnB,EAAA,OAAO;AAAA,IACN,GAAG,IAAA;AAAA,IACH,OAAA,EAAS,cAAA;AAAA,IACT,aAAa,sBAAA,CAAuB;AAAA,GACrC;AACD;AAKO,SAAS,iBACf,IAAA,EACsB;AACtB,EAAA,OAAO;AAAA,IACN,GAAG,IAAA;AAAA,IACH,OAAA,EAAS,iBAAA;AAAA,IACT,aAAa,sBAAA,CAAuB;AAAA,GACrC;AACD;AAEO,SAAS,sBACf,IAAA,EACsB;AACtB,EAAA,OAAO;AAAA,IACN,GAAG,IAAA;AAAA,IACH,OAAA,EAAS,iBAAA;AAAA,IACT,aAAa,sBAAA,CAAuB;AAAA,GACrC;AACD;AAKO,SAAS,sBACf,IAAA,EAC2B;AAC3B,EAAA,OAAO;AAAA,IACN,GAAG,IAAA;AAAA,IACH,OAAA,EAAS,sBAAA;AAAA,IACT,WAAA,EAAa,IAAI,UAAA;AAAW,GAC7B;AACD;AAEO,SAAS,2BACf,IAAA,EAC2B;AAC3B,EAAA,OAAO;AAAA,IACN,GAAG,IAAA;AAAA,IACH,OAAA,EAAS,sBAAA;AAAA,IACT,WAAA,EAAa,IAAI,UAAA;AAAW,GAC7B;AACD;AAEO,SAAS,4BACf,IAAA,EACgC;AAChC,EAAA,OAAO;AAAA,IACN,GAAG,IAAA;AAAA,IACH,aAAa,sBAAA,CAAuB;AAAA,GACrC;AACD;AAEO,SAAS,yBACf,IAAA,EAC6B;AAC7B,EAAA,OAAO;AAAA,IACN,GAAG,IAAA;AAAA,IACH,aAAa,sBAAA,CAAuB;AAAA,GACrC;AACD","file":"builders.commands.js","sourcesContent":["import {\n\tContextCommandData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n} from \"#typings\";\nimport { ApplicationCommandType, Collection } from \"discord.js\";\n\nexport function createSlashCommand(\n\tdata: Omit<SlashCommandData, \"context\" | \"commandType\" | \"subcommands\" | \"subcommandGroups\">\n): SlashCommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashCommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashCommandData;\n}\n\n/**\n * @deprecated Use createSlashSubcommand instead\n */\nexport function createSubcommand(\n\tdata: Omit<SlashSubcommandData, \"context\" | \"commandType\" | \"parent\">\n): SlashSubcommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashSubcommandData;\n}\n\nexport function createSlashSubcommand(\n\tdata: Omit<SlashSubcommandData, \"context\" | \"commandType\" | \"parent\">\n): SlashSubcommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashSubcommandData;\n}\n\n/**\n * @deprecated Use createSlashSubcommandGroup instead\n */\nexport function createSubcommandGroup(\n\tdata: Omit<SlashSubcommandGroupData, \"context\" | \"parent\" | \"subcommands\">\n): SlashSubcommandGroupData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommandGroup\",\n\t\tsubcommands: new Collection(),\n\t} satisfies SlashSubcommandGroupData;\n}\n\nexport function createSlashSubcommandGroup(\n\tdata: Omit<SlashSubcommandGroupData, \"context\" | \"parent\" | \"subcommands\">\n): SlashSubcommandGroupData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommandGroup\",\n\t\tsubcommands: new Collection(),\n\t} satisfies SlashSubcommandGroupData;\n}\n\nexport function createMessageContextCommand(\n\tdata: Omit<ContextCommandData<\"Message\">, \"commandType\">\n): ContextCommandData<\"Message\"> {\n\treturn {\n\t\t...data,\n\t\tcommandType: ApplicationCommandType.Message,\n\t} satisfies ContextCommandData<\"Message\">;\n}\n\nexport function createUserContextCommand(\n\tdata: Omit<ContextCommandData<\"User\">, \"commandType\">\n): ContextCommandData<\"User\"> {\n\treturn {\n\t\t...data,\n\t\tcommandType: ApplicationCommandType.User,\n\t} satisfies ContextCommandData<\"User\">;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/commands/builders.commands.ts"],"sourcesContent":["import {\n\tContextCommandData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n} from \"@typings\";\nimport { ApplicationCommandType, Collection } from \"discord.js\";\n\nexport function createSlashCommand(\n\tdata: Omit<SlashCommandData, \"context\" | \"commandType\" | \"subcommands\" | \"subcommandGroups\">\n): SlashCommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashCommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashCommandData;\n}\n\n/**\n * @deprecated Use createSlashSubcommand instead\n */\nexport function createSubcommand(\n\tdata: Omit<SlashSubcommandData, \"context\" | \"commandType\">\n): SlashSubcommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashSubcommandData;\n}\n\nexport function createSlashSubcommand(\n\tdata: Omit<SlashSubcommandData, \"context\" | \"commandType\">\n): SlashSubcommandData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommand\",\n\t\tcommandType: ApplicationCommandType.ChatInput,\n\t} satisfies SlashSubcommandData;\n}\n\n/**\n * @deprecated Use createSlashSubcommandGroup instead\n */\nexport function createSubcommandGroup(\n\tdata: Omit<SlashSubcommandGroupData, \"context\" | \"subcommands\">\n): SlashSubcommandGroupData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommandGroup\",\n\t\tsubcommands: new Collection(),\n\t} satisfies SlashSubcommandGroupData;\n}\n\nexport function createSlashSubcommandGroup(\n\tdata: Omit<SlashSubcommandGroupData, \"context\" | \"subcommands\">\n): SlashSubcommandGroupData {\n\treturn {\n\t\t...data,\n\t\tcontext: \"SlashSubcommandGroup\",\n\t\tsubcommands: new Collection(),\n\t} satisfies SlashSubcommandGroupData;\n}\n\nexport function createMessageContextCommand(\n\tdata: Omit<ContextCommandData<\"Message\">, \"commandType\">\n): ContextCommandData<\"Message\"> {\n\treturn {\n\t\t...data,\n\t\tcommandType: ApplicationCommandType.Message,\n\t} satisfies ContextCommandData<\"Message\">;\n}\n\nexport function createUserContextCommand(\n\tdata: Omit<ContextCommandData<\"User\">, \"commandType\">\n): ContextCommandData<\"User\"> {\n\treturn {\n\t\t...data,\n\t\tcommandType: ApplicationCommandType.User,\n\t} satisfies ContextCommandData<\"User\">;\n}\n"],"mappings":"AAMA,SAAS,wBAAwB,kBAAkB;AAE5C,SAAS,mBACf,MACmB;AACnB,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,uBAAuB;AAAA,EACrC;AACD;AAKO,SAAS,iBACf,MACsB;AACtB,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,uBAAuB;AAAA,EACrC;AACD;AAEO,SAAS,sBACf,MACsB;AACtB,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,uBAAuB;AAAA,EACrC;AACD;AAKO,SAAS,sBACf,MAC2B;AAC3B,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,IAAI,WAAW;AAAA,EAC7B;AACD;AAEO,SAAS,2BACf,MAC2B;AAC3B,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,IAAI,WAAW;AAAA,EAC7B;AACD;AAEO,SAAS,4BACf,MACgC;AAChC,SAAO;AAAA,IACN,GAAG;AAAA,IACH,aAAa,uBAAuB;AAAA,EACrC;AACD;AAEO,SAAS,yBACf,MAC6B;AAC7B,SAAO;AAAA,IACN,GAAG;AAAA,IACH,aAAa,uBAAuB;AAAA,EACrC;AACD;","names":[]}
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
- export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CommandFlags, c as CommandFunction, h as ContextCommandData, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData } from '../../modules.types-lYoNHt-m.js';
2
+ export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CollatedCommandData, c as CommandFlags, d as CommandFunction, e as CommandSetData, j as ContextCommandData, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData } from '../../modules.types-STECtgbF.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.types.js';
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=commands.types.js.map
3
1
  //# sourceMappingURL=commands.types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"commands.types.js"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { ChatInputCommandInteraction, Interaction, CacheType, InteractionReplyOptions, InteractionResponse, InteractionEditReplyOptions, Message, MessagePayload } from 'discord.js';
2
- import { T as TriviousClient, S as SlashCommandData, b as CommandFlags } from '../../modules.types-lYoNHt-m.js';
2
+ import { T as TriviousClient, S as SlashCommandData, c as CommandFlags } from '../../modules.types-STECtgbF.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
 
@@ -78,7 +78,8 @@ async function handleSlashCommand(client, command, interaction) {
78
78
  });
79
79
  }
80
80
  }
81
-
82
- export { handleSlashCommand, interactionReply };
83
- //# sourceMappingURL=methods.commands.js.map
81
+ export {
82
+ handleSlashCommand,
83
+ interactionReply
84
+ };
84
85
  //# sourceMappingURL=methods.commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/commands/methods.commands.ts"],"names":[],"mappings":"AA8BA,eAAsB,iBAAiB,OAAA,EAIpC;AACF,EAAA,MAAM,EAAE,WAAA,EAAa,YAAA,EAAc,KAAA,EAAM,GAAI,OAAA;AAC7C,EAAA,IAAI,EAAE,WAAW,WAAA,CAAA,EAAc;AAE/B,EAAA,MAAM,OAAA,GAAU,YAAA;AAChB,EAAA,IAAI,OAAO,QAAA,CAAS,gBAAgB,GAAG,OAAA,CAAQ,KAAA,GAAQ,CAAC,WAAW,CAAA;AAEnE,EAAA,IAAI,WAAA,CAAY,QAAA,IAAY,WAAA,CAAY,OAAA,EAAS;AAChD,IAAA,IAAI,KAAA,EAAO,SAAS,UAAU,CAAA,SAAU,MAAM,WAAA,CAAY,SAAS,OAAO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AAQ,KAAK,CAAA;AACrE,IAAA,OAAO,MAAM,eAAA,CAAgB,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,EACzD,CAAA,MAAO;AACN,IAAA,MAAM,gBAAA,CAAiB;AAAA,MACtB,WAAA;AAAA,MACA,KAAA,EAAO,CAAC,gBAAgB,CAAA;AAAA,MACxB,YAAA,EAAc,EAAE,OAAA,EAAS,4DAAA;AAA6D,KACtF,CAAA;AAAA,EACF;AACD","file":"methods.commands.js","sourcesContent":["import { CommandFlags, SlashCommandData, TriviousClient } from \"#typings\";\nimport {\n\tCacheType,\n\tChatInputCommandInteraction,\n\tInteraction,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tInteractionResponse,\n\tMessage,\n\tMessagePayload,\n} from \"discord.js\";\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionReplyOptions;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<InteractionResponse<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionEditReplyOptions;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<Message<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: MessagePayload;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<InteractionResponse<boolean> | Message<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionReplyOptions | InteractionEditReplyOptions | MessagePayload;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}) {\n\tconst { interaction, replyPayload, flags } = options;\n\tif (!(\"reply\" in interaction)) return;\n\n\tconst payload = replyPayload as InteractionReplyOptions;\n\tif (flags?.includes(\"EphemeralReply\")) payload.flags = [\"Ephemeral\"];\n\n\tif (interaction.deferred || interaction.replied) {\n\t\tif (flags?.includes(\"FollowUp\")) return await interaction.followUp(payload);\n\t\treturn await interaction.editReply(payload as InteractionEditReplyOptions);\n\t}\n\n\treturn await interaction.reply(payload);\n}\n\nasync function handleFlags(interaction: ChatInputCommandInteraction, flags?: CommandFlags[]) {\n\tif (flags?.includes(\"Cached\") && !interaction.inCachedGuild()) return;\n\tif (flags?.includes(\"ExpectModal\")) return;\n\tif (flags?.includes(\"DeferReply\")) {\n\t\tawait interactionReply({\n\t\t\tinteraction,\n\t\t\tflags: flags,\n\t\t\treplyPayload: { content: \"Processing command...\" },\n\t\t});\n\t}\n}\n\nexport async function handleSlashCommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData,\n\tinteraction: ChatInputCommandInteraction\n) {\n\tconst { options } = interaction;\n\n\tconst subcommandGroup = options.getSubcommandGroup(false);\n\tconst subcommand = options.getSubcommand(false);\n\n\tif (!subcommandGroup && !subcommand) {\n\t\tawait handleFlags(interaction, command.flags);\n\n\t\tif (\"run\" in command && command.run) {\n\t\t\ttry {\n\t\t\t\tawait command.run(client, interaction);\n\t\t\t} catch (err: any) {\n\t\t\t\tconsole.error(err);\n\t\t\t}\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (subcommandGroup && command.subcommandGroups && subcommand) {\n\t\tconst foundGroup = command.subcommandGroups.get(subcommandGroup);\n\t\tif (!foundGroup) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: {\n\t\t\t\t\tcontent: \"Subcommand group is outdated, inactive, or does not have a handler!\",\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst foundSubcommand = foundGroup.subcommands.get(subcommand);\n\t\tif (!foundSubcommand) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: { content: \"Subcommand is outdated, inactive, or does not have a handler!\" },\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait handleFlags(interaction, foundSubcommand.flags || command.flags);\n\t\treturn await foundSubcommand.execute(client, interaction);\n\t} else if (subcommand && command.subcommands) {\n\t\tconst foundSubcommand = command.subcommands.get(subcommand);\n\t\tif (!foundSubcommand) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: { content: \"Subcommand is outdated, inactive, or does not have a handler!\" },\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait handleFlags(interaction, foundSubcommand.flags || command.flags);\n\t\treturn await foundSubcommand.execute(client, interaction);\n\t} else {\n\t\tawait interactionReply({\n\t\t\tinteraction,\n\t\t\tflags: [\"EphemeralReply\"],\n\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/commands/methods.commands.ts"],"sourcesContent":["import { CommandFlags, SlashCommandData, TriviousClient } from \"@typings\";\nimport {\n\tCacheType,\n\tChatInputCommandInteraction,\n\tInteraction,\n\tInteractionEditReplyOptions,\n\tInteractionReplyOptions,\n\tInteractionResponse,\n\tMessage,\n\tMessagePayload,\n} from \"discord.js\";\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionReplyOptions;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<InteractionResponse<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionEditReplyOptions;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<Message<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: MessagePayload;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}): Promise<InteractionResponse<boolean> | Message<boolean>>;\n\nexport async function interactionReply(options: {\n\tinteraction: Interaction<CacheType>;\n\treplyPayload: InteractionReplyOptions | InteractionEditReplyOptions | MessagePayload;\n\tflags?: (CommandFlags | \"FollowUp\")[];\n}) {\n\tconst { interaction, replyPayload, flags } = options;\n\tif (!(\"reply\" in interaction)) return;\n\n\tconst payload = replyPayload as InteractionReplyOptions;\n\tif (flags?.includes(\"EphemeralReply\")) payload.flags = [\"Ephemeral\"];\n\n\tif (interaction.deferred || interaction.replied) {\n\t\tif (flags?.includes(\"FollowUp\")) return await interaction.followUp(payload);\n\t\treturn await interaction.editReply(payload as InteractionEditReplyOptions);\n\t}\n\n\treturn await interaction.reply(payload);\n}\n\nasync function handleFlags(interaction: ChatInputCommandInteraction, flags?: CommandFlags[]) {\n\tif (flags?.includes(\"Cached\") && !interaction.inCachedGuild()) return;\n\tif (flags?.includes(\"ExpectModal\")) return;\n\tif (flags?.includes(\"DeferReply\")) {\n\t\tawait interactionReply({\n\t\t\tinteraction,\n\t\t\tflags: flags,\n\t\t\treplyPayload: { content: \"Processing command...\" },\n\t\t});\n\t}\n}\n\nexport async function handleSlashCommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData,\n\tinteraction: ChatInputCommandInteraction\n) {\n\tconst { options } = interaction;\n\n\tconst subcommandGroup = options.getSubcommandGroup(false);\n\tconst subcommand = options.getSubcommand(false);\n\n\tif (!subcommandGroup && !subcommand) {\n\t\tawait handleFlags(interaction, command.flags);\n\n\t\tif (\"run\" in command && command.run) {\n\t\t\ttry {\n\t\t\t\tawait command.run(client, interaction);\n\t\t\t} catch (err: any) {\n\t\t\t\tconsole.error(err);\n\t\t\t}\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (subcommandGroup && command.subcommandGroups && subcommand) {\n\t\tconst foundGroup = command.subcommandGroups.get(subcommandGroup);\n\t\tif (!foundGroup) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: {\n\t\t\t\t\tcontent: \"Subcommand group is outdated, inactive, or does not have a handler!\",\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst foundSubcommand = foundGroup.subcommands.get(subcommand);\n\t\tif (!foundSubcommand) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: { content: \"Subcommand is outdated, inactive, or does not have a handler!\" },\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait handleFlags(interaction, foundSubcommand.flags || command.flags);\n\t\treturn await foundSubcommand.execute(client, interaction);\n\t} else if (subcommand && command.subcommands) {\n\t\tconst foundSubcommand = command.subcommands.get(subcommand);\n\t\tif (!foundSubcommand) {\n\t\t\tawait interactionReply({\n\t\t\t\tinteraction,\n\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\treplyPayload: { content: \"Subcommand is outdated, inactive, or does not have a handler!\" },\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait handleFlags(interaction, foundSubcommand.flags || command.flags);\n\t\treturn await foundSubcommand.execute(client, interaction);\n\t} else {\n\t\tawait interactionReply({\n\t\t\tinteraction,\n\t\t\tflags: [\"EphemeralReply\"],\n\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t});\n\t}\n}\n"],"mappings":"AA8BA,eAAsB,iBAAiB,SAIpC;AACF,QAAM,EAAE,aAAa,cAAc,MAAM,IAAI;AAC7C,MAAI,EAAE,WAAW,aAAc;AAE/B,QAAM,UAAU;AAChB,MAAI,OAAO,SAAS,gBAAgB,EAAG,SAAQ,QAAQ,CAAC,WAAW;AAEnE,MAAI,YAAY,YAAY,YAAY,SAAS;AAChD,QAAI,OAAO,SAAS,UAAU,EAAG,QAAO,MAAM,YAAY,SAAS,OAAO;AAC1E,WAAO,MAAM,YAAY,UAAU,OAAsC;AAAA,EAC1E;AAEA,SAAO,MAAM,YAAY,MAAM,OAAO;AACvC;AAEA,eAAe,YAAY,aAA0C,OAAwB;AAC5F,MAAI,OAAO,SAAS,QAAQ,KAAK,CAAC,YAAY,cAAc,EAAG;AAC/D,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C1D,QAAI,CAAC,iBAAiB;AACrB,YAAM,iBAAiB;AAAA,QACtB;AAAA,QACA,OAAO,CAAC,gBAAgB;AAAA,QACxB,cAAc,EAAE,SAAS,gEAAgE;AAAA,MAC1F,CAAC;AACD;AAAA,IACD;AAEA,UAAM,YAAY,aAAa,gBAAgB,SAAS,QAAQ,KAAK;AACrE,WAAO,MAAM,gBAAgB,QAAQ,QAAQ,WAAW;AAAA,EACzD,OAAO;AACN,UAAM,iBAAiB;AAAA,MACtB;AAAA,MACA,OAAO,CAAC,gBAAgB;AAAA,MACxB,cAAc,EAAE,SAAS,6DAA6D;AAAA,IACvF,CAAC;AAAA,EACF;AACD;","names":[]}
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
1
+ import { T as TriviousClient } from '../../modules.types-STECtgbF.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,105 +1,118 @@
1
- import { TriviousError } from '../../utility/errors.js';
2
- import { importFile } from '../../utility/functions.js';
3
- import { Collection, ApplicationCommandType } from 'discord.js';
4
- import { existsSync, promises } from 'fs';
5
- import path, { join } from 'path';
6
-
7
- function validateCommand(command, expects) {
8
- if (!("active" in command && "commandType" in command)) return false;
9
- if (!command.active) return false;
10
- return expects(command);
1
+ import { TriviousError } from "../../utility/errors.js";
2
+ import { importFile } from "../../utility/functions.js";
3
+ import { Collection } from "discord.js";
4
+ import { existsSync, promises as fs } from "fs";
5
+ import path from "path";
6
+ async function parseBase(input, expects) {
7
+ if (typeof input !== "string") {
8
+ if (expects && !expects(input)) return null;
9
+ return input;
10
+ }
11
+ if (!existsSync(input)) return null;
12
+ const base = await importFile(input);
13
+ if (!base) return null;
14
+ if (expects && !expects(base)) return null;
15
+ return base;
11
16
  }
12
- async function parseSlashSubcommands(directory, data) {
13
- const subcommands = new Collection();
14
- if (!("addSubcommand" in data.data)) return subcommands;
15
- const files = promises.glob(join(directory, "./*.js"));
17
+ async function parseDirectory(data, directory) {
18
+ const files = fs.glob(path.join(directory, "*.{js,ts}"));
16
19
  for await (const file of files) {
17
- const subcommand = await importFile(file);
18
- if (!subcommand || !validateCommand(subcommand, (subcmd) => subcmd.context === "SlashSubcommand"))
19
- continue;
20
- subcommand.parent = data;
21
- data.data.addSubcommand(subcommand.data);
22
- if (subcommands.has(subcommand.data.name))
23
- console.warn(
24
- `[Trivious] Subcommand '${subcommand.data.name}' under ${data.context} '${data.data.name}' has a duplicate and has been overridden`
25
- );
26
- subcommands.set(subcommand.data.name, subcommand);
20
+ const base = await parseBase(
21
+ file,
22
+ (base2) => "context" in base2 && !!base2.context
23
+ );
24
+ if (!base) continue;
25
+ const targetSet = data[base.context];
26
+ if (targetSet) targetSet.add([base, directory]);
27
27
  }
28
- if (subcommands.size > 0) data.subcommands = subcommands;
29
- return subcommands;
30
28
  }
31
- async function parseSlashCommand(file, parentDir, subdirectories) {
32
- if (!existsSync(file)) return;
33
- const command = await importFile(file);
34
- if (!command || !validateCommand(command, (cmd) => cmd.context === "SlashCommand") || !("addSubcommand" in command.data))
35
- return;
36
- await parseSlashSubcommands(parentDir, command);
37
- for (const subdir of subdirectories) {
38
- const indexFile = path.resolve(subdir.parentPath, subdir.name, "index.js");
39
- if (!existsSync(indexFile)) continue;
40
- const group = await importFile(indexFile);
41
- if (!group || !("context" in group && "addSubcommandGroup" in command.data) || group.context !== "SlashSubcommandGroup")
42
- continue;
43
- group.parent = command;
44
- if (!command.subcommandGroups) command.subcommandGroups = new Collection();
45
- await parseSlashSubcommands(join(subdir.parentPath, subdir.name), group);
46
- if (group.subcommands.size > 0) {
47
- if (command.subcommandGroups.has(group.data.name))
48
- console.warn(
49
- `[Trivious] SubcommandGroup '${group.data.name}' under SlashCommand '${command.data.name}' has a duplicate and has been overridden`
50
- );
51
- command.data.addSubcommandGroup(group.data);
52
- command.subcommandGroups.set(group.data.name, group);
29
+ function isSubdirectoryOf(directory, subdirectory) {
30
+ const relative = path.relative(path.resolve(directory), path.resolve(subdirectory));
31
+ return !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
32
+ }
33
+ function getDataFromCommandSet(set, options) {
34
+ const { matchData, matchParentDirectory } = options;
35
+ if (!matchData && !matchParentDirectory) return void 0;
36
+ const array = Array.from(set.entries());
37
+ let bestMatch;
38
+ let bestDepth = -1;
39
+ for (const entry of array) {
40
+ const [key, [data, directory]] = entry;
41
+ if (matchData && data === matchData) return key[0];
42
+ if (!matchParentDirectory) continue;
43
+ const isExact = directory === matchParentDirectory;
44
+ const isParent = isSubdirectoryOf(directory, matchParentDirectory);
45
+ if (isExact || isParent) {
46
+ const depth = directory.split(/\\|\//).length;
47
+ if (depth > bestDepth) {
48
+ bestDepth = depth;
49
+ bestMatch = entry[0];
50
+ }
53
51
  }
54
52
  }
55
- return command;
53
+ return bestMatch?.[0];
56
54
  }
57
- async function parseContextCommands(parentDir) {
58
- const collection = new Collection();
59
- const files = promises.glob(join(parentDir, "**/*.js"));
60
- for await (const file of files) {
61
- const contextCommand = await importFile(file);
62
- if (!contextCommand || !validateCommand(
63
- contextCommand,
64
- (cmd) => cmd.commandType === ApplicationCommandType.Message || cmd.commandType === ApplicationCommandType.User
65
- ))
55
+ async function setChildrenToParents(data) {
56
+ for (const [group, directory] of data.SlashSubcommandGroup) {
57
+ const slashCommand = group.parent || getDataFromCommandSet(data.SlashCommand, { matchParentDirectory: directory });
58
+ if (!slashCommand || !("addSubcommandGroup" in slashCommand.data)) {
59
+ console.warn("[Trivious] Could not find parent for subcommand group", group.data.name);
66
60
  continue;
67
- contextCommand.data.setType(contextCommand.commandType);
68
- collection.set(contextCommand.data.name, contextCommand);
61
+ }
62
+ if (!slashCommand.subcommandGroups) slashCommand.subcommandGroups = new Collection();
63
+ if (slashCommand.subcommandGroups.has(group.data.name))
64
+ console.warn(
65
+ `[Trivious] SubcommandGroup '${group.data.name}' under SlashCommand '${slashCommand.data.name}' has been overridden by a group with the same name`
66
+ );
67
+ group.parent = slashCommand;
68
+ slashCommand.subcommandGroups.set(group.data.name, group);
69
+ slashCommand.data.addSubcommandGroup(group.data);
69
70
  }
70
- return collection;
71
- }
72
- async function registerDirectory(client, parentDir) {
73
- const entries = await promises.readdir(parentDir, { withFileTypes: true });
74
- const subdirectories = entries.filter((entry) => entry.isDirectory());
75
- const indexFile = path.resolve(parentDir, "index.js");
76
- const slashCommand = await parseSlashCommand(indexFile, parentDir, subdirectories);
77
- if (slashCommand) {
78
- if (client.stores.commands.chatInput.has(slashCommand.data.name))
71
+ for (const [subcommand, directory] of data.SlashSubcommand) {
72
+ const parent = subcommand.parent || getDataFromCommandSet(data.SlashSubcommandGroup, { matchParentDirectory: directory }) || getDataFromCommandSet(data.SlashCommand, { matchParentDirectory: directory });
73
+ if (!parent || !("addSubcommand" in parent.data)) {
74
+ console.warn("[Trivious] Could not find parent for subcommand", subcommand.data.name);
75
+ continue;
76
+ }
77
+ if (!parent.subcommands) parent.subcommands = new Collection();
78
+ if (parent.subcommands.has(subcommand.data.name))
79
79
  console.warn(
80
- `[Trivious] SlashCommand '${slashCommand.data.name}' has a duplicate and has been overridden`
80
+ `[Trivious] Subcommand '${subcommand.data.name}' under SlashCommand/SubcommandGroup '${parent.data.name}' has been overridden by a subcommand with the same name`
81
81
  );
82
- client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);
82
+ subcommand.parent = parent;
83
+ parent.subcommands.set(subcommand.data.name, subcommand);
84
+ parent.data.addSubcommand(subcommand.data);
83
85
  }
84
- const contextCommands = await parseContextCommands(parentDir);
85
- contextCommands.forEach((cmd) => client.stores.commands.context.set(cmd.data.name, cmd));
86
86
  }
87
87
  async function registerCommands(client, directory) {
88
88
  if (!existsSync(directory))
89
89
  throw new TriviousError(
90
- `Could not register commands; passed directory '${directory}' does not exist!`,
90
+ `Could not regsiter commands; passed directory ${directory} does not exist`,
91
91
  "Nonexistant directory passed"
92
92
  );
93
93
  const processedDirectories = /* @__PURE__ */ new Set();
94
- const files = promises.glob(join(directory, "**/*.js"));
94
+ const files = fs.glob(path.join(directory, "**/*.{js,ts}"));
95
+ const data = {
96
+ SlashCommand: /* @__PURE__ */ new Set(),
97
+ SlashSubcommand: /* @__PURE__ */ new Set(),
98
+ SlashSubcommandGroup: /* @__PURE__ */ new Set()
99
+ };
95
100
  for await (const file of files) {
96
101
  const parentDir = path.dirname(file);
97
102
  if (processedDirectories.has(parentDir)) continue;
98
103
  processedDirectories.add(parentDir);
99
- await registerDirectory(client, parentDir);
104
+ await parseDirectory(data, parentDir);
105
+ }
106
+ await setChildrenToParents(data);
107
+ for (const [slashCommand] of data.SlashCommand) {
108
+ if (client.stores.commands.chatInput.get(slashCommand.data.name))
109
+ console.warn(
110
+ `[Trivious] Command '${slashCommand.data.name}' has been overridden by a command with the same name`
111
+ );
112
+ client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);
100
113
  }
101
114
  }
102
-
103
- export { registerCommands as default };
104
- //# sourceMappingURL=registry.commands.js.map
115
+ export {
116
+ registerCommands as default
117
+ };
105
118
  //# sourceMappingURL=registry.commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/commands/registry.commands.ts"],"names":["fs"],"mappings":";;;;;;AAcA,SAAS,eAAA,CACR,SACA,OAAA,EACU;AACV,EAAA,IAAI,EAAE,QAAA,IAAY,OAAA,IAAW,aAAA,IAAiB,UAAU,OAAO,KAAA;AAC/D,EAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,EAAQ,OAAO,KAAA;AAC5B,EAAA,OAAO,QAAQ,OAAO,CAAA;AACvB;AAEA,eAAe,qBAAA,CACd,WACA,IAAA,EACC;AAED,EAAA,MAAM,WAAA,GAAc,IAAI,UAAA,EAAkE;AAE1F,EAAA,IAAI,EAAE,eAAA,IAAmB,IAAA,CAAK,IAAA,CAAA,EAAO,OAAO,WAAA;AAE5C,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,QAAQ,CAAC,CAAA;AAC/C,EAAA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ED,IAAA,MAAA,CAAO,OAAO,QAAA,CAAS,SAAA,CAAU,IAAI,YAAA,CAAa,IAAA,CAAK,MAAM,YAAY,CAAA;AAAA,EAC1E;AAEA,EAAA,MAAM,eAAA,GAAkB,MAAM,oBAAA,CAAqB,SAAS,CAAA;AAC5D,EAAA,eAAA,CAAgB,OAAA,CAAQ,CAAC,GAAA,KAAQ,MAAA,CAAO,MAAA,CAAO,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,GAAA,CAAI,IAAA,CAAK,IAAA,EAAM,GAAG,CAAC,CAAA;AACxF;AAEA,eAAO,gBAAA,CAAwC,QAAwB,SAAA,EAAmB;AACzF,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,kDAAkD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC3D;AAAA,KACD;AAED,EAAA,MAAM,oBAAA,uBAA2B,GAAA,EAAY;AAE7C,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA;AAEnC,IAAA,IAAI,oBAAA,CAAqB,GAAA,CAAI,SAAS,CAAA,EAAG;AACzC,IAAA,oBAAA,CAAqB,IAAI,SAAS,CAAA;AAElC,IAAA,MAAM,iBAAA,CAAkB,QAAQ,SAAS,CAAA;AAAA,EAC1C;AACD","file":"registry.commands.js","sourcesContent":["import {\n\tBaseChatInputCommandData,\n\tContextCommandData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n\tTriviousClient,\n} from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { ApplicationCommandType, Collection } from \"discord.js\";\nimport { Dirent, existsSync, promises as fs } from \"fs\";\nimport path, { join } from \"path\";\n\nfunction validateCommand<T extends BaseChatInputCommandData | ContextCommandData>(\n\tcommand: T,\n\texpects: (command: Partial<T>) => boolean\n): boolean {\n\tif (!(\"active\" in command && \"commandType\" in command)) return false;\n\tif (!command.active) return false;\n\treturn expects(command);\n}\n\nasync function parseSlashSubcommands(\n\tdirectory: string,\n\tdata: SlashCommandData | SlashSubcommandGroupData<boolean>\n) {\n\tconst _parentType = \"context\" in data ? \"command\" : \"group\";\n\tconst subcommands = new Collection<string, SlashSubcommandData<typeof _parentType, true>>();\n\n\tif (!(\"addSubcommand\" in data.data)) return subcommands;\n\n\tconst files = fs.glob(join(directory, \"./*.js\"));\n\tfor await (const file of files) {\n\t\tconst subcommand = await importFile<SlashSubcommandData<typeof _parentType, true>>(file);\n\t\tif (\n\t\t\t!subcommand ||\n\t\t\t!validateCommand(subcommand, (subcmd) => subcmd.context === \"SlashSubcommand\")\n\t\t)\n\t\t\tcontinue;\n\n\t\tsubcommand.parent = data;\n\t\tdata.data.addSubcommand(subcommand.data);\n\n\t\tif (subcommands.has(subcommand.data.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Subcommand '${subcommand.data.name}' under ${data.context} '${data.data.name}' has a duplicate and has been overridden`\n\t\t\t);\n\t\tsubcommands.set(subcommand.data.name, subcommand);\n\t}\n\n\tif (subcommands.size > 0) data.subcommands = subcommands;\n\treturn subcommands;\n}\n\nasync function parseSlashCommand(\n\tfile: string,\n\tparentDir: string,\n\tsubdirectories: Dirent<string>[]\n) {\n\tif (!existsSync(file)) return;\n\n\tconst command = await importFile<SlashCommandData>(file);\n\tif (\n\t\t!command ||\n\t\t!validateCommand(command, (cmd) => cmd.context === \"SlashCommand\") ||\n\t\t!(\"addSubcommand\" in command.data)\n\t)\n\t\treturn;\n\n\tawait parseSlashSubcommands(parentDir, command);\n\n\tfor (const subdir of subdirectories) {\n\t\tconst indexFile = path.resolve(subdir.parentPath, subdir.name, \"index.js\");\n\t\tif (!existsSync(indexFile)) continue;\n\n\t\tconst group = await importFile<SlashSubcommandGroupData<true>>(indexFile);\n\t\tif (\n\t\t\t!group ||\n\t\t\t!(\"context\" in group && \"addSubcommandGroup\" in command.data) ||\n\t\t\tgroup.context !== \"SlashSubcommandGroup\"\n\t\t)\n\t\t\tcontinue;\n\n\t\tgroup.parent = command;\n\t\tif (!command.subcommandGroups) command.subcommandGroups = new Collection();\n\t\tawait parseSlashSubcommands(join(subdir.parentPath, subdir.name), group);\n\n\t\tif (group.subcommands.size > 0) {\n\t\t\tif (command.subcommandGroups.has(group.data.name))\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Trivious] SubcommandGroup '${group.data.name}' under SlashCommand '${command.data.name}' has a duplicate and has been overridden`\n\t\t\t\t);\n\n\t\t\tcommand.data.addSubcommandGroup(group.data);\n\t\t\tcommand.subcommandGroups.set(group.data.name, group);\n\t\t}\n\t}\n\n\treturn command;\n}\n\nasync function parseContextCommands(parentDir: string) {\n\tconst collection = new Collection<string, ContextCommandData>();\n\tconst files = fs.glob(join(parentDir, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst contextCommand = await importFile<ContextCommandData>(file);\n\t\tif (\n\t\t\t!contextCommand ||\n\t\t\t!validateCommand(\n\t\t\t\tcontextCommand,\n\t\t\t\t(cmd) =>\n\t\t\t\t\tcmd.commandType === ApplicationCommandType.Message ||\n\t\t\t\t\tcmd.commandType === ApplicationCommandType.User\n\t\t\t)\n\t\t)\n\t\t\tcontinue;\n\n\t\tcontextCommand.data.setType(contextCommand.commandType);\n\t\tcollection.set(contextCommand.data.name, contextCommand);\n\t}\n\n\treturn collection;\n}\n\nasync function registerDirectory(client: TriviousClient, parentDir: string) {\n\tconst entries = await fs.readdir(parentDir, { withFileTypes: true });\n\tconst subdirectories = entries.filter((entry) => entry.isDirectory());\n\n\tconst indexFile = path.resolve(parentDir, \"index.js\");\n\tconst slashCommand = await parseSlashCommand(indexFile, parentDir, subdirectories);\n\tif (slashCommand) {\n\t\tif (client.stores.commands.chatInput.has(slashCommand.data.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] SlashCommand '${slashCommand.data.name}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);\n\t}\n\n\tconst contextCommands = await parseContextCommands(parentDir);\n\tcontextCommands.forEach((cmd) => client.stores.commands.context.set(cmd.data.name, cmd));\n}\n\nexport default async function registerCommands(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register commands; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst processedDirectories = new Set<string>();\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst parentDir = path.dirname(file);\n\n\t\tif (processedDirectories.has(parentDir)) continue;\n\t\tprocessedDirectories.add(parentDir);\n\n\t\tawait registerDirectory(client, parentDir);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/commands/registry.commands.ts"],"sourcesContent":["import {\n\tCollatedCommandData,\n\tCommandSetData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n\tTriviousClient,\n} from \"@typings\";\nimport { TriviousError } from \"@utility/errors.js\";\nimport { importFile } from \"@utility/functions.js\";\nimport { Collection } from \"discord.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport path from \"path\";\n\nasync function parseBase<T>(input: string | T, expects?: (base: Partial<T>) => boolean) {\n\tif (typeof input !== \"string\") {\n\t\tif (expects && !expects(input)) return null;\n\t\treturn input;\n\t}\n\tif (!existsSync(input)) return null;\n\tconst base = await importFile<T>(input);\n\tif (!base) return null;\n\tif (expects && !expects(base)) return null;\n\treturn base;\n}\n\nasync function parseDirectory(data: CollatedCommandData, directory: string): Promise<void> {\n\tconst files = fs.glob(path.join(directory, \"*.{js,ts}\"));\n\tfor await (const file of files) {\n\t\tconst base = await parseBase<SlashCommandData | SlashSubcommandData | SlashSubcommandGroupData>(\n\t\t\tfile,\n\t\t\t(base) => \"context\" in base && !!base.context\n\t\t);\n\t\tif (!base) continue;\n\t\tconst targetSet = data[base.context];\n\t\tif (targetSet) (targetSet as Set<[typeof base, string]>).add([base, directory]);\n\t}\n}\n\nfunction isSubdirectoryOf(directory: string, subdirectory: string) {\n\tconst relative = path.relative(path.resolve(directory), path.resolve(subdirectory));\n\treturn !!relative && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n}\n\nfunction getDataFromCommandSet<Data>(\n\tset: Set<CommandSetData<Data>>,\n\toptions: { matchParentDirectory?: string; matchData?: Partial<Data> }\n) {\n\tconst { matchData, matchParentDirectory } = options;\n\tif (!matchData && !matchParentDirectory) return undefined;\n\tconst array = Array.from(set.entries());\n\tlet bestMatch: CommandSetData<Data> | undefined;\n\tlet bestDepth = -1;\n\n\tfor (const entry of array) {\n\t\tconst [key, [data, directory]] = entry;\n\t\tif (matchData && data === matchData) return key[0];\n\t\tif (!matchParentDirectory) continue;\n\t\tconst isExact = directory === matchParentDirectory;\n\t\tconst isParent = isSubdirectoryOf(directory, matchParentDirectory);\n\t\tif (isExact || isParent) {\n\t\t\tconst depth = directory.split(/\\\\|\\//).length;\n\t\t\tif (depth > bestDepth) {\n\t\t\t\tbestDepth = depth;\n\t\t\t\tbestMatch = entry[0];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn bestMatch?.[0];\n}\n\nasync function setChildrenToParents(data: CollatedCommandData) {\n\tfor (const [group, directory] of data.SlashSubcommandGroup) {\n\t\tconst slashCommand =\n\t\t\tgroup.parent || getDataFromCommandSet(data.SlashCommand, { matchParentDirectory: directory });\n\n\t\tif (!slashCommand || !(\"addSubcommandGroup\" in slashCommand.data)) {\n\t\t\tconsole.warn(\"[Trivious] Could not find parent for subcommand group\", group.data.name);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!slashCommand.subcommandGroups) slashCommand.subcommandGroups = new Collection();\n\t\tif (slashCommand.subcommandGroups.has(group.data.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] SubcommandGroup '${group.data.name}' under SlashCommand '${slashCommand.data.name}' has been overridden by a group with the same name`\n\t\t\t);\n\t\tgroup.parent = slashCommand;\n\t\tslashCommand.subcommandGroups.set(group.data.name, group);\n\t\tslashCommand.data.addSubcommandGroup(group.data);\n\t}\n\n\tfor (const [subcommand, directory] of data.SlashSubcommand) {\n\t\tconst parent =\n\t\t\tsubcommand.parent ||\n\t\t\tgetDataFromCommandSet(data.SlashSubcommandGroup, { matchParentDirectory: directory }) ||\n\t\t\tgetDataFromCommandSet(data.SlashCommand, { matchParentDirectory: directory });\n\n\t\tif (!parent || !(\"addSubcommand\" in parent.data)) {\n\t\t\tconsole.warn(\"[Trivious] Could not find parent for subcommand\", subcommand.data.name);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!parent.subcommands) parent.subcommands = new Collection();\n\t\tif (parent.subcommands.has(subcommand.data.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Subcommand '${subcommand.data.name}' under SlashCommand/SubcommandGroup '${parent.data.name}' has been overridden by a subcommand with the same name`\n\t\t\t);\n\t\tsubcommand.parent = parent;\n\t\tparent.subcommands.set(subcommand.data.name, subcommand);\n\t\tparent.data.addSubcommand(subcommand.data);\n\t}\n}\n\nexport default async function registerCommands(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not regsiter commands; passed directory ${directory} does not exist`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\tconst processedDirectories = new Set<string>();\n\tconst files = fs.glob(path.join(directory, \"**/*.{js,ts}\"));\n\tconst data: CollatedCommandData = {\n\t\tSlashCommand: new Set<CommandSetData<SlashCommandData>>(),\n\t\tSlashSubcommand: new Set<CommandSetData<SlashSubcommandData>>(),\n\t\tSlashSubcommandGroup: new Set<CommandSetData<SlashSubcommandGroupData>>(),\n\t};\n\tfor await (const file of files) {\n\t\tconst parentDir = path.dirname(file);\n\t\tif (processedDirectories.has(parentDir)) continue;\n\t\tprocessedDirectories.add(parentDir);\n\t\tawait parseDirectory(data, parentDir);\n\t}\n\tawait setChildrenToParents(data);\n\tfor (const [slashCommand] of data.SlashCommand) {\n\t\tif (client.stores.commands.chatInput.get(slashCommand.data.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Command '${slashCommand.data.name}' has been overridden by a command with the same name`\n\t\t\t);\n\t\tclient.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);\n\t}\n}\n"],"mappings":"AAQA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,YAAY,YAAY,UAAU;AAC3C,OAAO,UAAU;AAEjB,eAAe,UAAa,OAAmB,SAAyC;AACvF,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,WAAW,CAAC,QAAQ,KAAK,EAAG,QAAO;AACvC,WAAO;AAAA,EACR;AACA,MAAI,CAAC,WAAW,KAAK,EAAG,QAAO;AAC/B,QAAM,OAAO,MAAM,WAAc,KAAK;AACtC,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,WAAW,CAAC,QAAQ,IAAI,EAAG,QAAO;AACtC,SAAO;AACR;AAEA,eAAe,eAAe,MAA2B,WAAkC;AAC1F,QAAM,QAAQ,GAAG,KAAK,KAAK,KAAK,WAAW,WAAW,CAAC;AACvD,mBAAiB,QAAQ,OAAO;AAC/B,UAAM,OAAO,MAAM;AAAA,MAClB;AAAA,MACA,CAACA,UAAS,aAAaA,SAAQ,CAAC,CAACA,MAAK;AAAA,IACvC;AACA,QAAI,CAAC,KAAM;AACX,UAAM,YAAY,KAAK,KAAK,OAAO;AACnC,QAAI,UAAW,CAAC,UAAyC,IAAI,CAAC,MAAM,SAAS,CAAC;AAAA,EAC/E;AACD;AAEA,SAAS,iBAAiB,WAAmB,cAAsB;AAClE,QAAM,WAAW,KAAK,SAAS,KAAK,QAAQ,SAAS,GAAG,KAAK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M,qBAAqB,IAAI;AAC/B,aAAW,CAAC,YAAY,KAAK,KAAK,cAAc;AAC/C,QAAI,OAAO,OAAO,SAAS,UAAU,IAAI,aAAa,KAAK,IAAI;AAC9D,cAAQ;AAAA,QACP,uBAAuB,aAAa,KAAK,IAAI;AAAA,MAC9C;AACD,WAAO,OAAO,SAAS,UAAU,IAAI,aAAa,KAAK,MAAM,YAAY;AAAA,EAC1E;AACD;","names":["base"]}
@@ -1,4 +1,4 @@
1
- import { d as Component, e as ComponentContext } from '../../modules.types-lYoNHt-m.js';
1
+ import { f as Component, g as ComponentContext } from '../../modules.types-STECtgbF.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,5 +1,4 @@
1
- import { ComponentContext } from '../../shared/typings.js';
2
-
1
+ import { ComponentContext } from "../../shared/typings.js";
3
2
  function createComponent(data) {
4
3
  return data;
5
4
  }
@@ -21,7 +20,10 @@ function createModalComponent(data) {
21
20
  ...data
22
21
  };
23
22
  }
24
-
25
- export { createButtonComponent, createComponent, createModalComponent, createSelectMenuComponent };
26
- //# sourceMappingURL=builders.components.js.map
23
+ export {
24
+ createButtonComponent,
25
+ createComponent,
26
+ createModalComponent,
27
+ createSelectMenuComponent
28
+ };
27
29
  //# sourceMappingURL=builders.components.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/components/builders.components.ts"],"names":[],"mappings":";;AAOO,SAAS,gBACf,IAAA,EACqB;AACrB,EAAA,OAAO,IAAA;AACR;AAOO,SAAS,sBACf,IAAA,EACqC;AACrC,EAAA,OAAO;AAAA,IACN,SAAS,gBAAA,CAAiB,MAAA;AAAA,IAC1B,GAAG;AAAA,GACJ;AACD;AAOO,SAAS,0BACf,IAAA,EACyC;AACzC,EAAA,OAAO;AAAA,IACN,SAAS,gBAAA,CAAiB,UAAA;AAAA,IAC1B,GAAG;AAAA,GACJ;AACD;AAOO,SAAS,qBACf,IAAA,EACoC;AACpC,EAAA,OAAO;AAAA,IACN,SAAS,gBAAA,CAAiB,KAAA;AAAA,IAC1B,GAAG;AAAA,GACJ;AACD","file":"builders.components.js","sourcesContent":["import { Component, ComponentContext } from \"#typings\";\n\n/**\n * Create component handler\n * @param data Component data\n * @returns Component\n */\nexport function createComponent<Context extends ComponentContext = ComponentContext>(\n\tdata: Component<Context>\n): Component<Context> {\n\treturn data;\n}\n\n/**\n * Create a button component handler\n * @param data Component data\n * @returns Button Component\n */\nexport function createButtonComponent(\n\tdata: Omit<Component<ComponentContext.Button>, \"context\" | \"component\">\n): Component<ComponentContext.Button> {\n\treturn {\n\t\tcontext: ComponentContext.Button,\n\t\t...data,\n\t};\n}\n\n/**\n * Create a select menu component handler\n * @param data Component data\n * @returns AnySelectMenu Component\n */\nexport function createSelectMenuComponent(\n\tdata: Omit<Component<ComponentContext.SelectMenu>, \"context\" | \"component\">\n): Component<ComponentContext.SelectMenu> {\n\treturn {\n\t\tcontext: ComponentContext.SelectMenu,\n\t\t...data,\n\t};\n}\n\n/**\n * Create a modal component handler\n * @param data Component data\n * @returns Modal Component\n */\nexport function createModalComponent(\n\tdata: Omit<Component<ComponentContext.Modal>, \"context\" | \"component\">\n): Component<ComponentContext.Modal> {\n\treturn {\n\t\tcontext: ComponentContext.Modal,\n\t\t...data,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/components/builders.components.ts"],"sourcesContent":["import { Component, ComponentContext } from \"@typings\";\n\n/**\n * Create component handler\n * @param data Component data\n * @returns Component\n */\nexport function createComponent<Context extends ComponentContext = ComponentContext>(\n\tdata: Component<Context>\n): Component<Context> {\n\treturn data;\n}\n\n/**\n * Create a button component handler\n * @param data Component data\n * @returns Button Component\n */\nexport function createButtonComponent(\n\tdata: Omit<Component<ComponentContext.Button>, \"context\" | \"component\">\n): Component<ComponentContext.Button> {\n\treturn {\n\t\tcontext: ComponentContext.Button,\n\t\t...data,\n\t};\n}\n\n/**\n * Create a select menu component handler\n * @param data Component data\n * @returns AnySelectMenu Component\n */\nexport function createSelectMenuComponent(\n\tdata: Omit<Component<ComponentContext.SelectMenu>, \"context\" | \"component\">\n): Component<ComponentContext.SelectMenu> {\n\treturn {\n\t\tcontext: ComponentContext.SelectMenu,\n\t\t...data,\n\t};\n}\n\n/**\n * Create a modal component handler\n * @param data Component data\n * @returns Modal Component\n */\nexport function createModalComponent(\n\tdata: Omit<Component<ComponentContext.Modal>, \"context\" | \"component\">\n): Component<ComponentContext.Modal> {\n\treturn {\n\t\tcontext: ComponentContext.Modal,\n\t\t...data,\n\t};\n}\n"],"mappings":"AAAA,SAAoB,wBAAwB;AAOrC,SAAS,gBACf,MACqB;AACrB,SAAO;AACR;AAOO,SAAS,sBACf,MACqC;AACrC,SAAO;AAAA,IACN,SAAS,iBAAiB;AAAA,IAC1B,GAAG;AAAA,EACJ;AACD;AAOO,SAAS,0BACf,MACyC;AACzC,SAAO;AAAA,IACN,SAAS,iBAAiB;AAAA,IAC1B,GAAG;AAAA,EACJ;AACD;AAOO,SAAS,qBACf,MACoC;AACpC,SAAO;AAAA,IACN,SAAS,iBAAiB;AAAA,IAC1B,GAAG;AAAA,EACJ;AACD;","names":[]}
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
- export { d as Component, e as ComponentContext, f as ComponentFlags, g as ComponentInteraction } from '../../modules.types-lYoNHt-m.js';
2
+ export { f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction } from '../../modules.types-STECtgbF.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.types.js';