trivious 2.2.5 → 2.3.1

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 (88) 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.d.ts +1 -0
  4. package/dist/features/client/client.types.js +0 -2
  5. package/dist/features/client/client.types.js.map +1 -1
  6. package/dist/features/client/deploy.client.d.ts +2 -1
  7. package/dist/features/client/deploy.client.js +8 -9
  8. package/dist/features/client/deploy.client.js.map +1 -1
  9. package/dist/features/client/logger.d.ts +11 -0
  10. package/dist/features/client/logger.js +24 -0
  11. package/dist/features/client/logger.js.map +1 -0
  12. package/dist/features/client/trivious.client.d.ts +2 -1
  13. package/dist/features/client/trivious.client.js +11 -9
  14. package/dist/features/client/trivious.client.js.map +1 -1
  15. package/dist/features/commands/builders.commands.d.ts +6 -5
  16. package/dist/features/commands/builders.commands.js +10 -5
  17. package/dist/features/commands/builders.commands.js.map +1 -1
  18. package/dist/features/commands/commands.types.d.ts +2 -1
  19. package/dist/features/commands/commands.types.js +0 -2
  20. package/dist/features/commands/commands.types.js.map +1 -1
  21. package/dist/features/commands/methods.commands.d.ts +2 -1
  22. package/dist/features/commands/methods.commands.js +4 -3
  23. package/dist/features/commands/methods.commands.js.map +1 -1
  24. package/dist/features/commands/registry.commands.d.ts +2 -1
  25. package/dist/features/commands/registry.commands.js +91 -79
  26. package/dist/features/commands/registry.commands.js.map +1 -1
  27. package/dist/features/components/builders.components.d.ts +2 -1
  28. package/dist/features/components/builders.components.js +7 -5
  29. package/dist/features/components/builders.components.js.map +1 -1
  30. package/dist/features/components/components.types.d.ts +2 -1
  31. package/dist/features/components/components.types.js +3 -3
  32. package/dist/features/components/components.types.js.map +1 -1
  33. package/dist/features/components/registry.components.d.ts +2 -1
  34. package/dist/features/components/registry.components.js +9 -10
  35. package/dist/features/components/registry.components.js.map +1 -1
  36. package/dist/features/customId/customid.types.d.ts +2 -1
  37. package/dist/features/customId/customid.types.js +0 -2
  38. package/dist/features/customId/customid.types.js.map +1 -1
  39. package/dist/features/customId/methods.customid.d.ts +2 -1
  40. package/dist/features/customId/methods.customid.js +4 -5
  41. package/dist/features/customId/methods.customid.js.map +1 -1
  42. package/dist/features/events/builders.events.d.ts +2 -1
  43. package/dist/features/events/builders.events.js +4 -3
  44. package/dist/features/events/builders.events.js.map +1 -1
  45. package/dist/features/events/events.types.d.ts +2 -1
  46. package/dist/features/events/events.types.js +0 -2
  47. package/dist/features/events/events.types.js.map +1 -1
  48. package/dist/features/events/presets/clientReady.d.ts +2 -1
  49. package/dist/features/events/presets/clientReady.js +3 -3
  50. package/dist/features/events/presets/clientReady.js.map +1 -1
  51. package/dist/features/events/presets/interactionCreate.d.ts +2 -1
  52. package/dist/features/events/presets/interactionCreate.js +14 -9
  53. package/dist/features/events/presets/interactionCreate.js.map +1 -1
  54. package/dist/features/events/registry.events.d.ts +2 -1
  55. package/dist/features/events/registry.events.js +10 -10
  56. package/dist/features/events/registry.events.js.map +1 -1
  57. package/dist/features/modules/builders.modules.d.ts +2 -1
  58. package/dist/features/modules/builders.modules.js +3 -3
  59. package/dist/features/modules/builders.modules.js.map +1 -1
  60. package/dist/features/modules/modules.types.d.ts +2 -1
  61. package/dist/features/modules/modules.types.js +0 -2
  62. package/dist/features/modules/modules.types.js.map +1 -1
  63. package/dist/features/modules/registry.modules.d.ts +2 -1
  64. package/dist/features/modules/registry.modules.js +9 -9
  65. package/dist/features/modules/registry.modules.js.map +1 -1
  66. package/dist/features/permissions/methods.permissions.d.ts +2 -1
  67. package/dist/features/permissions/methods.permissions.js +4 -3
  68. package/dist/features/permissions/methods.permissions.js.map +1 -1
  69. package/dist/features/permissions/permissions.types.js +0 -2
  70. package/dist/features/permissions/permissions.types.js.map +1 -1
  71. package/dist/features/structure/index.structure.js +11 -12
  72. package/dist/features/structure/index.structure.js.map +1 -1
  73. package/dist/index.d.ts +2 -1
  74. package/dist/index.js +11 -9
  75. package/dist/index.js.map +1 -1
  76. package/dist/{modules.types-lYoNHt-m.d.ts → modules.types-hjAYMYut.d.ts} +14 -6
  77. package/dist/shared/registries.d.ts +2 -1
  78. package/dist/shared/registries.js +7 -8
  79. package/dist/shared/registries.js.map +1 -1
  80. package/dist/shared/typings.d.ts +2 -1
  81. package/dist/shared/typings.js +11 -9
  82. package/dist/shared/typings.js.map +1 -1
  83. package/dist/utility/errors.d.ts +2 -1
  84. package/dist/utility/errors.js +4 -3
  85. package/dist/utility/errors.js.map +1 -1
  86. package/dist/utility/functions.js +7 -7
  87. package/dist/utility/functions.js.map +1 -1
  88. package/package.json +10 -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":[]}
