trivious 2.3.5 → 2.3.7

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 (28) hide show
  1. package/dist/features/client/deploy.client.d.ts +1 -1
  2. package/dist/features/client/trivious.client.d.ts +1 -1
  3. package/dist/features/client/trivious.client.js +1 -0
  4. package/dist/features/client/trivious.client.js.map +1 -1
  5. package/dist/features/commands/builders.commands.d.ts +1 -1
  6. package/dist/features/commands/commands.types.d.ts +1 -1
  7. package/dist/features/commands/methods.commands.d.ts +1 -1
  8. package/dist/features/commands/registry.commands.d.ts +1 -5
  9. package/dist/features/commands/registry.commands.js +35 -18
  10. package/dist/features/commands/registry.commands.js.map +1 -1
  11. package/dist/features/components/builders.components.d.ts +1 -1
  12. package/dist/features/components/components.types.d.ts +1 -1
  13. package/dist/features/components/registry.components.d.ts +1 -5
  14. package/dist/features/customId/customid.types.d.ts +1 -1
  15. package/dist/features/customId/methods.customid.d.ts +1 -1
  16. package/dist/features/events/events.types.d.ts +1 -1
  17. package/dist/features/events/presets/clientReady.d.ts +1 -1
  18. package/dist/features/events/presets/interactionCreate.d.ts +1 -1
  19. package/dist/features/events/registry.events.d.ts +1 -6
  20. package/dist/features/modules/modules.types.d.ts +1 -1
  21. package/dist/features/modules/registry.modules.d.ts +1 -6
  22. package/dist/features/permissions/methods.permissions.d.ts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/{modules.types-hjAYMYut.d.ts → modules.types-DLv4ITOW.d.ts} +28 -1
  25. package/dist/shared/registries.d.ts +1 -5
  26. package/dist/shared/typings.d.ts +1 -1
  27. package/dist/utility/errors.d.ts +1 -1
  28. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
1
+ import { T as TriviousClient } from '../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import './client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
+ export { T as default } from '../../modules.types-DLv4ITOW.js';
1
2
  import 'discord.js';
2
3
  import './client.types.js';
3
- export { T as default } from '../../modules.types-hjAYMYut.js';
4
4
  import './logger.js';
5
5
  import '../permissions/permissions.types.js';
@@ -6,6 +6,7 @@ import commandDeploy from "./deploy.client.js";
6
6
  import { Logger } from "./logger.js";
