trivious 2.3.5 → 2.3.6

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.
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-hjAYMYut.js';
1
+ import { T as TriviousClient } from '../../modules.types-D-tuJArP.js';
2
2
  import 'discord.js';
3
3
  import './client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
1
  import 'discord.js';
2
2
  import './client.types.js';
3
- export { T as default } from '../../modules.types-hjAYMYut.js';
3
+ export { T as default } from '../../modules.types-D-tuJArP.js';
4
4
  import './logger.js';
5
5
  import '../permissions/permissions.types.js';
@@ -1,4 +1,4 @@
1
- import { j as ContextCommandData, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData } from '../../modules.types-hjAYMYut.js';
1
+ import { j as ContextCommandData, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData } from '../../modules.types-D-tuJArP.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-D-tuJArP.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-D-tuJArP.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-D-tuJArP.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -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;AAC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,IAAI,yCAAyC,OAAO,KAAK,IAAI;AAAA,MACxG;AACD,eAAW,SAAS;AACpB,WAAO,YAAY,IAAI,WAAW,KAAK,MAAM,UAAU;AACvD,WAAO,KAAK,cAAc,WAAW,IAAI;AAAA,EAC1C;AACD;AAEA,eAAO,iBAAwC,QAAwB,WAAmB;AACzF,MAAI,CAAC,WAAW,SAAS;AACxB,UAAM,IAAI;AAAA,MACT,iDAAiD,SAAS;AAAA,MAC1D;AAAA,IACD;AACD,QAAM,uBAAuB,oBAAI,IAAY;AAC7C,QAAM,QAAQ,GAAG,KAAK,KAAK,KAAK,WAAW,cAAc,CAAC;AAC1D,QAAM,OAA4B;AAAA,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,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,UAEjB,IAAI;AACN,QAAI,CAAC,KAAM;AACX,UAAM,YACL,aAAa,OACV,KAAK,KAAK,OAAO,IACjB,iBAAiB,SACf,KAAK,gBAAgB,uBAAuB,WAC7C,KAAK,gBAAgB,uBAAuB,QAC5C,KAAK,iBACL;AACL,QAAI,UAAW,CAAC,UAAyC,IAAI,CAAC,MAAM,SAAS,CAAC;AAAA,EAC/E;AACD;AAEA,SAAS,iBAAiB,WAAmB,cAAsB;AAClE,QAAM,WAAW,KAAK,SAAS,KAAK,QAAQ,SAAS,GAAG,KAAK,QAAQ,YAAY,CAAC;AAClF,SAAO,CAAC,CAAC,YAAY,CAAC,SAAS,WAAW,IAAI,KAAK,CAAC,KAAK,W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AAA,MACA,eAAe,KAAK;AAAA,IACrB;AACA,WAAO,OAAO,SAAS,QAAQ,IAAI,eAAe,KAAK,MAAM,cAAc;AAAA,EAC5E;AACD;AAEA,eAAO,iBAAwC,QAAwB,WAAmB;AACzF,MAAI,CAAC,WAAW,SAAS;AACxB,UAAM,IAAI;AAAA,MACT,iDAAiD,SAAS;AAAA,MAC1D;AAAA,IACD;AACD,QAAM,OAA4B;AAAA,IACjC,cAAc,oBAAI,IAAsC;AAAA,IACxD,iBAAiB,oBAAI,IAAyC;AAAA,IAC9D,sBAAsB,oBAAI,IAA8C;AAAA,IACxE,gBAAgB,oBAAI,IAAwC;AAAA,EAC7D;AACA,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-D-tuJArP.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-D-tuJArP.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.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-D-tuJArP.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 '../client/client.types.js';
2
- import { g as ComponentContext } from '../../modules.types-hjAYMYut.js';
2
+ import { g as ComponentContext } from '../../modules.types-D-tuJArP.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-D-tuJArP.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-D-tuJArP.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-D-tuJArP.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-D-tuJArP.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-D-tuJArP.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 { M as Module } from '../../modules.types-hjAYMYut.js';
2
+ export { M as Module } from '../../modules.types-D-tuJArP.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-D-tuJArP.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 { 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-D-tuJArP.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-D-tuJArP.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';
@@ -110,6 +110,7 @@ type CollatedCommandData = {
110
110
  SlashCommand: Set<CommandSetData<SlashCommandData>>;
111
111
  SlashSubcommand: Set<CommandSetData<SlashSubcommandData>>;
112
112
  SlashSubcommandGroup: Set<CommandSetData<SlashSubcommandGroupData>>;
113
+ ContextCommand: Set<CommandSetData<ContextCommandData>>;
113
114
  };
114
115
 
115
116
  type ComponentFlags = "Cached" | "DeferReply" | "EphemeralReply" | "ExpectModal";
@@ -2,7 +2,7 @@ import registerCommands from '../features/commands/registry.commands.js';
2
2
  import registerComponents from '../features/components/registry.components.js';
3
3
  import registerEvents, { bindEvents } from '../features/events/registry.events.js';
4
4
  import registerModules, { bindModules } from '../features/modules/registry.modules.js';
5
- import '../modules.types-hjAYMYut.js';
5
+ import '../modules.types-D-tuJArP.js';
6
6
  import 'discord.js';
7
7
  import '../features/client/client.types.js';
8
8
  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-D-tuJArP.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-D-tuJArP.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.6",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "discord-bot",