@@ -80,6 +80,7 @@ interface TriviousClientOptions extends ClientOptions {
80
80
  corePath: string;
81
81
  ownerUserIds?: string[];
82
82
  commandHashConfig?: CommandHashConfiguration;
83
+ debug?: boolean;
83
84
  }
84
85
 
85
86
  export type { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure };
@@ -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,7 +1,8 @@
1
- import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
1
+ import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
2
2
  import 'discord.js';
3
3
  import './client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
+ import './logger.js';
5
6
 
6
7
  declare function commandDeploy(client: TriviousClient): Promise<void>;
7
8
 
@@ -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,MA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AE,CAAA;AAAA,EACjE;AAEA,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,EAAE,SAAS,IAAA,EAAM,CAAA,CAAE,QAAA,CAAS,KAAK,CAAA;AACvD,EAAA,MAAM,IAAA,CAAK,IAAI,MAAA,CAAO,mBAAA,CAAoB,QAAQ,CAAA,EAAG,EAAE,MAAM,CAAA;AAC7D,EAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,SAAA,CAAW,CAAA;AAC5D","file":"deploy.client.js","sourcesContent":["import { createHash } from \"crypto\";\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,eAAO,cAAqC,QAAwB;AACnE,QAAM,EAAE,kBAAkB,IAAI,OAAO;AAErC,QAAM,WAAW,QAAQ,IAAI,OAAO,SAAS,YAAY,iBAAiB;AAC1E,QAAM,QAAQ,QAAQ,IAAI,OAAO,SAAS,YAAY,cAAc;AACpE,MAAI,CAAC,YAAY,CAAC;AACjB,UAAM,IAAI,cAAc,gDAAgD;AAEzE,QAAM,WAAW,OAAO,OAAO;AAC/B,QAAM,OAAO;AAAA,IACZ,GAAG,SAAS,UAAU,IAAI,CAAC,YAAY,QAAQ,KAAK,OAAO,CAAC;AAAA,IAC5D,GAAG,SAAS,QAAQ,IAAI,CAAC,YAAY,QAAQ,KAAK,OAAO,CAAC;AAAA,EAC3D;AAEA,MAAI,qBAAqB,kBAAkB,SAAS;AACnD,UAAM,WAAW,KAAK,kBAAkB,sBAAsB,QAAQ,eAAe;AACrF,UAAM,UAAU,WAAW,QAAQ,EACjC,OAAO,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,EACnF,OAAO,KAAK;AAEd,QAAI,UAAU;AACd,QAAI,WAAW,QAAQ,EAAG,WAAU,aAAa,UAAU,OAAO;AAElE,QAAI,YAAY,SAAS;AACxB,cAAQ,MAAM,+DAA+D;AAC7E;AAAA,IACD;AAEA,UAAM,gBAAgB,QAAQ,QAAQ;AACtC,QAAI,CAAC,WAAW,aAAa,GAAG;AAC/B,gBAAU,eAAe,EAAE,WAAW,KAAK,CAAC;AAAA,IAC7C;AAEA,kBAAc,UAAU,SAAS,EAAE,UAAU,QAAQ,CAAC;AACtD,YAAQ,MAAM,wCAAwC,QAAQ,EAAE;AAAA,EACjE;AAEA,QAAM,OAAO,IAAI,KAAK,EAAE,SAAS,KAAK,CAAC,EAAE,SAAS,KAAK;AACvD,QAAM,KAAK,IAAI,OAAO,oBAAoB,QAAQ,GAAG,EAAE,KAAK,CAAC;AAC7D,UAAQ,MAAM,uBAAuB,KAAK,MAAM,WAAW;AAC5D;","names":[]}
@@ -0,0 +1,11 @@
1
+ declare class Logger {
2
+ private prefix;
3
+ private debugActive;
4
+ constructor(prefix?: string, debugActive?: boolean);
5
+ debug(...args: any[]): void;
6
+ info(...args: any[]): void;
7
+ warn(...args: any[]): void;
8
+ error(...args: any[]): void;
9
+ }
10
+
11
+ export { Logger };
@@ -0,0 +1,24 @@
1
+ import chalk from "chalk";
2
+ class Logger {
3
+ constructor(prefix = "Trivious", debugActive = false) {
4
+ this.prefix = prefix;
5
+ this.debugActive = debugActive;
6
+ }
7
+ debug(...args) {
8
+ if (!this.debugActive) return;
9
+ console.log(chalk.gray(`[${this.prefix}] [DEBUG]`), ...args);
10
+ }
11
+ info(...args) {
12
+ console.log(chalk.cyan([`${this.prefix}`]), ...args);
13
+ }
14
+ warn(...args) {
15
+ console.log(chalk.yellow([`${this.prefix} [WARN]`]), ...args);
16
+ }
17
+ error(...args) {
18
+ console.log(chalk.red([`${this.prefix} [ERROR]`]), ...args);
19
+ }
20
+ }
21
+ export {
22
+ Logger
23
+ };
24
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/features/client/logger.ts"],"sourcesContent":["import chalk from \"chalk\";\n\nexport class Logger {\n\tconstructor(\n\t\tprivate prefix = \"Trivious\",\n\t\tprivate debugActive = false\n\t) {}\n\n\tdebug(...args: any[]) {\n\t\tif (!this.debugActive) return;\n\t\tconsole.log(chalk.gray(`[${this.prefix}] [DEBUG]`), ...args);\n\t}\n\n\tinfo(...args: any[]) {\n\t\tconsole.log(chalk.cyan([`${this.prefix}`]), ...args);\n\t}\n\n\twarn(...args: any[]) {\n\t\tconsole.log(chalk.yellow([`${this.prefix} [WARN]`]), ...args);\n\t}\n\n\terror(...args: any[]) {\n\t\tconsole.log(chalk.red([`${this.prefix} [ERROR]`]), ...args);\n\t}\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAEX,MAAM,OAAO;AAAA,EACnB,YACS,SAAS,YACT,cAAc,OACrB;AAFO;AACA;AAAA,EACN;AAAA,EAEH,SAAS,MAAa;AACrB,QAAI,CAAC,KAAK,YAAa;AACvB,YAAQ,IAAI,MAAM,KAAK,IAAI,KAAK,MAAM,WAAW,GAAG,GAAG,IAAI;AAAA,EAC5D;AAAA,EAEA,QAAQ,MAAa;AACpB,YAAQ,IAAI,MAAM,KAAK,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC,GAAG,GAAG,IAAI;AAAA,EACpD;AAAA,EAEA,QAAQ,MAAa;AACpB,YAAQ,IAAI,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,SAAS,CAAC,GAAG,GAAG,IAAI;AAAA,EAC7D;AAAA,EAEA,SAAS,MAAa;AACrB,YAAQ,IAAI,MAAM,IAAI,CAAC,GAAG,KAAK,MAAM,UAAU,CAAC,GAAG,GAAG,IAAI;AAAA,EAC3D;AACD;","names":[]}
@@ -1,4 +1,5 @@
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-hjAYMYut.js';
4
+ import './logger.js';
4
5
  import '../permissions/permissions.types.js';