7
7
  class TriviousClient extends Client {
8
8
  trivious;
9
+ registries = registries;
9
10
  stores;
10
11
  logger;
11
12
  constructor(options) {
@@ -1 +1 @@
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
+ {"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 registries = registries;\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\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;AAAA,EACb;AAAA,EAST;AAAA,EAEA,YAAY,SAAgC;AAC3C,UAAM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commandGroupData } from '../../modules.types-hjAYMYut.js';
1
+ import { j as ContextCommandData, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData } from '../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
1
  import 'discord.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';
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-DLv4ITOW.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.types.js';
5
5
  import '../client/logger.js';
@@ -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, c as CommandFlags } from '../../modules.types-hjAYMYut.js';
2
+ import { T as TriviousClient, S as SlashCommandData, c as CommandFlags } from '../../modules.types-DLv4ITOW.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
  import '../client/logger.js';
@@ -1,9 +1,5 @@
1
- import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
1
+ export { r as default } from '../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
  import '../client/logger.js';
6
-
7
- declare function registerCommands(client: TriviousClient, directory: string): Promise<void>;
8
-
9
- export { registerCommands as default };
@@ -1,6 +1,6 @@
1
1
  import { TriviousError } from "../../utility/errors.js";
2
2
  import { importFile } from "../../utility/functions.js";
3
- import { Collection } from "discord.js";
3
+ import { ApplicationCommandType, Collection } from "discord.js";
4
4
  import { existsSync, promises as fs } from "fs";
5
5
  import path from "path";
6
6
  async function parseBase(input, expects) {
@@ -15,12 +15,9 @@ async function parseBase(input, expects) {
15
15
  async function parseDirectory(data, directory) {
16
16
  const files = fs.glob(path.join(directory, "*.{js,ts}"));
17
17
  for await (const file of files) {
18
- const base = await parseBase(
19
- file,
20
- (base2) => "context" in base2 && !!base2.context
21
- );
18
+ const base = await parseBase(file);
22
19
  if (!base) continue;
23
- const targetSet = data[base.context];
20
+ const targetSet = "context" in base ? data[base.context] : "commandType" in base && (base.commandType === ApplicationCommandType.Message || base.commandType === ApplicationCommandType.User) ? data.ContextCommand : null;
24
21
  if (targetSet) targetSet.add([base, directory]);
25
22
  }
26
23
  }
@@ -82,35 +79,55 @@ async function setChildrenToParents(data) {
82
79
  parent.data.addSubcommand(subcommand.data);
83
80
  }
84
81
  }
82
+ async function registerSlashCommands(client, data) {
83
+ await setChildrenToParents(data);
84
+ for (const [slashCommand] of data.SlashCommand) {
85
+ if (client.stores.commands.chatInput.get(slashCommand.data.name))
86
+ client.logger.warn(
87
+ `Command '${slashCommand.data.name}' has been overridden by a command with the same name`
88
+ );
89
+ client.logger.debug("Registered slash command:", slashCommand.data.name);
90
+ client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);
91
+ }
92
+ }
93
+ async function registerContextMenuCommands(client, data) {
94
+ for (const [contextCommand] of data.ContextCommand) {
95
+ if (client.stores.commands.chatInput.get(contextCommand.data.name))
96
+ client.logger.warn(
97
+ `Command '${contextCommand.data.name}' has been overridden by a command with the same name`
98
+ );
99
+ client.logger.debug(
100
+ "Registered",
101
+ ApplicationCommandType[contextCommand.commandType],
102
+ "context command:",
103
+ contextCommand.data.name
104
+ );
105
+ client.stores.commands.context.set(contextCommand.data.name, contextCommand);
106
+ }
107
+ }
85
108
  async function registerCommands(client, directory) {
86
109
  if (!existsSync(directory))
87
110
  throw new TriviousError(
88
111
  `Could not regsiter commands; passed directory ${directory} does not exist`,
89
112
  "Nonexistant directory passed"
90
113
  );
91
- const processedDirectories = /* @__PURE__ */ new Set();
92
- const files = fs.glob(path.join(directory, "**/*.{js,ts}"));
93
114
  const data = {
94
115
  SlashCommand: /* @__PURE__ */ new Set(),
95
116
  SlashSubcommand: /* @__PURE__ */ new Set(),
96
- SlashSubcommandGroup: /* @__PURE__ */ new Set()
117
+ SlashSubcommandGroup: /* @__PURE__ */ new Set(),
118
+ ContextCommand: /* @__PURE__ */ new Set()
97
119
  };
98
120
  client.logger.debug("Starting command registration in:", directory);
121
+ const files = fs.glob(path.join(directory, "**/*.{js,ts}"));
122
+ const processedDirectories = /* @__PURE__ */ new Set();
99
123
  for await (const file of files) {
100
124
  const parentDir = path.dirname(file);
101
125
  if (processedDirectories.has(parentDir)) continue;
102
126
  processedDirectories.add(parentDir);
103
127
  await parseDirectory(data, parentDir);
104
128
  }
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.logger.debug("Registered slash command:", slashCommand.data.name);
112
- client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);
113
- }
129
+ await registerSlashCommands(client, data);
130
+ await registerContextMenuCommands(client, data);
114
131
  }
