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.
- package/dist/features/builders/utility.builders.js +8 -5
- package/dist/features/builders/utility.builders.js.map +1 -1
- package/dist/features/client/client.types.d.ts +1 -0
- package/dist/features/client/client.types.js +0 -2
- package/dist/features/client/client.types.js.map +1 -1
- package/dist/features/client/deploy.client.d.ts +2 -1
- package/dist/features/client/deploy.client.js +8 -9
- package/dist/features/client/deploy.client.js.map +1 -1
- package/dist/features/client/logger.d.ts +11 -0
- package/dist/features/client/logger.js +24 -0
- package/dist/features/client/logger.js.map +1 -0
- package/dist/features/client/trivious.client.d.ts +2 -1
- package/dist/features/client/trivious.client.js +11 -9
- package/dist/features/client/trivious.client.js.map +1 -1
- package/dist/features/commands/builders.commands.d.ts +6 -5
- package/dist/features/commands/builders.commands.js +10 -5
- package/dist/features/commands/builders.commands.js.map +1 -1
- package/dist/features/commands/commands.types.d.ts +2 -1
- package/dist/features/commands/commands.types.js +0 -2
- package/dist/features/commands/commands.types.js.map +1 -1
- package/dist/features/commands/methods.commands.d.ts +2 -1
- package/dist/features/commands/methods.commands.js +4 -3
- package/dist/features/commands/methods.commands.js.map +1 -1
- package/dist/features/commands/registry.commands.d.ts +2 -1
- package/dist/features/commands/registry.commands.js +91 -79
- package/dist/features/commands/registry.commands.js.map +1 -1
- package/dist/features/components/builders.components.d.ts +2 -1
- package/dist/features/components/builders.components.js +7 -5
- package/dist/features/components/builders.components.js.map +1 -1
- package/dist/features/components/components.types.d.ts +2 -1
- package/dist/features/components/components.types.js +3 -3
- package/dist/features/components/components.types.js.map +1 -1
- package/dist/features/components/registry.components.d.ts +2 -1
- package/dist/features/components/registry.components.js +9 -10
- package/dist/features/components/registry.components.js.map +1 -1
- package/dist/features/customId/customid.types.d.ts +2 -1
- package/dist/features/customId/customid.types.js +0 -2
- package/dist/features/customId/customid.types.js.map +1 -1
- package/dist/features/customId/methods.customid.d.ts +2 -1
- package/dist/features/customId/methods.customid.js +4 -5
- package/dist/features/customId/methods.customid.js.map +1 -1
- package/dist/features/events/builders.events.d.ts +2 -1
- package/dist/features/events/builders.events.js +4 -3
- package/dist/features/events/builders.events.js.map +1 -1
- package/dist/features/events/events.types.d.ts +2 -1
- package/dist/features/events/events.types.js +0 -2
- package/dist/features/events/events.types.js.map +1 -1
- package/dist/features/events/presets/clientReady.d.ts +2 -1
- package/dist/features/events/presets/clientReady.js +3 -3
- package/dist/features/events/presets/clientReady.js.map +1 -1
- package/dist/features/events/presets/interactionCreate.d.ts +2 -1
- package/dist/features/events/presets/interactionCreate.js +14 -9
- package/dist/features/events/presets/interactionCreate.js.map +1 -1
- package/dist/features/events/registry.events.d.ts +2 -1
- package/dist/features/events/registry.events.js +10 -10
- package/dist/features/events/registry.events.js.map +1 -1
- package/dist/features/modules/builders.modules.d.ts +2 -1
- package/dist/features/modules/builders.modules.js +3 -3
- package/dist/features/modules/builders.modules.js.map +1 -1
- package/dist/features/modules/modules.types.d.ts +2 -1
- package/dist/features/modules/modules.types.js +0 -2
- package/dist/features/modules/modules.types.js.map +1 -1
- package/dist/features/modules/registry.modules.d.ts +2 -1
- package/dist/features/modules/registry.modules.js +9 -9
- package/dist/features/modules/registry.modules.js.map +1 -1
- package/dist/features/permissions/methods.permissions.d.ts +2 -1
- package/dist/features/permissions/methods.permissions.js +4 -3
- package/dist/features/permissions/methods.permissions.js.map +1 -1
- package/dist/features/permissions/permissions.types.js +0 -2
- package/dist/features/permissions/permissions.types.js.map +1 -1
- package/dist/features/structure/index.structure.js +11 -12
- package/dist/features/structure/index.structure.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/dist/{modules.types-lYoNHt-m.d.ts → modules.types-hjAYMYut.d.ts} +14 -6
- package/dist/shared/registries.d.ts +2 -1
- package/dist/shared/registries.js +7 -8
- package/dist/shared/registries.js.map +1 -1
- package/dist/shared/typings.d.ts +2 -1
- package/dist/shared/typings.js +11 -9
- package/dist/shared/typings.js.map +1 -1
- package/dist/utility/errors.d.ts +2 -1
- package/dist/utility/errors.js +4 -3
- package/dist/utility/errors.js.map +1 -1
- package/dist/utility/functions.js +7 -7
- package/dist/utility/functions.js.map +1 -1
- package/package.json +10 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/commands/registry.commands.ts"],"names":["fs"],"mappings":";;;;;;AAcA,SAAS,eAAA,CACR,SACA,OAAA,EACU;AACV,EAAA,IAAI,EAAE,QAAA,IAAY,OAAA,IAAW,aAAA,IAAiB,UAAU,OAAO,KAAA;AAC/D,EAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,EAAQ,OAAO,KAAA;AAC5B,EAAA,OAAO,QAAQ,OAAO,CAAA;AACvB;AAEA,eAAe,qBAAA,CACd,WACA,IAAA,EACC;AAED,EAAA,MAAM,WAAA,GAAc,IAAI,UAAA,EAAkE;AAE1F,EAAA,IAAI,EAAE,eAAA,IAAmB,IAAA,CAAK,IAAA,CAAA,EAAO,OAAO,WAAA;AAE5C,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,QAAQ,CAAC,CAAA;AAC/C,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,UAAA,GAAa,MAAM,UAAA,CAA0D,IAAI,CAAA;AACvF,IAAA,IACC,CAAC,cACD,CAAC,eAAA,CAAgB,YAAY,CAAC,MAAA,KAAW,MAAA,CAAO,OAAA,KAAY,iBAAiB,CAAA;AAE7E,MAAA;AAED,IAAA,UAAA,CAAW,MAAA,GAAS,IAAA;AACpB,IAAA,IAAA,CAAK,IAAA,CAAK,aAAA,CAAc,UAAA,CAAW,IAAI,CAAA;AAEvC,IAAA,IAAI,WAAA,CAAY,GAAA,CAAI,UAAA,CAAW,IAAA,CAAK,IAAI,CAAA;AACvC,MAAA,OAAA,CAAQ,IAAA;AAAA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xB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,kDAAkD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC3D;AAAA,KACD;AAED,EAAA,MAAM,oBAAA,uBAA2B,GAAA,EAAY;AAE7C,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA;AAEnC,IAAA,IAAI,oBAAA,CAAqB,GAAA,CAAI,SAAS,CAAA,EAAG;AACzC,IAAA,oBAAA,CAAqB,IAAI,SAAS,CAAA;AAElC,IAAA,MAAM,iBAAA,CAAkB,QAAQ,SAAS,CAAA;AAAA,EAC1C;AACD","file":"registry.commands.js","sourcesContent":["import {\n\tBaseChatInputCommandData,\n\tContextCommandData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n\tTriviousClient,\n} from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { ApplicationCommandType, Collection } from \"discord.js\";\nimport { Dirent, existsSync, promises as fs } from \"fs\";\nimport path, { join } from \"path\";\n\nfunction validateCommand<T extends BaseChatInputCommandData | ContextCommandData>(\n\tcommand: T,\n\texpects: (command: Partial<T>) => boolean\n): boolean {\n\tif (!(\"active\" in command && \"commandType\" in command)) return false;\n\tif (!command.active) return false;\n\treturn expects(command);\n}\n\nasync function parseSlashSubcommands(\n\tdirectory: string,\n\tdata: SlashCommandData | SlashSubcommandGroupData<boolean>\n) {\n\tconst _parentType = \"context\" in data ? \"command\" : \"group\";\n\tconst subcommands = new Collection<string, SlashSubcommandData<typeof _parentType, true>>();\n\n\tif (!(\"addSubcommand\" in data.data)) return subcommands;\n\n\tconst files = fs.glob(join(directory, \"./*.js\"));\n\tfor await (const file of files) {\n\t\tconst subcommand = await importFile<SlashSubcommandData<typeof _parentType, true>>(file);\n\t\tif (\n\t\t\t!subcommand ||\n\t\t\t!validateCommand(subcommand, (subcmd) => subcmd.context === \"SlashSubcommand\")\n\t\t)\n\t\t\tcontinue;\n\n\t\tsubcommand.parent = data;\n\t\tdata.data.addSubcommand(subcommand.data);\n\n\t\tif (subcommands.has(subcommand.data.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Subcommand '${subcommand.data.name}' under ${data.context} '${data.data.name}' has a duplicate and has been overridden`\n\t\t\t);\n\t\tsubcommands.set(subcommand.data.name, subcommand);\n\t}\n\n\tif (subcommands.size > 0) data.subcommands = subcommands;\n\treturn subcommands;\n}\n\nasync function parseSlashCommand(\n\tfile: string,\n\tparentDir: string,\n\tsubdirectories: Dirent<string>[]\n) {\n\tif (!existsSync(file)) return;\n\n\tconst command = await importFile<SlashCommandData>(file);\n\tif (\n\t\t!command ||\n\t\t!validateCommand(command, (cmd) => cmd.context === \"SlashCommand\") ||\n\t\t!(\"addSubcommand\" in command.data)\n\t)\n\t\treturn;\n\n\tawait parseSlashSubcommands(parentDir, command);\n\n\tfor (const subdir of subdirectories) {\n\t\tconst indexFile = path.resolve(subdir.parentPath, subdir.name, \"index.js\");\n\t\tif (!existsSync(indexFile)) continue;\n\n\t\tconst group = await importFile<SlashSubcommandGroupData<true>>(indexFile);\n\t\tif (\n\t\t\t!group ||\n\t\t\t!(\"context\" in group && \"addSubcommandGroup\" in command.data) ||\n\t\t\tgroup.context !== \"SlashSubcommandGroup\"\n\t\t)\n\t\t\tcontinue;\n\n\t\tgroup.parent = command;\n\t\tif (!command.subcommandGroups) command.subcommandGroups = new Collection();\n\t\tawait parseSlashSubcommands(join(subdir.parentPath, subdir.name), group);\n\n\t\tif (group.subcommands.size > 0) {\n\t\t\tif (command.subcommandGroups.has(group.data.name))\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Trivious] SubcommandGroup '${group.data.name}' under SlashCommand '${command.data.name}' has a duplicate and has been overridden`\n\t\t\t\t);\n\n\t\t\tcommand.data.addSubcommandGroup(group.data);\n\t\t\tcommand.subcommandGroups.set(group.data.name, group);\n\t\t}\n\t}\n\n\treturn command;\n}\n\nasync function parseContextCommands(parentDir: string) {\n\tconst collection = new Collection<string, ContextCommandData>();\n\tconst files = fs.glob(join(parentDir, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst contextCommand = await importFile<ContextCommandData>(file);\n\t\tif (\n\t\t\t!contextCommand ||\n\t\t\t!validateCommand(\n\t\t\t\tcontextCommand,\n\t\t\t\t(cmd) =>\n\t\t\t\t\tcmd.commandType === ApplicationCommandType.Message ||\n\t\t\t\t\tcmd.commandType === ApplicationCommandType.User\n\t\t\t)\n\t\t)\n\t\t\tcontinue;\n\n\t\tcontextCommand.data.setType(contextCommand.commandType);\n\t\tcollection.set(contextCommand.data.name, contextCommand);\n\t}\n\n\treturn collection;\n}\n\nasync function registerDirectory(client: TriviousClient, parentDir: string) {\n\tconst entries = await fs.readdir(parentDir, { withFileTypes: true });\n\tconst subdirectories = entries.filter((entry) => entry.isDirectory());\n\n\tconst indexFile = path.resolve(parentDir, \"index.js\");\n\tconst slashCommand = await parseSlashCommand(indexFile, parentDir, subdirectories);\n\tif (slashCommand) {\n\t\tif (client.stores.commands.chatInput.has(slashCommand.data.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] SlashCommand '${slashCommand.data.name}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);\n\t}\n\n\tconst contextCommands = await parseContextCommands(parentDir);\n\tcontextCommands.forEach((cmd) => client.stores.commands.context.set(cmd.data.name, cmd));\n}\n\nexport default async function registerCommands(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register commands; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst processedDirectories = new Set<string>();\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst parentDir = path.dirname(file);\n\n\t\tif (processedDirectories.has(parentDir)) continue;\n\t\tprocessedDirectories.add(parentDir);\n\n\t\tawait registerDirectory(client, parentDir);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/features/commands/registry.commands.ts"],"sourcesContent":["import {\n\tCollatedCommandData,\n\tCommandSetData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n\tTriviousClient,\n} from \"@typings\";\nimport { TriviousError } from \"@utility/errors.js\";\nimport { importFile } from \"@utility/functions.js\";\nimport { Collection } from \"discord.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport path from \"path\";\n\nasync function parseBase<T>(input: string | T, expects?: (base: Partial<T>) => boolean) {\n\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.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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AAI,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,SAAS,UAAU,IAAI,aAAa,KAAK,MAAM,YAAY;AAAA,EAC1E;AACD;","names":["base"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as Component, g as ComponentContext } 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
|
/**
|
|
7
8
|
* Create component handler
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ComponentContext } from
|
|
2
|
-
|
|
1
|
+
import { ComponentContext } from "../../shared/typings.js";
|
|
3
2
|
function createComponent(data) {
|
|
4
3
|
return data;
|
|
5
4
|
}
|
|
@@ -21,7 +20,10 @@ function createModalComponent(data) {
|
|
|
21
20
|
...data
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
export {
|
|
24
|
+
createButtonComponent,
|
|
25
|
+
createComponent,
|
|
26
|
+
createModalComponent,
|
|
27
|
+
createSelectMenuComponent
|
|
28
|
+
};
|
|
27
29
|
//# sourceMappingURL=builders.components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/components/builders.components.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/components/builders.components.ts"],"sourcesContent":["import { Component, ComponentContext } from \"@typings\";\n\n/**\n * Create component handler\n * @param data Component data\n * @returns Component\n */\nexport function createComponent<Context extends ComponentContext = ComponentContext>(\n\tdata: Component<Context>\n): Component<Context> {\n\treturn data;\n}\n\n/**\n * Create a button component handler\n * @param data Component data\n * @returns Button Component\n */\nexport function createButtonComponent(\n\tdata: Omit<Component<ComponentContext.Button>, \"context\" | \"component\">\n): Component<ComponentContext.Button> {\n\treturn {\n\t\tcontext: ComponentContext.Button,\n\t\t...data,\n\t};\n}\n\n/**\n * Create a select menu component handler\n * @param data Component data\n * @returns AnySelectMenu Component\n */\nexport function createSelectMenuComponent(\n\tdata: Omit<Component<ComponentContext.SelectMenu>, \"context\" | \"component\">\n): Component<ComponentContext.SelectMenu> {\n\treturn {\n\t\tcontext: ComponentContext.SelectMenu,\n\t\t...data,\n\t};\n}\n\n/**\n * Create a modal component handler\n * @param data Component data\n * @returns Modal Component\n */\nexport function createModalComponent(\n\tdata: Omit<Component<ComponentContext.Modal>, \"context\" | \"component\">\n): Component<ComponentContext.Modal> {\n\treturn {\n\t\tcontext: ComponentContext.Modal,\n\t\t...data,\n\t};\n}\n"],"mappings":"AAAA,SAAoB,wBAAwB;AAOrC,SAAS,gBACf,MACqB;AACrB,SAAO;AACR;AAOO,SAAS,sBACf,MACqC;AACrC,SAAO;AAAA,IACN,SAAS,iBAAiB;AAAA,IAC1B,GAAG;AAAA,EACJ;AACD;AAOO,SAAS,0BACf,MACyC;AACzC,SAAO;AAAA,IACN,SAAS,iBAAiB;AAAA,IAC1B,GAAG;AAAA,EACJ;AACD;AAOO,SAAS,qBACf,MACoC;AACpC,SAAO;AAAA,IACN,SAAS,iBAAiB;AAAA,IAC1B,GAAG;AAAA,EACJ;AACD;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export {
|
|
2
|
+
export { f as Component, g as ComponentContext, h as ComponentFlags, i as ComponentInteraction } from '../../modules.types-hjAYMYut.js';
|
|
3
3
|
import '../permissions/permissions.types.js';
|
|
4
4
|
import '../client/client.types.js';
|
|
5
|
+
import '../client/logger.js';
|
|
@@ -4,7 +4,7 @@ var ComponentContext = /* @__PURE__ */ ((ComponentContext2) => {
|
|
|
4
4
|
ComponentContext2[ComponentContext2["Modal"] = 2] = "Modal";
|
|
5
5
|
return ComponentContext2;
|
|
6
6
|
})(ComponentContext || {});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export {
|
|
8
|
+
ComponentContext
|
|
9
|
+
};
|
|
10
10
|
//# sourceMappingURL=components.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/components/components.types.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/components/components.types.ts"],"sourcesContent":["import { CommandPermissionValues, TriviousClient } from \"@typings\";\nimport { AnySelectMenuInteraction, ButtonInteraction, ModalSubmitInteraction } from \"discord.js\";\n\nexport type ComponentFlags = \"Cached\" | \"DeferReply\" | \"EphemeralReply\" | \"ExpectModal\";\nexport type ComponentInteraction =\n\t| AnySelectMenuInteraction\n\t| ButtonInteraction\n\t| ModalSubmitInteraction;\n\nexport enum ComponentContext {\n\tButton,\n\tSelectMenu,\n\tModal,\n}\n\ntype ContextualComponentInteraction<Context extends ComponentContext = ComponentContext> =\n\tContext extends ComponentContext.Button\n\t\t? ButtonInteraction\n\t\t: Context extends ComponentContext.SelectMenu\n\t\t\t? AnySelectMenuInteraction\n\t\t\t: Context extends ComponentContext.Modal\n\t\t\t\t? ModalSubmitInteraction\n\t\t\t\t: ComponentInteraction;\n\n/**\n * Trivious component\n * @param context The component context\n * @param identifier The unique identifier inside the custom id\n * @param flags The component flags\n * @param execute Component handler\n */\nexport interface Component<Context extends ComponentContext = ComponentContext> {\n\t/**\n\t * @deprecated Use context instead\n\t */\n\tcomponent?: Context;\n\tcontext: Context;\n\tidentifier: string;\n\tflags?: ComponentFlags[];\n\tpermissions?: CommandPermissionValues;\n\texecute: (\n\t\tclient: TriviousClient,\n\t\tinteraction: ContextualComponentInteraction<Context>\n\t) => Promise<void>;\n}\n"],"mappings":"AASO,IAAK,mBAAL,kBAAKA,sBAAL;AACN,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AACA,EAAAA,oCAAA;AAHW,SAAAA;AAAA,GAAA;","names":["ComponentContext"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { T as TriviousClient } from '../../modules.types-
|
|
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 registerComponents(client: TriviousClient, directory: string): Promise<void>;
|
|
7
8
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { ComponentContext } from
|
|
2
|
-
import { TriviousError } from
|
|
3
|
-
import { importFile } from
|
|
4
|
-
import { existsSync, promises } from
|
|
5
|
-
import { join } from
|
|
6
|
-
|
|
1
|
+
import { ComponentContext } from "../../shared/typings.js";
|
|
2
|
+
import { TriviousError } from "../../utility/errors.js";
|
|
3
|
+
import { importFile } from "../../utility/functions.js";
|
|
4
|
+
import { existsSync, promises as fs } from "fs";
|
|
5
|
+
import { join } from "path";
|
|
7
6
|
async function registerComponents(client, directory) {
|
|
8
7
|
if (!existsSync(directory))
|
|
9
8
|
throw new TriviousError(
|
|
10
9
|
`Could not register components; passed directory '${directory} does not exist!'`,
|
|
11
10
|
"Nonexistant directory passed"
|
|
12
11
|
);
|
|
13
|
-
const files =
|
|
12
|
+
const files = fs.glob(join(directory, "**/*.js"));
|
|
14
13
|
for await (const file of files) {
|
|
15
14
|
const component = await importFile(file);
|
|
16
15
|
if (!component || !("component" in component && "identifier" in component && "execute" in component))
|
|
@@ -22,7 +21,7 @@ async function registerComponents(client, directory) {
|
|
|
22
21
|
client.stores.components.set(component.identifier, component);
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
export {
|
|
25
|
+
registerComponents as default
|
|
26
|
+
};
|
|
28
27
|
//# sourceMappingURL=registry.components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/components/registry.components.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/components/registry.components.ts"],"sourcesContent":["import { Component, ComponentContext, TriviousClient } from \"@typings\";\nimport { TriviousError } from \"@utility/errors.js\";\nimport { importFile } from \"@utility/functions.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\n\nexport default async function registerComponents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register components; passed directory '${directory} does not exist!'`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst component = await importFile<Component>(file);\n\t\tif (\n\t\t\t!component ||\n\t\t\t!(\"component\" in component && \"identifier\" in component && \"execute\" in component)\n\t\t)\n\t\t\tcontinue;\n\n\t\tif (client.stores.components.get(component.identifier))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Component identifier '${component.identifier}' with the context '${ComponentContext[component.context]}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.components.set(component.identifier, component);\n\t}\n}\n"],"mappings":"AAAA,SAAoB,wBAAwC;AAC5D,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,YAAY,YAAY,UAAU;AAC3C,SAAS,YAAY;AAErB,eAAO,mBAA0C,QAAwB,WAAmB;AAC3F,MAAI,CAAC,WAAW,SAAS;AACxB,UAAM,IAAI;AAAA,MACT,oDAAoD,SAAS;AAAA,MAC7D;AAAA,IACD;AAED,QAAM,QAAQ,GAAG,KAAK,KAAK,WAAW,SAAS,CAAC;AAChD,mBAAiB,QAAQ,OAAO;AAC/B,UAAM,YAAY,MAAM,WAAsB,IAAI;AAClD,QACC,CAAC,aACD,EAAE,eAAe,aAAa,gBAAgB,aAAa,aAAa;AAExE;AAED,QAAI,OAAO,OAAO,WAAW,IAAI,UAAU,UAAU;AACpD,cAAQ;AAAA,QACP,oCAAoC,UAAU,UAAU,uBAAuB,iBAAiB,UAAU,OAAO,CAAC;AAAA,MACnH;AAED,WAAO,OAAO,WAAW,IAAI,UAAU,YAAY,SAAS;AAAA,EAC7D;AACD;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import '../client/client.types.js';
|
|
2
|
-
import {
|
|
2
|
+
import { g as ComponentContext } from '../../modules.types-hjAYMYut.js';
|
|
3
3
|
import '../permissions/permissions.types.js';
|
|
4
4
|
import 'discord.js';
|
|
5
|
+
import '../client/logger.js';
|
|
5
6
|
|
|
6
7
|
type ComponentTag = "awaited";
|
|
7
8
|
interface ComponentCustomId {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ComponentCustomId } from './customid.types.js';
|
|
2
2
|
import '../client/client.types.js';
|
|
3
3
|
import 'discord.js';
|
|
4
|
-
import '../../modules.types-
|
|
4
|
+
import '../../modules.types-hjAYMYut.js';
|
|
5
5
|
import '../permissions/permissions.types.js';
|
|
6
|
+
import '../client/logger.js';
|
|
6
7
|
|
|
7
8
|
declare const customId: {
|
|
8
9
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { TriviousError } from
|
|
2
|
-
|
|
1
|
+
import { TriviousError } from "../../utility/errors.js";
|
|
3
2
|
const customId = {
|
|
4
3
|
/**
|
|
5
4
|
* Decode a customId into its parts
|
|
@@ -27,7 +26,7 @@ const customId = {
|
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
var methods_customid_default = customId;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
export {
|
|
30
|
+
methods_customid_default as default
|
|
31
|
+
};
|
|
33
32
|
//# sourceMappingURL=methods.customid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/customId/methods.customid.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/customId/methods.customid.ts"],"sourcesContent":["import { ComponentContext, ComponentCustomId, ComponentTag } from \"@typings\";\nimport { TriviousError } from \"@utility/errors.js\";\n\nconst customId = {\n\t/**\n\t * Decode a customId into its parts\n\t */\n\tdecode: (customId: string) => {\n\t\tconst [context, identifier, info] = customId.split(\":\") as [\n\t\t\tComponentContext,\n\t\t\tstring,\n\t\t\tstring | undefined,\n\t\t];\n\t\tconst [data, ...tags] = info\n\t\t\t? (info.split(\".\") as [string | undefined, ...ComponentTag[]])\n\t\t\t: [undefined, undefined];\n\n\t\treturn {\n\t\t\tcontext,\n\t\t\tidentifier,\n\t\t\tdata,\n\t\t\ttags,\n\t\t} as ComponentCustomId;\n\t},\n\t/**\n\t * Encode a customId\n\t */\n\tencode: (options: ComponentCustomId) => {\n\t\tconst { context, identifier, data, tags } = options;\n\t\tlet customId = `${context}:${identifier}`;\n\n\t\tif (data) customId += `:${data}`;\n\t\tif (tags) customId += `.${tags.join(\".\")}`;\n\n\t\tif (customId.length > 100) throw new TriviousError(\"Encoded customId exceeds 100 characters.\");\n\t\treturn customId;\n\t},\n} as const;\n\nexport default customId;\n"],"mappings":"AACA,SAAS,qBAAqB;AAE9B,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAIhB,QAAQ,CAACA,cAAqB;AAC7B,UAAM,CAAC,SAAS,YAAY,IAAI,IAAIA,UAAS,MAAM,GAAG;AAKtD,UAAM,CAAC,MAAM,GAAG,IAAI,IAAI,OACpB,KAAK,MAAM,GAAG,IACf,CAAC,QAAW,MAAS;AAExB,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAIA,QAAQ,CAAC,YAA+B;AACvC,UAAM,EAAE,SAAS,YAAY,MAAM,KAAK,IAAI;AAC5C,QAAIA,YAAW,GAAG,OAAO,IAAI,UAAU;AAEvC,QAAI,KAAM,CAAAA,aAAY,IAAI,IAAI;AAC9B,QAAI,KAAM,CAAAA,aAAY,IAAI,KAAK,KAAK,GAAG,CAAC;AAExC,QAAIA,UAAS,SAAS,IAAK,OAAM,IAAI,cAAc,0CAA0C;AAC7F,WAAOA;AAAA,EACR;AACD;AAEA,IAAO,2BAAQ;","names":["customId"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { E as Event } from '../../modules.types-
|
|
1
|
+
import { E as Event } 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
|
/**
|
|
7
8
|
* Create an event handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/events/builders.events.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/events/builders.events.ts"],"sourcesContent":["import { Event } from \"@typings\";\n\n/**\n * Create an event handler\n * @param data Event data\n * @returns Event\n */\nexport function createEvent(data: Event): Event {\n\treturn data;\n}\n\n/**\n * Create an event handler that runs once\n * @param data Event data\n * @returns Event\n */\nexport function createOnceEvent(data: Omit<Event, \"once\">): Event {\n\treturn {\n\t\tonce: true,\n\t\t...data,\n\t} satisfies Event;\n}\n"],"mappings":"AAOO,SAAS,YAAY,MAAoB;AAC/C,SAAO;AACR;AAOO,SAAS,gBAAgB,MAAkC;AACjE,SAAO;AAAA,IACN,MAAM;AAAA,IACN,GAAG;AAAA,EACJ;AACD;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { T as TriviousClient } from '../../../modules.types-
|
|
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 const _default: {
|
|
7
8
|
name: "clientReady";
|
|
@@ -5,7 +5,7 @@ var clientReady_default = {
|
|
|
5
5
|
console.log(`Successfully logged into ${client.user?.username}`);
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export {
|
|
9
|
+
clientReady_default as default
|
|
10
|
+
};
|
|
11
11
|
//# sourceMappingURL=clientReady.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/events/presets/clientReady.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/events/presets/clientReady.ts"],"sourcesContent":["import { Event } from \"@typings\";\n\nexport default {\n\tname: \"clientReady\",\n\tonce: true,\n\tasync execute(client) {\n\t\tconsole.log(`Successfully logged into ${client.user?.username}`);\n\t},\n} satisfies Event<\"clientReady\">;\n"],"mappings":"AAEA,IAAO,sBAAQ;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM,QAAQ,QAAQ;AACrB,YAAQ,IAAI,4BAA4B,OAAO,MAAM,QAAQ,EAAE;AAAA,EAChE;AACD;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { T as TriviousClient } from '../../../modules.types-
|
|
2
|
+
import { T as TriviousClient } 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 const _default: {
|
|
7
8
|
name: "interactionCreate";
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { handleSlashCommand, interactionReply } from "../../commands/methods.commands.js";
|
|
2
|
+
import customId from "../../customId/methods.customid.js";
|
|
3
|
+
import { canMemberRunCommand } from "../../permissions/methods.permissions.js";
|
|
4
|
+
import {
|
|
5
|
+
ComponentContext
|
|
6
|
+
} from "../../../shared/typings.js";
|
|
7
|
+
import {
|
|
8
|
+
ApplicationCommandType,
|
|
9
|
+
ButtonInteraction,
|
|
10
|
+
ModalSubmitInteraction
|
|
11
|
+
} from "discord.js";
|
|
7
12
|
function validateMemberPermissionsForSubcommand(client, command, interaction) {
|
|
8
13
|
if (!("subcommands" in command)) return [false, "Cannot validate subcommand permissions"];
|
|
9
14
|
if (!interaction.isChatInputCommand()) return [false, "Cannot validate subcommand permissions"];
|
|
@@ -88,7 +93,7 @@ var interactionCreate_default = {
|
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
export {
|
|
97
|
+
interactionCreate_default as default
|
|
98
|
+
};
|
|
94
99
|
//# sourceMappingURL=interactionCreate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"sourcesContent":["import { handleSlashCommand, interactionReply } from \"@feature/commands/methods.commands.js\";\nimport customId from \"@feature/customId/methods.customid.js\";\nimport { canMemberRunCommand } from \"@feature/permissions/methods.permissions.js\";\nimport {\n\tComponentContext,\n\tSlashCommandData,\n\tTriviousClient,\n\ttype ContextCommandData,\n\ttype Event,\n} from \"@typings\";\nimport {\n\tApplicationCommandType,\n\tButtonInteraction,\n\tChatInputCommandInteraction,\n\tGuildMember,\n\tMessageContextMenuCommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\n\n/**\n * Check if the command is a subcommand and validate whether the member can run the command based on subcommand permissions\n */\nfunction validateMemberPermissionsForSubcommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData | ContextCommandData,\n\tinteraction:\n\t\t| ChatInputCommandInteraction\n\t\t| MessageContextMenuCommandInteraction\n\t\t| UserContextMenuCommandInteraction\n): [boolean, string] {\n\tif (!(\"subcommands\" in command)) return [false, \"Cannot validate subcommand permissions\"];\n\tif (!interaction.isChatInputCommand()) return [false, \"Cannot validate subcommand permissions\"];\n\n\tconst { options } = interaction;\n\n\tconst subcommandName = options.getSubcommand(false);\n\tconst groupName = options.getSubcommandGroup(false);\n\tif (!subcommandName) return [false, \"Cannot validate subcommand permissions\"];\n\n\tif (groupName) {\n\t\tconst group = command.subcommandGroups?.get(groupName);\n\t\tif (!group) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\tconst subcommand = group.subcommands.get(subcommandName);\n\t\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n\t}\n\n\tconst subcommand = command.subcommands?.get(subcommandName);\n\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n}\n\nexport default {\n\tname: \"interactionCreate\",\n\tasync execute(client, interaction) {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst storeToCheck = interaction.isChatInputCommand()\n\t\t\t\t? client.stores.commands.chatInput\n\t\t\t\t: client.stores.commands.context;\n\t\t\tconst command = storeToCheck.get(commandName);\n\n\t\t\tif (!command) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst subcommandPerms = validateMemberPermissionsForSubcommand(client, command, interaction);\n\t\t\tconst commandPerms = canMemberRunCommand(client, command, interaction.member as GuildMember);\n\t\t\tconst hasPermission = subcommandPerms[0] && commandPerms[0] ? true : false;\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: {\n\t\t\t\t\t\tcontent: `You do not have permission to run this command`,\n\t\t\t\t\t},\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tcommand.commandType === ApplicationCommandType.ChatInput &&\n\t\t\t\tinteraction.isChatInputCommand()\n\t\t\t) {\n\t\t\t\tawait handleSlashCommand(client, command, interaction);\n\t\t\t} else {\n\t\t\t\tawait (command as ContextCommandData).execute(client, interaction as never);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { context, identifier, tags } = customId.decode(interaction.customId);\n\t\t\tif (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))\n\t\t\t\treturn;\n\t\t\tif (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst component = client.stores.components.get(identifier);\n\n\t\t\tif (!component) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst hasPermission = canMemberRunCommand(\n\t\t\t\tclient,\n\t\t\t\tcomponent,\n\t\t\t\tinteraction.member as GuildMember\n\t\t\t);\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"You do not have permission to use this component\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"],"mappings":"AAAA,SAAS,oBAAoB,wBAAwB;AACrD,OAAO,cAAc;AACrB,SAAS,2BAA2B;AACpC;AAAA,EACC;AAAA,OAKM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EAIA;AAAA,OAEM;AAKP,SAAS,uCACR,QACA,SACA,aAIoB;AACpB,MAAI,EAAE,iBAAiB,SAAU,QAAO,CAAC,OAAO,wCAAwC;AACxF,MAAI,CAAC,YAAY,mBAAmB,EAAG,QAAO,CAAC,OAAO,wCAAwC;AAE9F,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,iB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AA,UACV;AAAA,UACA,OAAO,CAAC,gBAAgB;AAAA,QACzB,CAAC;AACD;AAAA,MACD;AAEA,UACC,QAAQ,gBAAgB,uBAAuB,aAC/C,YAAY,mBAAmB,GAC9B;AACD,cAAM,mBAAmB,QAAQ,SAAS,WAAW;AAAA,MACtD,OAAO;AACN,cAAO,QAA+B,QAAQ,QAAQ,WAAoB;AAAA,MAC3E;AAAA,IACD,WAAW,YAAY,mBAAmB,KAAK,YAAY,cAAc,GAAG;AAC3E,YAAM,EAAE,SAAS,YAAY,KAAK,IAAI,SAAS,OAAO,YAAY,QAAQ;AAC1E,UAAI,YAAY,iBAAiB,UAAU,EAAE,uBAAuB;AACnE;AACD,UAAI,YAAY,iBAAiB,SAAS,EAAE,uBAAuB;AAClE;AACD,UAAI,QAAQ,KAAK,SAAS,SAAS,EAAG;AAEtC,YAAM,YAAY,OAAO,OAAO,WAAW,IAAI,UAAU;AAEzD,UAAI,CAAC,WAAW;AACf,cAAM,iBAAiB;AAAA,UACtB;AAAA,UACA,cAAc,EAAE,SAAS,6DAA6D;AAAA,UACtF,OAAO,CAAC,gBAAgB;AAAA,QACzB,CAAC;AACD;AAAA,MACD;AAEA,YAAM,gBAAgB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,YAAY;AAAA,MACb;AACA,UAAI,CAAC,eAAe;AACnB,cAAM,iBAAiB;AAAA,UACtB;AAAA,UACA,cAAc,EAAE,SAAS,mDAAmD;AAAA,UAC5E,OAAO,CAAC,gBAAgB;AAAA,QACzB,CAAC;AACD;AAAA,MACD;AACA,YAAM,UAAU,QAAQ,QAAQ,WAAW;AAAA,IAC5C;AAAA,EACD;AACD;","names":["subcommand"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { T as TriviousClient } from '../../modules.types-
|
|
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 bindEvents(client: TriviousClient): Promise<void>;
|
|
7
8
|
declare function registerEvents(client: TriviousClient, directory: string): Promise<void>;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { TriviousError } from
|
|
2
|
-
import { importFile } from
|
|
3
|
-
import { existsSync, promises } from
|
|
4
|
-
import path, { join } from
|
|
5
|
-
|
|
1
|
+
import { TriviousError } from "../../utility/errors.js";
|
|
2
|
+
import { importFile } from "../../utility/functions.js";
|
|
3
|
+
import { existsSync, promises as fs } from "fs";
|
|
4
|
+
import path, { join } from "path";
|
|
6
5
|
async function loadPresetEvents(client) {
|
|
7
6
|
const directory = path.resolve(import.meta.dirname, "presets");
|
|
8
7
|
if (!existsSync(directory)) return;
|
|
9
|
-
const files =
|
|
8
|
+
const files = fs.glob(join(directory, "./*.js"));
|
|
10
9
|
for await (const file of files) {
|
|
11
10
|
const event = await parseEvent(file);
|
|
12
11
|
if (!event) continue;
|
|
@@ -32,7 +31,7 @@ async function registerEvents(client, directory) {
|
|
|
32
31
|
"Nonexistant directory passed"
|
|
33
32
|
);
|
|
34
33
|
await loadPresetEvents(client);
|
|
35
|
-
const files =
|
|
34
|
+
const files = fs.glob(join(directory, "**/*.js"));
|
|
36
35
|
for await (const file of files) {
|
|
37
36
|
const event = await parseEvent(file);
|
|
38
37
|
if (!event) continue;
|
|
@@ -41,7 +40,8 @@ async function registerEvents(client, directory) {
|
|
|
41
40
|
client.stores.events.set(event.name, event);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
export {
|
|
44
|
+
bindEvents,
|
|
45
|
+
registerEvents as default
|
|
46
|
+
};
|
|
47
47
|
//# sourceMappingURL=registry.events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/events/registry.events.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/events/registry.events.ts"],"sourcesContent":["import { Event, TriviousClient } from \"@typings\";\nimport { TriviousError } from \"@utility/errors.js\";\nimport { importFile } from \"@utility/functions.js\";\nimport { ClientEvents } from \"discord.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport path, { join } from \"path\";\n\nasync function loadPresetEvents(client: TriviousClient) {\n\tconst directory = path.resolve(import.meta.dirname, \"presets\");\n\tif (!existsSync(directory)) return;\n\n\tconst files = fs.glob(join(directory, \"./*.js\"));\n\tfor await (const file of files) {\n\t\tconst event = await parseEvent(file);\n\t\tif (!event) continue;\n\n\t\tclient.stores.events.set(event.name, event);\n\t}\n}\n\nasync function parseEvent(file: string) {\n\tconst event = await importFile<Event>(file);\n\tif (!event || !(\"name\" in event && \"execute\" in event)) return null;\n\n\treturn event;\n}\n\nexport async function bindEvents(client: TriviousClient) {\n\tfor (const event of client.stores.events.values()) {\n\t\tconst handler = (...args: ClientEvents[typeof event.name]) =>\n\t\t\tvoid event.execute(client, ...args);\n\n\t\tif (event.once) client.once(event.name, handler);\n\t\telse client.on(event.name, handler);\n\t}\n}\n\nexport default async function registerEvents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register events; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tawait loadPresetEvents(client);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst event = await parseEvent(file);\n\t\tif (!event) continue;\n\n\t\tif (client.stores.events.get(event.name))\n\t\t\tconsole.warn(`[Trivious] Event '${event.name}' has a duplicate and has been overridden`);\n\n\t\tclient.stores.events.set(event.name, event);\n\t}\n}\n"],"mappings":"AACA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAE3B,SAAS,YAAY,YAAY,UAAU;AAC3C,OAAO,QAAQ,YAAY;AAE3B,eAAe,iBAAiB,QAAwB;AACvD,QAAM,YAAY,KAAK,QAAQ,YAAY,SAA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YMYut.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
|
/**
|
|
7
8
|
* Create a module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/modules/builders.modules.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/modules/builders.modules.ts"],"sourcesContent":["import { Module } from \"@typings\";\n\n/**\n * Create a module\n * @param data Module data\n * @returns Module\n */\nexport function createModule(data: Module) {\n\treturn data;\n}\n"],"mappings":"AAOO,SAAS,aAAa,MAAc;AAC1C,SAAO;AACR;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { T as TriviousClient } from '../../modules.types-
|
|
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 bindModules(client: TriviousClient): Promise<void>;
|
|
7
8
|
declare function registerModules(client: TriviousClient, directory: string): Promise<void>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { TriviousError } from
|
|
2
|
-
import { importFile } from
|
|
3
|
-
import { existsSync, promises } from
|
|
4
|
-
import { join } from
|
|
5
|
-
|
|
1
|
+
import { TriviousError } from "../../utility/errors.js";
|
|
2
|
+
import { importFile } from "../../utility/functions.js";
|
|
3
|
+
import { existsSync, promises as fs } from "fs";
|
|
4
|
+
import { join } from "path";
|
|
6
5
|
async function bindModules(client) {
|
|
7
6
|
for (const moduleData of client.stores.modules.values()) {
|
|
8
7
|
for (const [name, handler] of Object.entries(moduleData.events)) {
|
|
@@ -17,7 +16,7 @@ async function registerModules(client, directory) {
|
|
|
17
16
|
`Could not register modules; passed directory '${directory}' does not exist!`,
|
|
18
17
|
"Nonexistant directory passed"
|
|
19
18
|
);
|
|
20
|
-
const files =
|
|
19
|
+
const files = fs.glob(join(directory, "**/*.js"));
|
|
21
20
|
for await (const file of files) {
|
|
22
21
|
const moduleData = await importFile(file);
|
|
23
22
|
if (!moduleData || !("name" in moduleData && "events" in moduleData)) continue;
|
|
@@ -28,7 +27,8 @@ async function registerModules(client, directory) {
|
|
|
28
27
|
client.stores.modules.set(moduleData.name, moduleData);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
export {
|
|
31
|
+
bindModules,
|
|
32
|
+
registerModules as default
|
|
33
|
+
};
|
|
34
34
|
//# sourceMappingURL=registry.modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/modules/registry.modules.ts"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/features/modules/registry.modules.ts"],"sourcesContent":["import { Module, TriviousClient } from \"@typings\";\nimport { TriviousError } from \"@utility/errors.js\";\nimport { importFile } from \"@utility/functions.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\n\nexport async function bindModules(client: TriviousClient) {\n\tfor (const moduleData of client.stores.modules.values()) {\n\t\tfor (const [name, handler] of Object.entries(moduleData.events)) {\n\t\t\tconst listener = (...args: unknown[]) =>\n\t\t\t\tvoid (handler as (client: TriviousClient, ...args: unknown[]) => any)(client, ...args);\n\n\t\t\tclient.on(name, listener);\n\t\t}\n\t}\n}\n\nexport default async function registerModules(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register modules; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst moduleData = await importFile<Module>(file);\n\t\tif (!moduleData || !(\"name\" in moduleData && \"events\" in moduleData)) continue;\n\n\t\tif (client.stores.events.get(moduleData.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Module '${moduleData.name}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.modules.set(moduleData.name, moduleData);\n\t}\n}\n"],"mappings":"AACA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,YAAY,YAAY,UAAU;AAC3C,SAAS,YAAY;AAErB,eAAsB,YAAY,QAAwB;AACzD,aAAW,cAAc,OAAO,OAAO,QAAQ,OAAO,GAAG;AACxD,eAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,WAAW,MAAM,GAAG;AAChE,YAAM,WAAW,IAAI,SACpB,KAAM,QAAgE,QAAQ,GAAG,IAAI;AAEtF,aAAO,GAAG,MAAM,QAAQ;AAAA,IACzB;AAAA,EACD;AACD;AAEA,eAAO,gBAAuC,QAAwB,WAAmB;AACxF,MAAI,CAAC,WAAW,SAAS;AACxB,UAAM,IAAI;AAAA,MACT,iDAAiD,SAAS;AAAA,MAC1D;AAAA,IACD;AAED,QAAM,QAAQ,GAAG,KAAK,KAAK,WAAW,SAAS,CAAC;AAChD,mBAAiB,QAAQ,OAAO;AAC/B,UAAM,aAAa,MAAM,WAAmB,IAAI;AAChD,QAAI,CAAC,cAAc,EAAE,UAAU,cAAc,YAAY,YAAa;AAEtE,QAAI,OAAO,OAAO,OAAO,IAAI,WAAW,IAAI;AAC3C,cAAQ;AAAA,QACP,sBAAsB,WAAW,IAAI;AAAA,MACtC;AAED,WAAO,OAAO,QAAQ,IAAI,WAAW,MAAM,UAAU;AAAA,EACtD;AACD;","names":[]}
|