@@ -1,15 +1,17 @@
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";
6
+ import { Logger } from "./logger.js";
7
7
  class TriviousClient extends Client {
8
8
  trivious;
9
9
  stores;
10
+ logger;
10
11
  constructor(options) {
11
12
  super(options);
12
13
  this.trivious = options;
14
+ this.logger = new Logger("Trivious", !!options.debug);
13
15
  this.stores = {
14
16
  commands: {
15
17
  chatInput: new Collection(),
@@ -55,7 +57,7 @@ class TriviousClient extends Client {
55
57
  await commandDeploy(this);
56
58
  }
57
59
  }
58
-
59
- export { TriviousClient as default };
60
- //# sourceMappingURL=trivious.client.js.map
60
+ export {
61
+ TriviousClient as default
62
+ };
61
63
  //# 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;AAAW,KACzB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,KAAA,GAAQ;AACb,IAAA,MAAM,QAAQ,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAK,QAA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ection } 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\";\nimport { Logger } from \"./logger.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\tlogger: Logger;\n\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis.trivious = options;\n\t\tthis.logger = new Logger(\"Trivious\", !!options.debug);\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;AAC1B,SAAS,cAAc;AAEvB,MAAO,uBAAqC,OAAO;AAAA,EAClD;AAAA,EACS;AAAA,EAST;AAAA,EAEA,YAAY,SAAgC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW;AAChB,SAAK,SAAS,IAAI,OAAO,YAAY,CAAC,CAAC,QAAQ,KAAK;AAEpD,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,19 +1,20 @@
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-hjAYMYut.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
+ import '../client/logger.js';
5
6
 
6
7
  declare function createSlashCommand(data: Omit<SlashCommandData, "context" | "commandType" | "subcommands" | "subcommandGroups">): SlashCommandData;
7
8
  /**
8
9
  * @deprecated Use createSlashSubcommand instead
9
10
  */
10
- declare function createSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType" | "parent">): SlashSubcommandData;
11
- declare function createSlashSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType" | "parent">): SlashSubcommandData;
11
+ declare function createSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType">): SlashSubcommandData;
12
+ declare function createSlashSubcommand(data: Omit<SlashSubcommandData, "context" | "commandType">): SlashSubcommandData;
12
13
  /**
13
14
  * @deprecated Use createSlashSubcommandGroup instead
14
15
  */
15
- declare function createSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "parent" | "subcommands">): SlashSubcommandGroupData;
16
- declare function createSlashSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "parent" | "subcommands">): SlashSubcommandGroupData;
16
+ declare function createSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "subcommands">): SlashSubcommandGroupData;
17
+ declare function createSlashSubcommandGroup(data: Omit<SlashSubcommandGroupData, "context" | "subcommands">): SlashSubcommandGroupData;
17
18
  declare function createMessageContextCommand(data: Omit<ContextCommandData<"Message">, "commandType">): ContextCommandData<"Message">;