115
132
  export {
116
133
  registerCommands as default
@@ -1 +1 @@
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\tlet base: T | null = null;\n\tif (typeof input === \"string\") {\n\t\tbase = await importFile<T>(input);\n\t} else base = 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\tclient.logger.debug(\"Starting command registration in:\", directory);\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\tclient.logger.warn(\n\t\t\t\t`Command '${slashCommand.data.name}' has been overridden by a command with the same name`\n\t\t\t);\n\t\tclient.logger.debug(\"Registered slash command:\", slashCommand.data.name);\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,OAAiB;AACrB,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO,MAAM,WAAc,KAAK;AAAA,EACjC,MAAO,QAAO;AACd,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,MAC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,IACjC,cAAc,oBAAI,IAAsC;AAAA,IACxD,iBAAiB,oBAAI,IAAyC;AAAA,IAC9D,sBAAsB,oBAAI,IAA8C;AAAA,EACzE;AACA,SAAO,OAAO,MAAM,qCAAqC,SAAS;AAClE,mBAAiB,QAAQ,OAAO;AAC/B,UAAM,YAAY,KAAK,QAAQ,IAAI;AACnC,QAAI,qBAAqB,IAAI,SAAS,EAAG;AACzC,yBAAqB,IAAI,SAAS;AAClC,UAAM,eAAe,MAAM,SAAS;AAAA,EACrC;AACA,QAAM,qBAAqB,IAAI;AAC/B,aAAW,CAAC,YAAY,KAAK,KAAK,cAAc;AAC/C,QAAI,OAAO,OAAO,SAAS,UAAU,IAAI,aAAa,KAAK,IAAI;AAC9D,aAAO,OAAO;AAAA,QACb,YAAY,aAAa,KAAK,IAAI;AAAA,MACnC;AACD,WAAO,OAAO,MAAM,6BAA6B,aAAa,KAAK,IAAI;AACvE,WAAO,OAAO,SAAS,UAAU,IAAI,aAAa,KAAK,MAAM,YAAY;AAAA,EAC1E;AACD;","names":["base"]}
1
+ {"version":3,"sources":["../../../src/features/commands/registry.commands.ts"],"sourcesContent":["import {\n\tCollatedCommandData,\n\tCommandSetData,\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 { existsSync, promises as fs } from \"fs\";\nimport path from \"path\";\n\nasync function parseBase<T>(input: string | T, expects?: (base: Partial<T>) => boolean) {\n\tlet base: T | null = null;\n\tif (typeof input === \"string\") {\n\t\tbase = await importFile<T>(input);\n\t} else base = 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<\n\t\t\tSlashCommandData | SlashSubcommandData | SlashSubcommandGroupData | ContextCommandData\n\t\t>(file);\n\t\tif (!base) continue;\n\t\tconst targetSet =\n\t\t\t\"context\" in base\n\t\t\t\t? data[base.context]\n\t\t\t\t: \"commandType\" in base &&\n\t\t\t\t\t (base.commandType === ApplicationCommandType.Message ||\n\t\t\t\t\t\t\tbase.commandType === ApplicationCommandType.User)\n\t\t\t\t\t? data.ContextCommand\n\t\t\t\t\t: null;\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\nasync function registerSlashCommands(client: TriviousClient, data: CollatedCommandData) {\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\tclient.logger.warn(\n\t\t\t\t`Command '${slashCommand.data.name}' has been overridden by a command with the same name`\n\t\t\t);\n\t\tclient.logger.debug(\"Registered slash command:\", slashCommand.data.name);\n\t\tclient.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);\n\t}\n}\n\nasync function registerContextMenuCommands(client: TriviousClient, data: CollatedCommandData) {\n\tfor (const [contextCommand] of data.ContextCommand) {\n\t\tif (client.stores.commands.chatInput.get(contextCommand.data.name))\n\t\t\tclient.logger.warn(\n\t\t\t\t`Command '${contextCommand.data.name}' has been overridden by a command with the same name`\n\t\t\t);\n\t\tclient.logger.debug(\n\t\t\t\"Registered\",\n\t\t\tApplicationCommandType[contextCommand.commandType],\n\t\t\t\"context command:\",\n\t\t\tcontextCommand.data.name\n\t\t);\n\t\tclient.stores.commands.context.set(contextCommand.data.name, contextCommand);\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 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\tContextCommand: new Set<CommandSetData<ContextCommandData>>(),\n\t};\n\tclient.logger.debug(\"Starting command registration in:\", directory);\n\tconst files = fs.glob(path.join(directory, \"**/*.{js,ts}\"));\n\tconst processedDirectories = new Set<string>();\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 registerSlashCommands(client, data);\n\tawait registerContextMenuCommands(client, data);\n}\n"],"mappings":"AASA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB,kBAAkB;AACnD,SAAS,YAAY,YAAY,UAAU;AAC3C,OAAO,UAAU;AAEjB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,SAAO,OAAO,MAAM,qCAAqC,SAAS;AAClE,QAAM,QAAQ,GAAG,KAAK,KAAK,KAAK,WAAW,cAAc,CAAC;AAC1D,QAAM,uBAAuB,oBAAI,IAAY;AAC7C,mBAAiB,QAAQ,OAAO;AAC/B,UAAM,YAAY,KAAK,QAAQ,IAAI;AACnC,QAAI,qBAAqB,IAAI,SAAS,EAAG;AACzC,yBAAqB,IAAI,SAAS;AAClC,UAAM,eAAe,MAAM,SAAS;AAAA,EACrC;AACA,QAAM,sBAAsB,QAAQ,IAAI;AACxC,QAAM,4BAA4B,QAAQ,IAAI;AAC/C;","names":[]}
@@ -1,4 +1,4 @@
1
- import { f as Component, g as ComponentContext } from '../../modules.types-hjAYMYut.js';
1
+ import { f as Component, g as ComponentContext } from '../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
1
  import 'discord.js';
2
- export { f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction } from '../../modules.types-hjAYMYut.js';
2
+ export { f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction } from '../../modules.types-DLv4ITOW.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.types.js';
5
5
  import '../client/logger.js';
@@ -1,9 +1,5 @@
1
- import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
1
+ export { m as default } from '../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
  import '../client/logger.js';
6
-
7
- declare function registerComponents(client: TriviousClient, directory: string): Promise<void>;
8
-
9
- export { registerComponents as default };
@@ -1,5 +1,5 @@
1
1
  import '../client/client.types.js';
2
- import { g as ComponentContext } from '../../modules.types-hjAYMYut.js';
2
+ import { g as ComponentContext } from '../../modules.types-DLv4ITOW.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import 'discord.js';
5
5
  import '../client/logger.js';
@@ -1,7 +1,7 @@
1
1
  import { ComponentCustomId } from './customid.types.js';
2
2
  import '../client/client.types.js';
3
3
  import 'discord.js';
4
- import '../../modules.types-hjAYMYut.js';
4
+ import '../../modules.types-DLv4ITOW.js';
5
5
  import '../permissions/permissions.types.js';
6
6
  import '../client/logger.js';
7
7
 
@@ -1,5 +1,5 @@
1
1
  import 'discord.js';
2
- export { E as Event } from '../../modules.types-hjAYMYut.js';
2
+ export { E as Event } from '../../modules.types-DLv4ITOW.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
  import '../client/logger.js';
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../../modules.types-hjAYMYut.js';
1
+ import { T as TriviousClient } from '../../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../../client/client.types.js';
4
4
  import '../../permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { T as TriviousClient } from '../../../modules.types-hjAYMYut.js';
2
+ import { T as TriviousClient } from '../../../modules.types-DLv4ITOW.js';
3
3
  import '../../client/client.types.js';
4
4
  import '../../permissions/permissions.types.js';
5
5
  import '../../client/logger.js';
@@ -1,10 +1,5 @@
1
- import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
1
+ export { o as bindEvents, n as default } from '../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
  import '../client/logger.js';
6
-
7
- declare function bindEvents(client: TriviousClient): Promise<void>;
8
- declare function registerEvents(client: TriviousClient, directory: string): Promise<void>;
9
-
10
- export { bindEvents, registerEvents as default };
@@ -1,5 +1,5 @@
1
1
  import 'discord.js';
2
- export { M as Module } from '../../modules.types-hjAYMYut.js';
2
+ export { M as Module } from '../../modules.types-DLv4ITOW.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
  import '../client/logger.js';
@@ -1,10 +1,5 @@
1
- import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
1
+ export { q as bindModules, p as default } from '../../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
  import '../client/logger.js';
6
-
7
- declare function bindModules(client: TriviousClient): Promise<void>;
8
- declare function registerModules(client: TriviousClient, directory: string): Promise<void>;
9
-
10
- export { bindModules, registerModules as default };
@@ -1,5 +1,5 @@
1
1
  import { GuildMember, User } from 'discord.js';
2
- import { T as TriviousClient, a as BaseCommandData, f as Component } from '../../modules.types-hjAYMYut.js';
2
+ import { T as TriviousClient, a as BaseCommandData, f as Component } from '../../modules.types-DLv4ITOW.js';
3
3
  import '../client/client.types.js';
4
4
  import './permissions.types.js';
5
5
  import '../client/logger.js';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure } from './features/client/client.types.js';
