trivious 1.6.18 → 2.0.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/README.md +57 -68
- package/dist/{core/builders/util.builders.d.ts → features/builders/utility.builders.d.ts} +0 -9
- package/dist/{core/builders/util.builders.js → features/builders/utility.builders.js} +2 -2
- package/dist/features/builders/utility.builders.js.map +1 -0
- package/dist/features/client/client.types.d.ts +85 -0
- package/dist/features/client/client.types.js +3 -0
- package/dist/{shared/typings/client.js.map → features/client/client.types.js.map} +1 -1
- package/dist/features/client/deploy.client.d.ts +7 -0
- package/dist/features/client/deploy.client.js +43 -0
- package/dist/features/client/deploy.client.js.map +1 -0
- package/dist/features/client/trivious.client.d.ts +3 -0
- package/dist/features/client/trivious.client.js +61 -0
- package/dist/features/client/trivious.client.js.map +1 -0
- package/dist/features/commands/commands.types.d.ts +3 -0
- package/dist/features/commands/commands.types.js +3 -0
- package/dist/{shared/typings/commands.js.map → features/commands/commands.types.js.map} +1 -1
- package/dist/features/commands/methods.commands.d.ts +13 -0
- package/dist/features/commands/methods.commands.js +70 -0
- package/dist/features/commands/methods.commands.js.map +1 -0
- package/dist/features/commands/registry.commands.d.ts +7 -0
- package/dist/features/commands/registry.commands.js +90 -0
- package/dist/features/commands/registry.commands.js.map +1 -0
- package/dist/features/components/components.types.d.ts +3 -0
- package/dist/features/components/components.types.js +10 -0
- package/dist/features/components/components.types.js.map +1 -0
- package/dist/features/components/registry.components.d.ts +7 -0
- package/dist/features/components/registry.components.js +23 -0
- package/dist/features/components/registry.components.js.map +1 -0
- package/dist/features/customId/customid.types.d.ts +13 -0
- package/dist/features/customId/customid.types.js +3 -0
- package/dist/features/customId/customid.types.js.map +1 -0
- package/dist/features/customId/methods.customid.d.ts +20 -0
- package/dist/features/customId/methods.customid.js +24 -0
- package/dist/features/customId/methods.customid.js.map +1 -0
- package/dist/features/events/events.types.d.ts +3 -0
- package/dist/features/events/events.types.js +3 -0
- package/dist/{shared/typings/events.js.map → features/events/events.types.js.map} +1 -1
- package/dist/features/events/presets/clientReady.d.ts +11 -0
- package/dist/{core/events → features/events/presets}/clientReady.js +1 -1
- package/dist/features/events/presets/clientReady.js.map +1 -0
- package/dist/features/events/presets/interactionCreate.d.ts +10 -0
- package/dist/features/events/presets/interactionCreate.js +49 -0
- package/dist/features/events/presets/interactionCreate.js.map +1 -0
- package/dist/features/events/registry.events.d.ts +8 -0
- package/dist/features/events/registry.events.js +45 -0
- package/dist/features/events/registry.events.js.map +1 -0
- package/dist/features/modules/modules.types.d.ts +3 -0
- package/dist/features/modules/modules.types.js +3 -0
- package/dist/{shared/typings/module.js.map → features/modules/modules.types.js.map} +1 -1
- package/dist/features/modules/registry.modules.d.ts +8 -0
- package/dist/features/modules/registry.modules.js +30 -0
- package/dist/features/modules/registry.modules.js.map +1 -0
- package/dist/features/structure/index.structure.d.ts +10 -0
- package/dist/features/structure/index.structure.js +51 -0
- package/dist/features/structure/index.structure.js.map +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +4 -10
- package/dist/modules.types-4hfuUiCb.d.ts +165 -0
- package/dist/shared/registries.d.ts +26 -0
- package/dist/shared/registries.js +25 -0
- package/dist/shared/registries.js.map +1 -0
- package/dist/shared/typings.d.ts +4 -0
- package/dist/shared/typings.js +9 -0
- package/dist/shared/typings.js.map +1 -0
- package/dist/utility/errors.d.ts +15 -0
- package/dist/utility/errors.js +24 -0
- package/dist/utility/errors.js.map +1 -0
- package/dist/utility/functions.d.ts +4 -0
- package/dist/utility/functions.js +32 -0
- package/dist/utility/functions.js.map +1 -0
- package/package.json +7 -3
- package/dist/core/builders/util.builders.js.map +0 -1
- package/dist/core/client/trivious.client.d.ts +0 -6
- package/dist/core/client/trivious.client.js +0 -115
- package/dist/core/client/trivious.client.js.map +0 -1
- package/dist/core/commands/methods.command.d.ts +0 -6
- package/dist/core/commands/methods.command.js +0 -90
- package/dist/core/commands/methods.command.js.map +0 -1
- package/dist/core/events/clientReady.d.ts +0 -14
- package/dist/core/events/clientReady.js.map +0 -1
- package/dist/core/events/interactionCreate.d.ts +0 -14
- package/dist/core/events/interactionCreate.js +0 -84
- package/dist/core/events/interactionCreate.js.map +0 -1
- package/dist/core/registry/command.registry.d.ts +0 -6
- package/dist/core/registry/command.registry.js +0 -54
- package/dist/core/registry/command.registry.js.map +0 -1
- package/dist/core/registry/component.registry.d.ts +0 -6
- package/dist/core/registry/component.registry.js +0 -41
- package/dist/core/registry/component.registry.js.map +0 -1
- package/dist/core/registry/event.registry.d.ts +0 -6
- package/dist/core/registry/event.registry.js +0 -71
- package/dist/core/registry/event.registry.js.map +0 -1
- package/dist/core/registry/index.d.ts +0 -22
- package/dist/core/registry/index.js +0 -39
- package/dist/core/registry/index.js.map +0 -1
- package/dist/core/registry/module.registry.d.ts +0 -6
- package/dist/core/registry/module.registry.js +0 -55
- package/dist/core/registry/module.registry.js.map +0 -1
- package/dist/index-DbWA_10I.d.ts +0 -439
- package/dist/shared/typings/client.d.ts +0 -74
- package/dist/shared/typings/client.js +0 -3
- package/dist/shared/typings/commands.d.ts +0 -6
- package/dist/shared/typings/commands.js +0 -3
- package/dist/shared/typings/components.d.ts +0 -6
- package/dist/shared/typings/components.js +0 -10
- package/dist/shared/typings/components.js.map +0 -1
- package/dist/shared/typings/events.d.ts +0 -6
- package/dist/shared/typings/events.js +0 -3
- package/dist/shared/typings/index.d.ts +0 -6
- package/dist/shared/typings/index.js +0 -9
- package/dist/shared/typings/index.js.map +0 -1
- package/dist/shared/typings/module.d.ts +0 -6
- package/dist/shared/typings/module.js +0 -3
- package/dist/shared/typings/permissions.d.ts +0 -16
- package/dist/shared/typings/permissions.js +0 -13
- package/dist/shared/typings/permissions.js.map +0 -1
- package/dist/shared/typings/registry.d.ts +0 -51
- package/dist/shared/typings/registry.js +0 -61
- package/dist/shared/typings/registry.js.map +0 -1
- package/dist/shared/utility/components.utility.d.ts +0 -6
- package/dist/shared/utility/components.utility.js +0 -17
- package/dist/shared/utility/components.utility.js.map +0 -1
- package/dist/shared/utility/functions.d.ts +0 -60
- package/dist/shared/utility/functions.js +0 -81
- package/dist/shared/utility/functions.js.map +0 -1
- package/dist/shared/utility/permissions.utility.d.ts +0 -6
- package/dist/shared/utility/permissions.utility.js +0 -12
- package/dist/shared/utility/permissions.utility.js.map +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { TriviousError } from '../../utility/errors.js';
|
|
2
|
+
import { importFile } from '../../utility/functions.js';
|
|
3
|
+
import { Collection, ApplicationCommandType } from 'discord.js';
|
|
4
|
+
import { existsSync, promises } from 'fs';
|
|
5
|
+
import path, { join } from 'path';
|
|
6
|
+
|
|
7
|
+
function validateCommand(command, expects) {
|
|
8
|
+
if (!("active" in command && "commandType" in command)) return false;
|
|
9
|
+
if (!command.active) return false;
|
|
10
|
+
return expects(command);
|
|
11
|
+
}
|
|
12
|
+
async function parseSlashSubcommands(directory, data) {
|
|
13
|
+
const subcommands = new Collection();
|
|
14
|
+
if (!("addSubcommand" in data.data)) return subcommands;
|
|
15
|
+
const files = promises.glob(join(directory, "./*.js"));
|
|
16
|
+
for await (const file of files) {
|
|
17
|
+
const subcommand = await importFile(file);
|
|
18
|
+
if (!subcommand || !validateCommand(subcommand, (subcmd) => subcmd.context === "SlashSubcommand"))
|
|
19
|
+
continue;
|
|
20
|
+
subcommand.parent = data;
|
|
21
|
+
data.data.addSubcommand(subcommand.data);
|
|
22
|
+
subcommands.set(subcommand.data.name, subcommand);
|
|
23
|
+
}
|
|
24
|
+
if (subcommands.size > 0) data.subcommands = subcommands;
|
|
25
|
+
return subcommands;
|
|
26
|
+
}
|
|
27
|
+
async function parseSlashCommand(file, parentDir, subdirectories) {
|
|
28
|
+
if (!existsSync(file)) return;
|
|
29
|
+
const command = await importFile(file);
|
|
30
|
+
if (!command || !validateCommand(command, (cmd) => cmd.context === "SlashCommand") || !("addSubcommand" in command.data))
|
|
31
|
+
return;
|
|
32
|
+
await parseSlashSubcommands(parentDir, command);
|
|
33
|
+
for (const subdir of subdirectories) {
|
|
34
|
+
const indexFile = path.resolve(subdir.parentPath, subdir.name, "index.js");
|
|
35
|
+
if (!existsSync(indexFile)) continue;
|
|
36
|
+
const group = await importFile(indexFile);
|
|
37
|
+
if (!group || !("context" in group) || group.context !== "SlashSubcommandGroup") continue;
|
|
38
|
+
group.parent = command;
|
|
39
|
+
if (!command.subcommandGroups) command.subcommandGroups = new Collection();
|
|
40
|
+
await parseSlashSubcommands(join(subdir.parentPath, subdir.name), group);
|
|
41
|
+
if (group.subcommands.size > 0) {
|
|
42
|
+
command.data.addSubcommandGroup(group.data);
|
|
43
|
+
command.subcommandGroups.set(group.data.name, group);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return command;
|
|
47
|
+
}
|
|
48
|
+
async function parseContextCommands(parentDir) {
|
|
49
|
+
const collection = new Collection();
|
|
50
|
+
const files = promises.glob(join(parentDir, "**/*.js"));
|
|
51
|
+
for await (const file of files) {
|
|
52
|
+
const contextCommand = await importFile(file);
|
|
53
|
+
if (!contextCommand || !validateCommand(
|
|
54
|
+
contextCommand,
|
|
55
|
+
(cmd) => cmd.commandType === ApplicationCommandType.Message || cmd.commandType === ApplicationCommandType.User
|
|
56
|
+
))
|
|
57
|
+
continue;
|
|
58
|
+
contextCommand.data.setType(contextCommand.commandType);
|
|
59
|
+
collection.set(contextCommand.data.name, contextCommand);
|
|
60
|
+
}
|
|
61
|
+
return collection;
|
|
62
|
+
}
|
|
63
|
+
async function registerDirectory(client, parentDir) {
|
|
64
|
+
const entries = await promises.readdir(parentDir, { withFileTypes: true });
|
|
65
|
+
const subdirectories = entries.filter((entry) => entry.isDirectory());
|
|
66
|
+
const indexFile = path.resolve(parentDir, "index.js");
|
|
67
|
+
const slashCommand = await parseSlashCommand(indexFile, parentDir, subdirectories);
|
|
68
|
+
if (slashCommand) client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);
|
|
69
|
+
const contextCommands = await parseContextCommands(parentDir);
|
|
70
|
+
contextCommands.forEach((cmd) => client.stores.commands.context.set(cmd.data.name, cmd));
|
|
71
|
+
}
|
|
72
|
+
async function registerCommands(client, directory) {
|
|
73
|
+
if (!existsSync(directory))
|
|
74
|
+
throw new TriviousError(
|
|
75
|
+
`Could not register commands; passed directory '${directory}' does not exist!`,
|
|
76
|
+
"Nonexistant directory passed"
|
|
77
|
+
);
|
|
78
|
+
const processedDirectories = /* @__PURE__ */ new Set();
|
|
79
|
+
const files = promises.glob(join(directory, "**/*.js"));
|
|
80
|
+
for await (const file of files) {
|
|
81
|
+
const parentDir = path.dirname(file);
|
|
82
|
+
if (processedDirectories.has(parentDir)) continue;
|
|
83
|
+
processedDirectories.add(parentDir);
|
|
84
|
+
await registerDirectory(client, parentDir);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { registerCommands as default };
|
|
89
|
+
//# sourceMappingURL=registry.commands.js.map
|
|
90
|
+
//# sourceMappingURL=registry.commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/commands/registry.commands.ts"],"names":["fs"],"mappings":";;;;;;AAgBA,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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qB,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 type {\n\tBaseChatInputCommandData,\n\tBaseContextCommandData,\n\tMessageCommandData,\n\tSlashCommandData,\n\tSlashSubcommandData,\n\tSlashSubcommandGroupData,\n\tTriviousClient,\n\tUserCommandData,\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 | BaseContextCommandData>(\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<true, typeof _parentType>>();\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<true, typeof _parentType>>(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\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 (!group || !(\"context\" in group) || group.context !== \"SlashSubcommandGroup\") continue;\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\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, MessageCommandData | UserCommandData>();\n\tconst files = fs.glob(join(parentDir, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst contextCommand = await importFile<MessageCommandData | UserCommandData>(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) client.stores.commands.chatInput.set(slashCommand.data.name, slashCommand);\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"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var ComponentContext = /* @__PURE__ */ ((ComponentContext2) => {
|
|
2
|
+
ComponentContext2[ComponentContext2["Button"] = 0] = "Button";
|
|
3
|
+
ComponentContext2[ComponentContext2["SelectMenu"] = 1] = "SelectMenu";
|
|
4
|
+
ComponentContext2[ComponentContext2["Modal"] = 2] = "Modal";
|
|
5
|
+
return ComponentContext2;
|
|
6
|
+
})(ComponentContext || {});
|
|
7
|
+
|
|
8
|
+
export { ComponentContext };
|
|
9
|
+
//# sourceMappingURL=components.types.js.map
|
|
10
|
+
//# sourceMappingURL=components.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/components/components.types.ts"],"names":["ComponentContext"],"mappings":"AAaO,IAAK,gBAAA,qBAAAA,iBAAAA,KAAL;AACN,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAA;AACA,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA;AACA,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAA;AAHW,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA","file":"components.types.js","sourcesContent":["import type {\n\tAnySelectMenuInteraction,\n\tButtonInteraction,\n\tModalSubmitInteraction,\n} from \"discord.js\";\nimport type { TriviousClient } from \"#typings\";\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\n/**\n * Trivious component\n * @param component The component type\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 {\n\tcomponent: ComponentContext;\n\tidentifier: string;\n\tflags?: ComponentFlags[];\n\texecute: (client: TriviousClient, interaction: ComponentInteraction) => Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { T as TriviousClient } from '../../modules.types-4hfuUiCb.js';
|
|
2
|
+
import 'discord.js';
|
|
3
|
+
import '../client/client.types.js';
|
|
4
|
+
|
|
5
|
+
declare function registerComponents(client: TriviousClient, directory: string): Promise<void>;
|
|
6
|
+
|
|
7
|
+
export { registerComponents as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { existsSync, promises } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { TriviousError } from '../../utility/errors.js';
|
|
4
|
+
import { importFile } from '../../utility/functions.js';
|
|
5
|
+
|
|
6
|
+
async function registerComponents(client, directory) {
|
|
7
|
+
if (!existsSync(directory))
|
|
8
|
+
throw new TriviousError(
|
|
9
|
+
`Could not register components; passed directory '${directory} does not exist!'`,
|
|
10
|
+
"Nonexistant directory passed"
|
|
11
|
+
);
|
|
12
|
+
const files = promises.glob(join(directory, "**/*.js"));
|
|
13
|
+
for await (const file of files) {
|
|
14
|
+
const component = await importFile(file);
|
|
15
|
+
if (!component || !("component" in component && "identifier" in component && "execute" in component))
|
|
16
|
+
continue;
|
|
17
|
+
client.stores.components.set(component.identifier, component);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { registerComponents as default };
|
|
22
|
+
//# sourceMappingURL=registry.components.js.map
|
|
23
|
+
//# sourceMappingURL=registry.components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/components/registry.components.ts"],"names":["fs"],"mappings":";;;;;AAMA,eAAO,kBAAA,CAA0C,QAAwB,SAAA,EAAmB;AAC3F,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,oDAAoD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC7D;AAAA,KACD;AAED,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,MAAM,UAAA,CAAsB,IAAI,CAAA;AAClD,IAAA,IACC,CAAC,SAAA,IACD,EAAE,eAAe,SAAA,IAAa,YAAA,IAAgB,aAAa,SAAA,IAAa,SAAA,CAAA;AAExE,MAAA;AAED,IAAA,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,SAAA,CAAU,YAAY,SAAS,CAAA;AAAA,EAC7D;AACD","file":"registry.components.js","sourcesContent":["import { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\nimport type { Component, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\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\tclient.stores.components.set(component.identifier, component);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '../client/client.types.js';
|
|
2
|
+
import { f as ComponentContext } from '../../modules.types-4hfuUiCb.js';
|
|
3
|
+
import 'discord.js';
|
|
4
|
+
|
|
5
|
+
type ComponentTag = "awaited";
|
|
6
|
+
interface ComponentCustomId {
|
|
7
|
+
identifier: string;
|
|
8
|
+
context: ComponentContext;
|
|
9
|
+
data?: string;
|
|
10
|
+
tags?: ComponentTag[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type { ComponentCustomId, ComponentTag };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"customid.types.js"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentCustomId } from './customid.types.js';
|
|
2
|
+
import '../client/client.types.js';
|
|
3
|
+
import 'discord.js';
|
|
4
|
+
import '../../modules.types-4hfuUiCb.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Decode a customId into its parts
|
|
8
|
+
* @param customId The custom id
|
|
9
|
+
* @returns Decoded customId
|
|
10
|
+
*/
|
|
11
|
+
declare const decodeCustomId: (customId: string) => ComponentCustomId;
|
|
12
|
+
/**
|
|
13
|
+
* Encode a customId
|
|
14
|
+
* @param options Custom id parts
|
|
15
|
+
* @returns Encoded customId
|
|
16
|
+
* @throws {TriviousError} If encoded length exceeds 100 characters
|
|
17
|
+
*/
|
|
18
|
+
declare const encodeCustomId: (options: ComponentCustomId) => string;
|
|
19
|
+
|
|
20
|
+
export { decodeCustomId, encodeCustomId };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TriviousError } from '../../utility/errors.js';
|
|
2
|
+
|
|
3
|
+
const decodeCustomId = (customId) => {
|
|
4
|
+
const [context, identifier, info] = customId.split(":");
|
|
5
|
+
const [data, ...tags] = info?.split(".");
|
|
6
|
+
return {
|
|
7
|
+
context,
|
|
8
|
+
identifier,
|
|
9
|
+
data,
|
|
10
|
+
tags
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const encodeCustomId = (options) => {
|
|
14
|
+
const { context, identifier, data, tags } = options;
|
|
15
|
+
let customId = `${context}:${identifier}`;
|
|
16
|
+
if (data) customId += `:${data}`;
|
|
17
|
+
if (tags) customId += `.${tags.join(".")}`;
|
|
18
|
+
if (customId.length > 100) throw new TriviousError("Encoded customId exceeds 100 characters.");
|
|
19
|
+
return customId;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { decodeCustomId, encodeCustomId };
|
|
23
|
+
//# sourceMappingURL=methods.customid.js.map
|
|
24
|
+
//# sourceMappingURL=methods.customid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/customId/methods.customid.ts"],"names":[],"mappings":";;AAQO,MAAM,cAAA,GAAiB,CAAC,QAAA,KAAqB;AACnD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAA,EAAY,IAAI,CAAA,GAAI,QAAA,CAAS,MAAM,GAAG,CAAA;AAKtD,EAAA,MAAM,CAAC,IAAA,EAAM,GAAG,IAAI,CAAA,GAAI,IAAA,EAAM,MAAM,GAAG,CAAA;AAEvC,EAAA,OAAO;AAAA,IACN,OAAA;AAAA,IACA,UAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACD;AACD;AAQO,MAAM,cAAA,GAAiB,CAAC,OAAA,KAA+B;AAC7D,EAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAY,IAAA,EAAM,MAAK,GAAI,OAAA;AAC5C,EAAA,IAAI,QAAA,GAAW,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,UAAU,CAAA,CAAA;AAEvC,EAAA,IAAI,IAAA,EAAM,QAAA,IAAY,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAC9B,EAAA,IAAI,MAAM,QAAA,IAAY,CAAA,CAAA,EAAI,IAAA,CAAK,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAExC,EAAA,IAAI,SAAS,MAAA,GAAS,GAAA,EAAK,MAAM,IAAI,cAAc,0CAA0C,CAAA;AAC7F,EAAA,OAAO,QAAA;AACR","file":"methods.customid.js","sourcesContent":["import type { ComponentContext, ComponentCustomId, ComponentTag } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\n\n/**\n * Decode a customId into its parts\n * @param customId The custom id\n * @returns Decoded customId\n */\nexport const decodeCustomId = (customId: string) => {\n\tconst [context, identifier, info] = customId.split(\":\") as [\n\t\tComponentContext,\n\t\tstring,\n\t\tstring | undefined,\n\t];\n\tconst [data, ...tags] = info?.split(\".\") as [string | undefined, ...ComponentTag[]];\n\n\treturn {\n\t\tcontext,\n\t\tidentifier,\n\t\tdata,\n\t\ttags,\n\t} as ComponentCustomId;\n};\n\n/**\n * Encode a customId\n * @param options Custom id parts\n * @returns Encoded customId\n * @throws {TriviousError} If encoded length exceeds 100 characters\n */\nexport const encodeCustomId = (options: ComponentCustomId) => {\n\tconst { context, identifier, data, tags } = options;\n\tlet customId = `${context}:${identifier}`;\n\n\tif (data) customId += `:${data}`;\n\tif (tags) customId += `.${tags.join(\".\")}`;\n\n\tif (customId.length > 100) throw new TriviousError(\"Encoded customId exceeds 100 characters.\");\n\treturn customId;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"events.js"}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"events.types.js"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { T as TriviousClient } from '../../../modules.types-4hfuUiCb.js';
|
|
2
|
+
import 'discord.js';
|
|
3
|
+
import '../../client/client.types.js';
|
|
4
|
+
|
|
5
|
+
declare const _default: {
|
|
6
|
+
name: "clientReady";
|
|
7
|
+
once: true;
|
|
8
|
+
execute(client: TriviousClient): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { _default as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/events/presets/clientReady.ts"],"names":[],"mappings":"AAEA,IAAO,mBAAA,GAAQ;AAAA,EACd,IAAA,EAAM,aAAA;AAAA,EACN,IAAA,EAAM,IAAA;AAAA,EACN,MAAM,QAAQ,MAAA,EAAQ;AACrB,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,yBAAA,EAA4B,MAAA,CAAO,IAAA,EAAM,QAAQ,CAAA,CAAE,CAAA;AAAA,EAChE;AACD","file":"clientReady.js","sourcesContent":["import type { 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"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as discord_js from 'discord.js';
|
|
2
|
+
import { T as TriviousClient } from '../../../modules.types-4hfuUiCb.js';
|
|
3
|
+
import '../../client/client.types.js';
|
|
4
|
+
|
|
5
|
+
declare const _default: {
|
|
6
|
+
name: "interactionCreate";
|
|
7
|
+
execute(client: TriviousClient, interaction: discord_js.Interaction<discord_js.CacheType>): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { _default as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ApplicationCommandType, ButtonInteraction, ModalSubmitInteraction } from 'discord.js';
|
|
2
|
+
import { interactionReply, handleSlashCommand } from '../../../features/commands/methods.commands.js';
|
|
3
|
+
import { decodeCustomId } from '../../../features/customId/methods.customid.js';
|
|
4
|
+
import { ComponentContext } from '../../../shared/typings.js';
|
|
5
|
+
|
|
6
|
+
var interactionCreate_default = {
|
|
7
|
+
name: "interactionCreate",
|
|
8
|
+
async execute(client, interaction) {
|
|
9
|
+
if (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {
|
|
10
|
+
const { commandName } = interaction;
|
|
11
|
+
const storeToCheck = interaction.isChatInputCommand() ? client.stores.commands.chatInput : client.stores.commands.context;
|
|
12
|
+
const command = storeToCheck.get(commandName);
|
|
13
|
+
if (!command) {
|
|
14
|
+
await interactionReply({
|
|
15
|
+
interaction,
|
|
16
|
+
replyPayload: { content: "Command is outdated, inactive, or does not have a handler!" },
|
|
17
|
+
flags: ["EphemeralReply"]
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (command.commandType === ApplicationCommandType.ChatInput && interaction.isChatInputCommand()) {
|
|
22
|
+
await handleSlashCommand(client, command, interaction);
|
|
23
|
+
} else {
|
|
24
|
+
await command.execute(client, interaction);
|
|
25
|
+
}
|
|
26
|
+
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
27
|
+
const { context, identifier, tags } = decodeCustomId(interaction.customId);
|
|
28
|
+
if (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))
|
|
29
|
+
return;
|
|
30
|
+
if (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))
|
|
31
|
+
return;
|
|
32
|
+
if (tags && tags.includes("awaited")) return;
|
|
33
|
+
const component = client.stores.components.get(identifier);
|
|
34
|
+
if (!component) {
|
|
35
|
+
await interactionReply({
|
|
36
|
+
interaction,
|
|
37
|
+
replyPayload: { content: "Command is outdated, inactive, or does not have a handler!" },
|
|
38
|
+
flags: ["EphemeralReply"]
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
await component.execute(client, interaction);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { interactionCreate_default as default };
|
|
48
|
+
//# sourceMappingURL=interactionCreate.js.map
|
|
49
|
+
//# sourceMappingURL=interactionCreate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"names":[],"mappings":";;;;;AAKA,IAAO,yBAAA,GAAQ;AAAA,EACd,IAAA,EAAM,mBAAA;AAAA,EACN,MAAM,OAAA,CAAQ,MAAA,EAAQ,WAAA,EAAa;AAClC,IAAA,IAAI,WAAA,CAAY,kBAAA,EAAmB,IAAK,WAAA,CAAY,sBAAqB,EAAG;AAC3E,MAAA,MAAM,EAAE,aAAY,GAAI,WAAA;AAExB,MAAA,MAAM,YAAA,GAAe,WAAA,CAAY,kBAAA,EAAmB,GACjD,MAAA,CAAO,OAAO,QAAA,CAAS,SAAA,GACvB,MAAA,CAAO,MAAA,CAAO,QAAA,CAAS,OAAA;AAC1B,MAAA,MAAM,OAAA,GAAU,YAAA,CAAa,GAAA,CAAI,WAAW,CAAA;AAE5C,MAAA,IAAI,CAAC,OAAA,EAAS;AACb,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,4DAAA,EAA6D;AAAA,UACtF,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,IACC,QAAQ,WAAA,KAAgB,sBAAA,CAAuB,SAAA,IAC/C,WAAA,CAAY,oBAAmB,EAC9B;AACD,QAAA,MAAM,kBAAA,CAAmB,MAAA,EAAQ,OAAA,EAAS,WAAW,CAAA;AAAA,MACtD,CAAA,MAAO;AACN,QAAA,MAAO,OAAA,CAA+B,OAAA,CAAQ,MAAA,EAAQ,WAAoB,CAAA;AAAA,MAC3E;AAAA,IACD,WAAW,WAAA,CAAY,kBAAA,EAAmB,IAAK,WAAA,CAAY,eAAc,EAAG;AAC3E,MAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAY,MAAK,GAAI,cAAA,CAAe,YAAY,QAAQ,CAAA;AAEzE,MAAA,IAAI,OAAA,KAAY,gBAAA,CAAiB,MAAA,IAAU,EAAE,WAAA,YAAuB,iBAAA,CAAA;AACnE,QAAA;AACD,MAAA,IAAI,OAAA,KAAY,gBAAA,CAAiB,KAAA,IAAS,EAAE,WAAA,YAAuB,sBAAA,CAAA;AAClE,QAAA;AACD,MAAA,IAAI,IAAA,IAAQ,IAAA,CAAK,QAAA,CAAS,SAAS,CAAA,EAAG;AAEtC,MAAA,MAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,IAAI,UAAU,CAAA;AAEzD,MAAA,IAAI,CAAC,SAAA,EAAW;AACf,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,4DAAA,EAA6D;AAAA,UACtF,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,SAAA,CAAU,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,IAC5C;AAAA,EACD;AACD","file":"interactionCreate.js","sourcesContent":["import { ApplicationCommandType, ButtonInteraction, ModalSubmitInteraction } from \"discord.js\";\nimport { handleSlashCommand, interactionReply } from \"src/features/commands/methods.commands.js\";\nimport { decodeCustomId } from \"src/features/customId/methods.customid.js\";\nimport { ComponentContext, type ContextCommandData, type Event } from \"#typings\";\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\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 } = decodeCustomId(interaction.customId);\n\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\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { T as TriviousClient } from '../../modules.types-4hfuUiCb.js';
|
|
2
|
+
import 'discord.js';
|
|
3
|
+
import '../client/client.types.js';
|
|
4
|
+
|
|
5
|
+
declare function bindEvents(client: TriviousClient): Promise<void>;
|
|
6
|
+
declare function registerEvents(client: TriviousClient, directory: string): Promise<void>;
|
|
7
|
+
|
|
8
|
+
export { bindEvents, registerEvents as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { existsSync, promises } from 'fs';
|
|
2
|
+
import path, { join } from 'path';
|
|
3
|
+
import { TriviousError } from '../../utility/errors.js';
|
|
4
|
+
import { importFile } from '../../utility/functions.js';
|
|
5
|
+
|
|
6
|
+
async function loadPresetEvents(client) {
|
|
7
|
+
const directory = path.resolve(import.meta.dirname, "presets");
|
|
8
|
+
if (!existsSync(directory)) return;
|
|
9
|
+
const files = promises.glob(join(directory, "./*.js"));
|
|
10
|
+
for await (const file of files) {
|
|
11
|
+
const event = await parseEvent(file);
|
|
12
|
+
if (!event) continue;
|
|
13
|
+
client.stores.events.set(event.name, event);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function parseEvent(file) {
|
|
17
|
+
const event = await importFile(file);
|
|
18
|
+
if (!event || !("name" in event && "execute" in event)) return null;
|
|
19
|
+
return event;
|
|
20
|
+
}
|
|
21
|
+
async function bindEvents(client) {
|
|
22
|
+
for (const event of client.stores.events.values()) {
|
|
23
|
+
const handler = (...args) => void event.execute(client, ...args);
|
|
24
|
+
if (event.once) client.once(event.name, handler);
|
|
25
|
+
else client.on(event.name, handler);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function registerEvents(client, directory) {
|
|
29
|
+
if (!existsSync(directory))
|
|
30
|
+
throw new TriviousError(
|
|
31
|
+
`Could not register events; passed directory '${directory}' does not exist!`,
|
|
32
|
+
"Nonexistant directory passed"
|
|
33
|
+
);
|
|
34
|
+
await loadPresetEvents(client);
|
|
35
|
+
const files = promises.glob(join(directory, "**/*.js"));
|
|
36
|
+
for await (const file of files) {
|
|
37
|
+
const event = await parseEvent(file);
|
|
38
|
+
if (!event) continue;
|
|
39
|
+
client.stores.events.set(event.name, event);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { bindEvents, registerEvents as default };
|
|
44
|
+
//# sourceMappingURL=registry.events.js.map
|
|
45
|
+
//# sourceMappingURL=registry.events.js.map
|
|
@@ -0,0 +1 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,eAAO,cAAA,CAAsC,QAAwB,SAAA,EAAmB;AACvF,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,gDAAgD,SAAS,CAAA,iBAAA,CAAA;AAAA,MACzD;AAAA,KACD;AAED,EAAA,MAAM,iBAAiB,MAAM,CAAA;AAE7B,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,KAAA,GAAQ,MAAM,UAAA,CAAW,IAAI,CAAA;AACnC,IAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,IAAA,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,EAC3C;AACD","file":"registry.events.js","sourcesContent":["import { existsSync, promises as fs } from \"fs\";\nimport path, { join } from \"path\";\nimport type { ClientEvents } from \"discord.js\";\nimport type { Event, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\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\tclient.stores.events.set(event.name, event);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"modules.types.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { T as TriviousClient } from '../../modules.types-4hfuUiCb.js';
|
|
2
|
+
import 'discord.js';
|
|
3
|
+
import '../client/client.types.js';
|
|
4
|
+
|
|
5
|
+
declare function bindModules(client: TriviousClient): Promise<void>;
|
|
6
|
+
declare function registerModules(client: TriviousClient, directory: string): Promise<void>;
|
|
7
|
+
|
|
8
|
+
export { bindModules, registerModules as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { existsSync, promises } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { TriviousError } from '../../utility/errors.js';
|
|
4
|
+
import { importFile } from '../../utility/functions.js';
|
|
5
|
+
|
|
6
|
+
async function bindModules(client) {
|
|
7
|
+
for (const moduleData of client.stores.modules.values()) {
|
|
8
|
+
for (const [name, handler] of Object.entries(moduleData.events)) {
|
|
9
|
+
const listener = (...args) => void handler(client, ...args);
|
|
10
|
+
client.on(name, listener);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function registerModules(client, directory) {
|
|
15
|
+
if (!existsSync(directory))
|
|
16
|
+
throw new TriviousError(
|
|
17
|
+
`Could not register modules; passed directory '${directory}' does not exist!`,
|
|
18
|
+
"Nonexistant directory passed"
|
|
19
|
+
);
|
|
20
|
+
const files = promises.glob(join(directory, "**/*.js"));
|
|
21
|
+
for await (const file of files) {
|
|
22
|
+
const moduleData = await importFile(file);
|
|
23
|
+
if (!moduleData || !("name" in moduleData && "events" in moduleData)) continue;
|
|
24
|
+
client.stores.modules.set(moduleData.name, moduleData);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { bindModules, registerModules as default };
|
|
29
|
+
//# sourceMappingURL=registry.modules.js.map
|
|
30
|
+
//# sourceMappingURL=registry.modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/modules/registry.modules.ts"],"names":["fs"],"mappings":";;;;;AAMA,eAAsB,YAAY,MAAA,EAAwB;AACzD,EAAA,KAAA,MAAW,UAAA,IAAc,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,QAAO,EAAG;AACxD,IAAA,KAAA,MAAW,CAAC,MAAM,OAAO,CAAA,IAAK,OAAO,OAAA,CAAQ,UAAA,CAAW,MAAM,CAAA,EAAG;AAChE,MAAA,MAAM,WAAW,CAAA,GAAI,IAAA,KACpB,KAAM,OAAA,CAAgE,MAAA,EAAQ,GAAG,IAAI,CAAA;AAEtF,MAAA,MAAA,CAAO,EAAA,CAAG,MAAM,QAAQ,CAAA;AAAA,IACzB;AAAA,EACD;AACD;AAEA,eAAO,eAAA,CAAuC,QAAwB,SAAA,EAAmB;AACxF,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,iDAAiD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC1D;AAAA,KACD;AAED,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,UAAA,GAAa,MAAM,UAAA,CAAmB,IAAI,CAAA;AAChD,IAAA,IAAI,CAAC,UAAA,IAAc,EAAE,MAAA,IAAU,UAAA,IAAc,YAAY,UAAA,CAAA,EAAa;AAEtE,IAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAW,MAAM,UAAU,CAAA;AAAA,EACtD;AACD","file":"registry.modules.js","sourcesContent":["import { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\nimport { Module, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\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\tclient.stores.modules.set(moduleData.name, moduleData);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Collection } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
type ClientStores = "commands" | "components" | "events" | "modules";
|
|
4
|
+
declare const structure: {
|
|
5
|
+
getPackageRoot(): string;
|
|
6
|
+
resolveRelativePath(relativePath: string): string;
|
|
7
|
+
resolveTypeBasedStructure(corePath: string): Collection<ClientStores, string>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { structure as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { dirname, join, resolve } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { Collection } from 'discord.js';
|
|
5
|
+
|
|
6
|
+
const __filename$1 = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname$1 = dirname(__filename$1);
|
|
8
|
+
const structure = {
|
|
9
|
+
getPackageRoot() {
|
|
10
|
+
let dir = __dirname$1;
|
|
11
|
+
while (dir !== dirname(dir)) {
|
|
12
|
+
if (existsSync(join(dir, "package.json")) || existsSync(join(dir, "node_modules"))) {
|
|
13
|
+
return dir;
|
|
14
|
+
}
|
|
15
|
+
dir = dirname(dir);
|
|
16
|
+
}
|
|
17
|
+
return __dirname$1;
|
|
18
|
+
},
|
|
19
|
+
resolveRelativePath(relativePath) {
|
|
20
|
+
const workingDir = process.cwd();
|
|
21
|
+
const packageRoot = this.getPackageRoot();
|
|
22
|
+
const candidates = [
|
|
23
|
+
join(workingDir, "lib", relativePath),
|
|
24
|
+
join(workingDir, "dist", relativePath),
|
|
25
|
+
join(packageRoot, "lib", relativePath),
|
|
26
|
+
join(packageRoot, "dist", relativePath),
|
|
27
|
+
join(packageRoot, relativePath),
|
|
28
|
+
join(workingDir, relativePath)
|
|
29
|
+
];
|
|
30
|
+
for (const candidate of candidates) {
|
|
31
|
+
const full = resolve(candidate);
|
|
32
|
+
if (existsSync(full)) return full;
|
|
33
|
+
}
|
|
34
|
+
return join(workingDir, relativePath);
|
|
35
|
+
},
|
|
36
|
+
resolveTypeBasedStructure(corePath) {
|
|
37
|
+
const resolved = new Collection();
|
|
38
|
+
const directoriesToCheck = ["commands", "components", "events", "modules"];
|
|
39
|
+
for (const dir of directoriesToCheck) {
|
|
40
|
+
const fullPath = structure.resolveRelativePath(join(corePath, dir));
|
|
41
|
+
if (!existsSync(fullPath)) continue;
|
|
42
|
+
resolved.set(dir, fullPath);
|
|
43
|
+
}
|
|
44
|
+
return resolved;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var index_structure_default = structure;
|
|
48
|
+
|
|
49
|
+
export { index_structure_default as default };
|
|
50
|
+
//# sourceMappingURL=index.structure.js.map
|
|
51
|
+
//# sourceMappingURL=index.structure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/structure/index.structure.ts"],"names":["__filename","__dirname"],"mappings":";;;;;AAOA,MAAMA,YAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAChD,MAAMC,WAAA,GAAY,QAAQD,YAAU,CAAA;AAEpC,MAAM,SAAA,GAAY;AAAA,EACjB,cAAA,GAAiB;AAChB,IAAA,IAAI,GAAA,GAAMC,WAAA;AAEV,IAAA,OAAO,GAAA,KAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG;AAC5B,MAAA,IAAI,UAAA,CAAW,IAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,IAAK,UAAA,CAAW,IAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,EAAG;AACnF,QAAA,OAAO,GAAA;AAAA,MACR;AAEA,MAAA,GAAA,GAAM,QAAQ,GAAG,CAAA;AAAA,IAClB;AAEA,IAAA,OAAOA,WAAA;AAAA,EACR,CAAA;AAAA,EAEA,oBAAoB,YAAA,EAAsB;AACzC,IAAA,MAAM,UAAA,GAAa,QAAQ,GAAA,EAAI;AAC/B,IAAA,MAAM,WAAA,GAAc,KAAK,cAAA,EAAe;AAExC,IAAA,MAAM,UAAA,GAAa;AAAA,MAClB,IAAA,CAAK,UAAA,EAAY,KAAA,EAAO,YAAY,CAAA;AAAA,MACpC,IAAA,CAAK,UAAA,EAAY,MAAA,EAAQ,YAAY,CAAA;AAAA,MACrC,IAAA,CAAK,WAAA,EAAa,KAAA,EAAO,YAAY,CAAA;AAAA,MACrC,IAAA,CAAK,WAAA,EAAa,MAAA,EAAQ,YAAY,CAAA;AAAA,MAEtC,IAAA,CAAK,aAAa,YAAY,CAAA;AAAA,MAC9B,IAAA,CAAK,YAAY,YAAY;AAAA,KAC9B;AAEA,IAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AACnC,MAAA,MAAM,IAAA,GAAO,QAAQ,SAAS,CAAA;AAC9B,MAAA,IAAI,UAAA,CAAW,IAAI,CAAA,EAAG,OAAO,IAAA;AAAA,IAC9B;AAEA,IAAA,OAAO,IAAA,CAAK,YAAY,YAAY,CAAA;AAAA,EACrC,CAAA;AAAA,EAEA,0BAA0B,QAAA,EAAkB;AAC3C,IAAA,MAAM,QAAA,GAAW,IAAI,UAAA,EAAiC;AACtD,IAAA,MAAM,kBAAA,GAAqC,CAAC,UAAA,EAAY,YAAA,EAAc,UAAU,SAAS,CAAA;AAEzF,IAAA,KAAA,MAAW,OAAO,kBAAA,EAAoB;AACrC,MAAA,MAAM,WAAW,SAAA,CAAU,mBAAA,CAAoB,IAAA,CAAK,QAAA,EAAU,GAAG,CAAC,CAAA;AAClE,MAAA,IAAI,CAAC,UAAA,CAAW,QAAQ,CAAA,EAAG;AAC3B,MAAA,QAAA,CAAS,GAAA,CAAI,KAAK,QAAQ,CAAA;AAAA,IAC3B;AAEA,IAAA,OAAO,QAAA;AAAA,EACR;AACD,CAAA;AAEA,IAAO,uBAAA,GAAQ","file":"index.structure.js","sourcesContent":["import { existsSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { Collection } from \"discord.js\";\n\ntype ClientStores = \"commands\" | \"components\" | \"events\" | \"modules\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst structure = {\n\tgetPackageRoot() {\n\t\tlet dir = __dirname;\n\n\t\twhile (dir !== dirname(dir)) {\n\t\t\tif (existsSync(join(dir, \"package.json\")) || existsSync(join(dir, \"node_modules\"))) {\n\t\t\t\treturn dir;\n\t\t\t}\n\n\t\t\tdir = dirname(dir);\n\t\t}\n\n\t\treturn __dirname;\n\t},\n\n\tresolveRelativePath(relativePath: string) {\n\t\tconst workingDir = process.cwd();\n\t\tconst packageRoot = this.getPackageRoot();\n\n\t\tconst candidates = [\n\t\t\tjoin(workingDir, \"lib\", relativePath),\n\t\t\tjoin(workingDir, \"dist\", relativePath),\n\t\t\tjoin(packageRoot, \"lib\", relativePath),\n\t\t\tjoin(packageRoot, \"dist\", relativePath),\n\n\t\t\tjoin(packageRoot, relativePath),\n\t\t\tjoin(workingDir, relativePath),\n\t\t];\n\n\t\tfor (const candidate of candidates) {\n\t\t\tconst full = resolve(candidate);\n\t\t\tif (existsSync(full)) return full;\n\t\t}\n\n\t\treturn join(workingDir, relativePath);\n\t},\n\n\tresolveTypeBasedStructure(corePath: string) {\n\t\tconst resolved = new Collection<ClientStores, string>();\n\t\tconst directoriesToCheck: ClientStores[] = [\"commands\", \"components\", \"events\", \"modules\"];\n\n\t\tfor (const dir of directoriesToCheck) {\n\t\t\tconst fullPath = structure.resolveRelativePath(join(corePath, dir));\n\t\t\tif (!existsSync(fullPath)) continue;\n\t\t\tresolved.set(dir, fullPath);\n\t\t}\n\n\t\treturn resolved;\n\t},\n};\n\nexport default structure;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { createActionRow, createEmbed } from './features/builders/utility.builders.js';
|
|
2
|
+
export { handleSlashCommand, interactionReply } from './features/commands/methods.commands.js';
|
|
3
|
+
export { decodeCustomId, encodeCustomId } from './features/customId/methods.customid.js';
|
|
4
|
+
export { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure } from './features/client/client.types.js';
|
|
5
|
+
export { B as BaseChatInputCommandData, a as BaseCommandData, b as BaseContextCommandData, C as ChatInputCommandContext, c as ChatInputCommandFunction, d as CommandFlags, e as Component, f as ComponentContext, g as ComponentFlags, h as ComponentInteraction, i as ContextCommandData, j as ContextMenuCommandFunction, E as Event, M as MessageCommandData, k as Module, S as SlashCommandData, l as SlashSubcommandData, m as SlashSubcommandGroupData, T as TriviousClient, U as UserCommandData } from './modules.types-4hfuUiCb.js';
|
|
6
|
+
export { ComponentCustomId, ComponentTag } from './features/customId/customid.types.js';
|
|
1
7
|
import 'discord.js';
|
|
2
|
-
export { B as ButtonInteraction, t as ChatInputCommandInteraction, g as Command, l as CommandContext, k as CommandFlags, j as CommandInteraction, C as CommandRegistry, b as Component, c as ComponentCustomIdTag, d as ComponentInteraction, a as ComponentRegistry, e as ComponentType, i as ContextMenuCommand, x as ContextMenuCommandInteraction, f as CustomIdConstructOptions, m as Event, w as ModalSubmitInteraction, n as Module, S as SlashCommand, h as SlashSubcommand, u as StringSelectMenuInteraction, T as TriviousClient, r as constructCustomId, q as deconstructCustomId, s as getPermissionLevel, p as handleSlashCommand, o as interactionReply, v as verifyGuildPermission } from './index-DbWA_10I.js';
|
|
3
|
-
export { createActionRow, createEmbed } from './core/builders/util.builders.js';
|
|
4
|
-
export { PermissionLevel } from './shared/typings/permissions.js';
|
|
5
|
-
export { BaseRegistry } from './shared/typings/registry.js';
|
|
6
|
-
export { TriviousClientOptions } from './shared/typings/client.js';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './core/commands/methods.command.js';
|
|
6
|
-
export { default as ComponentRegistry } from './core/registry/component.registry.js';
|
|
7
|
-
export * from './core/builders/util.builders.js';
|
|
8
|
-
export * from './shared/utility/components.utility.js';
|
|
9
|
-
export * from './shared/utility/permissions.utility.js';
|
|
10
|
-
export * from './shared/typings/index.js';
|
|
1
|
+
export * from './features/builders/utility.builders.js';
|
|
2
|
+
export * from './features/commands/methods.commands.js';
|
|
3
|
+
export * from './features/customId/methods.customid.js';
|
|
4
|
+
export * from './shared/typings.js';
|
|
11
5
|
//# sourceMappingURL=index.js.map
|
|
12
6
|
//# sourceMappingURL=index.js.map
|