18
19
  declare function createUserContextCommand(data: Omit<ContextCommandData<"User">, "commandType">): ContextCommandData<"User">;
19
20
 
@@ -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,5 @@
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-hjAYMYut.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.types.js';
5
+ import '../client/logger.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,7 +1,8 @@
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-hjAYMYut.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
+ import '../client/logger.js';
5
6
 
6
7
  declare function interactionReply(options: {
7
8
  interaction: Interaction<CacheType>;
@@ -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,CA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,QACxB,YAAA,EAAc,EAAE,OAAA,EAAS,+DAAA;AAAgE,OACzF,CAAA;AACD,MAAA;AAAA,IACD;AAEA,IAAA,MAAM,WAAA,CAAY,WAAA,EAAa,eAAA,CAAgB,KAAA,IAAS,QAAQ,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;AAA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,SAAS,QAAQ,KAAK;AACrE,WAAO,MAAM,gBAAgB,QAAQ,QAAQ,WAAW;AAAA,EACzD,WAAW,cAAc,QAAQ,aAAa;AAC7C,UAAM,kBAAkB,QAAQ,YAAY,IAAI,UAAU;AAC1D,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,7 +1,8 @@
1
- import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
1
+ import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
+ import '../client/logger.js';
5
6
 
6
7
  declare function registerCommands(client: TriviousClient, directory: string): Promise<void>;
7
8
 
@@ -1,105 +1,117 @@
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
+ let base = null;
8
+ if (typeof input === "string") {
9
+ base = await importFile(input);
10
+ } else base = input;
11
+ if (!base) return null;
12
+ if (expects && !expects(base)) return null;
13
+ return base;
11
14
  }
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"));
15
+ async function parseDirectory(data, directory) {
16
+ const files = fs.glob(path.join(directory, "*.{js,ts}"));
16
17
  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);
18
+ const base = await parseBase(
19
+ file,
20
+ (base2) => "context" in base2 && !!base2.context
21
+ );
22
+ if (!base) continue;
23
+ const targetSet = data[base.context];
24
+ if (targetSet) targetSet.add([base, directory]);
27
25
  }