2
- export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CollatedCommandData, c as CommandFlags, d as CommandFunction, e as CommandSetData, f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction, j as ContextCommandData, E as Event, M as Module, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData, T as TriviousClient } from './modules.types-hjAYMYut.js';
2
+ export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CollatedCommandData, c as CommandFlags, d as CommandFunction, e as CommandSetData, f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction, j as ContextCommandData, E as Event, M as Module, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData, T as TriviousClient } from './modules.types-DLv4ITOW.js';
3
3
  export { ComponentCustomId, ComponentTag } from './features/customId/customid.types.js';
4
4
  export { CommandPermissionValues } from './features/permissions/permissions.types.js';
5
5
  export { createActionRow, createEmbed } from './features/builders/utility.builders.js';
@@ -3,8 +3,34 @@ import { TriviousClientOptions } from './features/client/client.types.js';
3
3
  import { CommandPermissionValues } from './features/permissions/permissions.types.js';
4
4
  import { Logger } from './features/client/logger.js';
5
5
 
6
+ declare function bindModules(client: TriviousClient): Promise<void>;
7
+ declare function registerModules(client: TriviousClient, directory: string): Promise<void>;
8
+
9
+ declare function bindEvents(client: TriviousClient): Promise<void>;
10
+ declare function registerEvents(client: TriviousClient, directory: string): Promise<void>;
11
+
12
+ declare function registerComponents(client: TriviousClient, directory: string): Promise<void>;
13
+
14
+ declare function registerCommands(client: TriviousClient, directory: string): Promise<void>;
15
+
6
16
  declare class TriviousClient extends Client {
7
17
  trivious: TriviousClientOptions;
18
+ readonly registries: {
19
+ readonly commands: {
20
+ readonly register: typeof registerCommands;
21
+ };
22
+ readonly components: {
23
+ readonly register: typeof registerComponents;
24
+ };
25
+ readonly events: {
26
+ readonly register: typeof registerEvents;
27
+ readonly bind: typeof bindEvents;
28
+ };
29
+ readonly modules: {
30
+ readonly register: typeof registerModules;
31
+ readonly bind: typeof bindModules;
32
+ };
33
+ };
8
34
  readonly stores: {
9
35
  commands: {
10
36
  chatInput: Collection<string, SlashCommandData>;
@@ -110,6 +136,7 @@ type CollatedCommandData = {
110
136
  SlashCommand: Set<CommandSetData<SlashCommandData>>;
111
137
  SlashSubcommand: Set<CommandSetData<SlashSubcommandData>>;
112
138
  SlashSubcommandGroup: Set<CommandSetData<SlashSubcommandGroupData>>;
139
+ ContextCommand: Set<CommandSetData<ContextCommandData>>;
113
140
  };
114
141
 
115
142
  type ComponentFlags = "Cached" | "DeferReply" | "EphemeralReply" | "ExpectModal";
@@ -152,4 +179,4 @@ interface Module {
152
179
  };
153
180
  }
154
181
 
155
- export { type BaseChatInputCommandData as B, type ChatInputCommandContext as C, type Event as E, type Module as M, type SlashCommandData as S, TriviousClient as T, type BaseCommandData as a, type CollatedCommandData as b, type CommandFlags as c, type CommandFunction as d, type CommandSetData as e, type Component as f, ComponentContext as g, type ComponentFlags as h, type ComponentInteraction as i, type ContextCommandData as j, type SlashSubcommandData as k, type SlashSubcommandGroupData as l };
182
+ export { type BaseChatInputCommandData as B, type ChatInputCommandContext as C, type Event as E, type Module as M, type SlashCommandData as S, TriviousClient as T, type BaseCommandData as a, type CollatedCommandData as b, type CommandFlags as c, type CommandFunction as d, type CommandSetData as e, type Component as f, ComponentContext as g, type ComponentFlags as h, type ComponentInteraction as i, type ContextCommandData as j, type SlashSubcommandData as k, type SlashSubcommandGroupData as l, registerComponents as m, registerEvents as n, bindEvents as o, registerModules as p, bindModules as q, registerCommands as r };
@@ -1,8 +1,4 @@
1
- import registerCommands from '../features/commands/registry.commands.js';
2
- import registerComponents from '../features/components/registry.components.js';
3
- import registerEvents, { bindEvents } from '../features/events/registry.events.js';
4
- import registerModules, { bindModules } from '../features/modules/registry.modules.js';
5
- import '../modules.types-hjAYMYut.js';
1
+ import { r as registerCommands, m as registerComponents, n as registerEvents, o as bindEvents, p as registerModules, q as bindModules } from '../modules.types-DLv4ITOW.js';
6
2
  import 'discord.js';
7
3
  import '../features/client/client.types.js';
8
4
  import '../features/permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
1
  export { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure } from '../features/client/client.types.js';
2
- export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CollatedCommandData, c as CommandFlags, d as CommandFunction, e as CommandSetData, f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction, j as ContextCommandData, E as Event, M as Module, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData, T as TriviousClient } from '../modules.types-hjAYMYut.js';
2
+ export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CollatedCommandData, c as CommandFlags, d as CommandFunction, e as CommandSetData, f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction, j as ContextCommandData, E as Event, M as Module, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData, T as TriviousClient } from '../modules.types-DLv4ITOW.js';
3
3
  export { ComponentCustomId, ComponentTag } from '../features/customId/customid.types.js';