28
- if (subcommands.size > 0) data.subcommands = subcommands;
29
- return subcommands;
30
26
  }
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);
27
+ function isSubdirectoryOf(directory, subdirectory) {
28
+ const relative = path.relative(path.resolve(directory), path.resolve(subdirectory));
29
+ return !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
30
+ }
31
+ function getDataFromCommandSet(set, options) {
32
+ const { matchData, matchParentDirectory } = options;
33
+ if (!matchData && !matchParentDirectory) return void 0;
34
+ const array = Array.from(set.entries());
35
+ let bestMatch;
36
+ let bestDepth = -1;
37
+ for (const entry of array) {
38
+ const [key, [data, directory]] = entry;
39
+ if (matchData && data === matchData) return key[0];
40
+ if (!matchParentDirectory) continue;
41
+ const isExact = directory === matchParentDirectory;
42
+ const isParent = isSubdirectoryOf(directory, matchParentDirectory);
43
+ if (isExact || isParent) {
44
+ const depth = directory.split(/\\|\//).length;
45
+ if (depth > bestDepth) {
46
+ bestDepth = depth;
47
+ bestMatch = entry[0];
48
+ }
53
49
  }
54
50
  }
55
- return command;
51
+ return bestMatch?.[0];
56
52
  }
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
- ))
53
+ async function setChildrenToParents(data) {
54
+ for (const [group, directory] of data.SlashSubcommandGroup) {
55
+ const slashCommand = group.parent || getDataFromCommandSet(data.SlashCommand, { matchParentDirectory: directory });
56
+ if (!slashCommand || !("addSubcommandGroup" in slashCommand.data)) {
57
+ console.warn("[Trivious] Could not find parent for subcommand group", group.data.name);
66
58
  continue;
67
- contextCommand.data.setType(contextCommand.commandType);
68
- collection.set(contextCommand.data.name, contextCommand);
59
+ }
60
+ if (!slashCommand.subcommandGroups) slashCommand.subcommandGroups = new Collection();
61
+ if (slashCommand.subcommandGroups.has(group.data.name))
62
+ console.warn(
63
+ `[Trivious] SubcommandGroup '${group.data.name}' under SlashCommand '${slashCommand.data.name}' has been overridden by a group with the same name`
64
+ );
65
+ group.parent = slashCommand;
66
+ slashCommand.subcommandGroups.set(group.data.name, group);
67
+ slashCommand.data.addSubcommandGroup(group.data);
69
68
  }
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))
69
+ for (const [subcommand, directory] of data.SlashSubcommand) {
70
+ const parent = subcommand.parent || getDataFromCommandSet(data.SlashSubcommandGroup, { matchParentDirectory: directory }) || getDataFromCommandSet(data.SlashCommand, { matchParentDirectory: directory });
71
+ if (!parent || !("addSubcommand" in parent.data)) {
72
+ console.warn("[Trivious] Could not find parent for subcommand", subcommand.data.name);
73
+ continue;
74
+ }
75
+ if (!parent.subcommands) parent.subcommands = new Collection();
76
+ if (parent.subcommands.has(subcommand.data.name))
79
77
  console.warn(
80
- `[Trivious] SlashCommand '${slashCommand.data.name}' has a duplicate and has been overridden`
78
+ `[Trivious] Subcommand '${subcommand.data.name}' under SlashCommand/SubcommandGroup '${parent.data.name}' has been overridden by a subcommand with the same name`
81
79
  );
82
- client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);
80
+ subcommand.parent = parent;
81
+ parent.subcommands.set(subcommand.data.name, subcommand);
82
+ parent.data.addSubcommand(subcommand.data);
83
83
  }
84
- const contextCommands = await parseContextCommands(parentDir);
85
- contextCommands.forEach((cmd) => client.stores.commands.context.set(cmd.data.name, cmd));
86
84
  }
87
85
  async function registerCommands(client, directory) {
88
86
  if (!existsSync(directory))
89
87
  throw new TriviousError(
90
- `Could not register commands; passed directory '${directory}' does not exist!`,
88
+ `Could not regsiter commands; passed directory ${directory} does not exist`,
91
89
  "Nonexistant directory passed"
92
90
  );
93
91
  const processedDirectories = /* @__PURE__ */ new Set();
94
- const files = promises.glob(join(directory, "**/*.js"));
92
+ const files = fs.glob(path.join(directory, "**/*.{js,ts}"));
93
+ const data = {
94
+ SlashCommand: /* @__PURE__ */ new Set(),
95
+ SlashSubcommand: /* @__PURE__ */ new Set(),
96
+ SlashSubcommandGroup: /* @__PURE__ */ new Set()
97
+ };
98
+ client.logger.debug("Starting command registration in:", directory);
95
99
  for await (const file of files) {
96
100
  const parentDir = path.dirname(file);
97
101
  if (processedDirectories.has(parentDir)) continue;
98
102
  processedDirectories.add(parentDir);
99
- await registerDirectory(client, parentDir);
103
+ await parseDirectory(data, parentDir);
104
+ }
105
+ await setChildrenToParents(data);
106
+ for (const [slashCommand] of data.SlashCommand) {
107
+ if (client.stores.commands.chatInput.get(slashCommand.data.name))
108
+ client.logger.warn(
109
+ `Command '${slashCommand.data.name}' has been overridden by a command with the same name`
110
+ );
111
+ client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);
100
112
  }
101
113
  }
102
-
103
- export { registerCommands as default };
104
- //# sourceMappingURL=registry.commands.js.map
114
+ export {
115
+ registerCommands as default
116
+ };
105
117
  //# sourceMappingURL=registry.commands.js.map