4
4
  export { CommandPermissionValues } from '../features/permissions/permissions.types.js';
5
5
  import 'discord.js';
@@ -1,4 +1,4 @@
1
- import { a as BaseCommandData, S as SlashCommandData } from '../modules.types-hjAYMYut.js';
1
+ import { a as BaseCommandData, S as SlashCommandData } from '../modules.types-DLv4ITOW.js';
2
2
  import 'discord.js';
3
3
  import '../features/client/client.types.js';
4
4
  import '../features/permissions/permissions.types.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trivious",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "discord-bot",
@@ -15,6 +15,7 @@
15
15
  "typescript-discord"
16
16
  ],
17
17
  "license": "Apache-2.0",
18
+ "packageManager": "pnpm@11.8.0",
18
19
  "publishConfig": {
19
20
  "access": "public"
20
21
  },
@@ -72,7 +73,7 @@
72
73
  "tsc-alias": "^1.8.16",
73
74
  "tsup": "^8.5.1",
74
75
  "tsx": "^4.22.3",
75
- "typescript": "^5.9.3",
76
+ "typescript": "^6.0.3",
76
77
  "typescript-eslint": "^8.57.0",
77
78
  "vite": "^8.0.14",
78
79
  "vite-tsconfig-paths": "^6.1.1",