trivious 1.3.25 → 1.4.0
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/core/client/trivious.client.cjs +20 -2
- package/dist/core/client/trivious.client.cjs.map +1 -1
- package/dist/core/client/trivious.client.d.cts +1 -1
- package/dist/core/client/trivious.client.d.ts +1 -1
- package/dist/core/client/trivious.client.js +16 -2
- package/dist/core/client/trivious.client.js.map +1 -1
- package/dist/core/commands/command.base.d.cts +1 -1
- package/dist/core/commands/command.base.d.ts +1 -1
- package/dist/core/commands/subcommand.base.d.cts +1 -1
- package/dist/core/commands/subcommand.base.d.ts +1 -1
- package/dist/core/components/component.base.d.cts +1 -1
- package/dist/core/components/component.base.d.ts +1 -1
- package/dist/core/events/clientReady.d.cts +1 -1
- package/dist/core/events/clientReady.d.ts +1 -1
- package/dist/core/events/interactionCreate.d.cts +1 -1
- package/dist/core/events/interactionCreate.d.ts +1 -1
- package/dist/core/registry/command.registry.cjs +10 -6
- package/dist/core/registry/command.registry.cjs.map +1 -1
- package/dist/core/registry/command.registry.d.cts +1 -1
- package/dist/core/registry/command.registry.d.ts +1 -1
- package/dist/core/registry/command.registry.js +3 -3
- package/dist/core/registry/command.registry.js.map +1 -1
- package/dist/core/registry/component.registry.cjs +8 -4
- package/dist/core/registry/component.registry.cjs.map +1 -1
- package/dist/core/registry/component.registry.d.cts +1 -1
- package/dist/core/registry/component.registry.d.ts +1 -1
- package/dist/core/registry/component.registry.js +3 -3
- package/dist/core/registry/component.registry.js.map +1 -1
- package/dist/core/registry/event.registry.cjs +10 -5
- package/dist/core/registry/event.registry.cjs.map +1 -1
- package/dist/core/registry/event.registry.d.cts +1 -1
- package/dist/core/registry/event.registry.d.ts +1 -1
- package/dist/core/registry/event.registry.js +5 -4
- package/dist/core/registry/event.registry.js.map +1 -1
- package/dist/core/registry/index.d.cts +1 -1
- package/dist/core/registry/index.d.ts +1 -1
- package/dist/core/registry/module.registry.cjs +8 -4
- package/dist/core/registry/module.registry.cjs.map +1 -1
- package/dist/core/registry/module.registry.d.cts +1 -1
- package/dist/core/registry/module.registry.d.ts +1 -1
- package/dist/core/registry/module.registry.js +3 -3
- package/dist/core/registry/module.registry.js.map +1 -1
- package/dist/{index-BR-jyADe.d.ts → index-D5NcshUu.d.ts} +14 -1
- package/dist/{index-BYTZLXk8.d.cts → index-SutqlRMo.d.cts} +14 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared/typings/client.d.cts +1 -1
- package/dist/shared/typings/client.d.ts +1 -1
- package/dist/shared/typings/commands.d.cts +1 -1
- package/dist/shared/typings/commands.d.ts +1 -1
- package/dist/shared/typings/components.d.cts +1 -1
- package/dist/shared/typings/components.d.ts +1 -1
- package/dist/shared/typings/events.d.cts +1 -1
- package/dist/shared/typings/events.d.ts +1 -1
- package/dist/shared/typings/index.d.cts +1 -1
- package/dist/shared/typings/index.d.ts +1 -1
- package/dist/shared/typings/module.d.cts +1 -1
- package/dist/shared/typings/module.d.ts +1 -1
- package/dist/shared/typings/permissions.d.cts +1 -1
- package/dist/shared/typings/permissions.d.ts +1 -1
- package/dist/shared/utility/functions.cjs +13 -5
- package/dist/shared/utility/functions.cjs.map +1 -1
- package/dist/shared/utility/functions.d.cts +5 -4
- package/dist/shared/utility/functions.d.ts +5 -4
- package/dist/shared/utility/functions.js +13 -6
- package/dist/shared/utility/functions.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var discord_js = require('discord.js');
|
|
4
4
|
var index_js = require('../registry/index.js');
|
|
5
|
+
var functions_js = require('../../shared/utility/functions.js');
|
|
6
|
+
var path = require('node:path');
|
|
7
|
+
var node_fs = require('node:fs');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
5
12
|
|
|
6
13
|
class TriviousClient extends discord_js.Client {
|
|
7
14
|
/**
|
|
@@ -63,11 +70,22 @@ class TriviousClient extends discord_js.Client {
|
|
|
63
70
|
* @returns {*}
|
|
64
71
|
*/
|
|
65
72
|
async deploy() {
|
|
73
|
+
const { commandHashConfig } = this._options;
|
|
66
74
|
const clientId = process.env[this._options.clientIdReference];
|
|
67
75
|
const token = process.env[this._options.tokenReference];
|
|
68
76
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
69
|
-
const
|
|
70
|
-
const body = [...
|
|
77
|
+
const commands = Array.from(this.registries.commands.get().values());
|
|
78
|
+
const body = [...commands.map((command) => command.toJSON())];
|
|
79
|
+
if (commandHashConfig.enabled) {
|
|
80
|
+
const hashFile = path__default.default.join(commandHashConfig.filePath || "data", "commands.hash");
|
|
81
|
+
const newHash = await functions_js.hashCommands(body);
|
|
82
|
+
let oldHash = "";
|
|
83
|
+
if (await functions_js.exists(hashFile)) oldHash = node_fs.readFileSync(hashFile, "utf-8");
|
|
84
|
+
if (newHash === oldHash) {
|
|
85
|
+
console.debug(`[Trivious] No changes in commands found, skipping deployment`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
71
89
|
const rest = new discord_js.REST({ version: "10" }).setToken(token);
|
|
72
90
|
await rest.put(discord_js.Routes.applicationCommands(clientId), { body });
|
|
73
91
|
console.log(`[Trivious] Deployed ${body.length} commands`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["Client","registries","REST","Routes"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["Client","registries","path","hashCommands","exists","readFileSync","REST","Routes"],"mappings":";;;;;;;;;;;;AAeA,MAAO,uBAAqCA,iBAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,aAAaC,mBAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,SAAA,CAAW,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,KAAA,EAAwC;AAC1D,IAAA,IAAA,CAAK,SAAS,eAAA,GAAkB,KAAA;AAAA,EACjC;AAAA,EAEA,IAAI,eAAA,GAAkB;AACrB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,eAAA,IAAmB,EAAC;AAAA,EAC1C;AACD","file":"trivious.client.cjs","sourcesContent":["import { Client, REST, Routes } from \"discord.js\";\nimport { registries } from \"../registry/index.js\";\nimport { TriviousClientOptions, PermissionLevel } from \"src/shared/typings/index.js\";\nimport { exists, hashCommands } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { readFileSync } from \"node:fs\";\n\n/**\n * Trivious base client.\n *\n * @export\n * @class TriviousClient\n * @typedef {TriviousClient}\n * @extends {Client}\n */\nexport default class TriviousClient extends Client {\n\t/**\n\t * Client registries.\n\t *\n\t * @public\n\t * @readonly\n\t * @type {*}\n\t */\n\tpublic readonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\tpublic readonly _options: TriviousClientOptions;\n\n\t/**\n\t * Creates an instance of TriviousClient.\n\t *\n\t * @constructor\n\t * @param {TriviousClientOptions} options\n\t */\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis._options = options;\n\t}\n\n\t/**\n\t * Load all registries.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync register() {\n\t\tconst { registries } = this;\n\t\tawait registries.loadAll(this._options);\n\t\tconsole.log(\n\t\t\t`[Trivious] Loaded all registries (${registries.commands.get().size} commands, ${registries.events.get().size} events, ${registries.components.get().size} components, ${registries.modules.get().size} modules)`\n\t\t);\n\t}\n\n\t/**\n\t * Login and start the bot.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync start() {\n\t\tif (!process.env[this._options.tokenReference]) {\n\t\t\tif (process.env.NODE_ENV !== \"production\") return;\n\t\t\telse throw new Error(\"[Trivious] Invalid token reference\");\n\t\t}\n\n\t\tthis.registries.bind(this);\n\t\tawait this.login(process.env[this._options.tokenReference]);\n\t}\n\n\t/**\n\t * Deploy all commands.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync deploy() {\n\t\tconst { commandHashConfig } = this._options;\n\t\tconst clientId = process.env[this._options.clientIdReference];\n\t\tconst token = process.env[this._options.tokenReference];\n\t\tif (!clientId || !token) throw new Error(\"[Trivious] Invalid clientId or token reference\");\n\n\t\tconst commands = Array.from(this.registries.commands.get().values());\n\t\tconst body = [...commands.map(command => command.toJSON())];\n\n\t\tif (commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = await hashCommands(body);\n\t\t\tlet oldHash = \"\";\n\n\t\t\tif (await exists(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\t\t\tif (newHash === oldHash) {\n\t\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment`)\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\t\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\t\tconsole.log(`[Trivious] Deployed ${body.length} commands`);\n\t}\n\n\t/**\n\t * Set the roles tied to a permission level.\n\t *\n\t * @param {Record<string, PermissionLevel>} roles\n\t */\n\tsetRolePermissions(roles: Record<string, PermissionLevel>) {\n\t\tthis._options.rolePermissions = roles;\n\t}\n\n\tget rolePermissions() {\n\t\treturn this._options.rolePermissions ?? {};\n\t}\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Client, REST, Routes } from 'discord.js';
|
|
2
2
|
import { registries } from '../registry/index.js';
|
|
3
|
+
import { hashCommands, exists } from '../../shared/utility/functions.js';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
3
6
|
|
|
4
7
|
class TriviousClient extends Client {
|
|
5
8
|
/**
|
|
@@ -61,11 +64,22 @@ class TriviousClient extends Client {
|
|
|
61
64
|
* @returns {*}
|
|
62
65
|
*/
|
|
63
66
|
async deploy() {
|
|
67
|
+
const { commandHashConfig } = this._options;
|
|
64
68
|
const clientId = process.env[this._options.clientIdReference];
|
|
65
69
|
const token = process.env[this._options.tokenReference];
|
|
66
70
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
67
|
-
const
|
|
68
|
-
const body = [...
|
|
71
|
+
const commands = Array.from(this.registries.commands.get().values());
|
|
72
|
+
const body = [...commands.map((command) => command.toJSON())];
|
|
73
|
+
if (commandHashConfig.enabled) {
|
|
74
|
+
const hashFile = path.join(commandHashConfig.filePath || "data", "commands.hash");
|
|
75
|
+
const newHash = await hashCommands(body);
|
|
76
|
+
let oldHash = "";
|
|
77
|
+
if (await exists(hashFile)) oldHash = readFileSync(hashFile, "utf-8");
|
|
78
|
+
if (newHash === oldHash) {
|
|
79
|
+
console.debug(`[Trivious] No changes in commands found, skipping deployment`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
69
83
|
const rest = new REST({ version: "10" }).setToken(token);
|
|
70
84
|
await rest.put(Routes.applicationCommands(clientId), { body });
|
|
71
85
|
console.log(`[Trivious] Deployed ${body.length} commands`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["registries"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["registries"],"mappings":";;;;;;AAeA,MAAO,uBAAqC,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,aAAa,UAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAA,CAAI,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,SAAA,CAAW,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,KAAA,EAAwC;AAC1D,IAAA,IAAA,CAAK,SAAS,eAAA,GAAkB,KAAA;AAAA,EACjC;AAAA,EAEA,IAAI,eAAA,GAAkB;AACrB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,eAAA,IAAmB,EAAC;AAAA,EAC1C;AACD","file":"trivious.client.js","sourcesContent":["import { Client, REST, Routes } from \"discord.js\";\nimport { registries } from \"../registry/index.js\";\nimport { TriviousClientOptions, PermissionLevel } from \"src/shared/typings/index.js\";\nimport { exists, hashCommands } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { readFileSync } from \"node:fs\";\n\n/**\n * Trivious base client.\n *\n * @export\n * @class TriviousClient\n * @typedef {TriviousClient}\n * @extends {Client}\n */\nexport default class TriviousClient extends Client {\n\t/**\n\t * Client registries.\n\t *\n\t * @public\n\t * @readonly\n\t * @type {*}\n\t */\n\tpublic readonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\tpublic readonly _options: TriviousClientOptions;\n\n\t/**\n\t * Creates an instance of TriviousClient.\n\t *\n\t * @constructor\n\t * @param {TriviousClientOptions} options\n\t */\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis._options = options;\n\t}\n\n\t/**\n\t * Load all registries.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync register() {\n\t\tconst { registries } = this;\n\t\tawait registries.loadAll(this._options);\n\t\tconsole.log(\n\t\t\t`[Trivious] Loaded all registries (${registries.commands.get().size} commands, ${registries.events.get().size} events, ${registries.components.get().size} components, ${registries.modules.get().size} modules)`\n\t\t);\n\t}\n\n\t/**\n\t * Login and start the bot.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync start() {\n\t\tif (!process.env[this._options.tokenReference]) {\n\t\t\tif (process.env.NODE_ENV !== \"production\") return;\n\t\t\telse throw new Error(\"[Trivious] Invalid token reference\");\n\t\t}\n\n\t\tthis.registries.bind(this);\n\t\tawait this.login(process.env[this._options.tokenReference]);\n\t}\n\n\t/**\n\t * Deploy all commands.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync deploy() {\n\t\tconst { commandHashConfig } = this._options;\n\t\tconst clientId = process.env[this._options.clientIdReference];\n\t\tconst token = process.env[this._options.tokenReference];\n\t\tif (!clientId || !token) throw new Error(\"[Trivious] Invalid clientId or token reference\");\n\n\t\tconst commands = Array.from(this.registries.commands.get().values());\n\t\tconst body = [...commands.map(command => command.toJSON())];\n\n\t\tif (commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = await hashCommands(body);\n\t\t\tlet oldHash = \"\";\n\n\t\t\tif (await exists(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\t\t\tif (newHash === oldHash) {\n\t\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment`)\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\t\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\t\tconsole.log(`[Trivious] Deployed ${body.length} commands`);\n\t}\n\n\t/**\n\t * Set the roles tied to a permission level.\n\t *\n\t * @param {Record<string, PermissionLevel>} roles\n\t */\n\tsetRolePermissions(roles: Record<string, PermissionLevel>) {\n\t\tthis._options.rolePermissions = roles;\n\t}\n\n\tget rolePermissions() {\n\t\treturn this._options.rolePermissions ?? {};\n\t}\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-
|
|
2
|
+
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-SutqlRMo.cjs';
|
|
3
3
|
import '../../shared/typings/registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-
|
|
2
|
+
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-D5NcshUu.js';
|
|
3
3
|
import '../../shared/typings/registry.js';
|
|
@@ -4,7 +4,11 @@ var discord_js = require('discord.js');
|
|
|
4
4
|
var index_js = require('../../shared/typings/index.js');
|
|
5
5
|
var functions_js = require('../../shared/utility/functions.js');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var
|
|
7
|
+
var path = require('node:path');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
8
12
|
|
|
9
13
|
class CommandRegistry extends index_js.BaseRegistry {
|
|
10
14
|
items = new discord_js.Collection();
|
|
@@ -15,16 +19,16 @@ class CommandRegistry extends index_js.BaseRegistry {
|
|
|
15
19
|
* @param {string} [directory=getCorePath({ coreDirectory: "commands" })]
|
|
16
20
|
* @returns {unknown}
|
|
17
21
|
*/
|
|
18
|
-
async load(directory = functions_js.
|
|
22
|
+
async load(directory = functions_js.resolveUserPath(path__default.default.join("src", "commands"))) {
|
|
19
23
|
if (!await functions_js.exists(directory)) {
|
|
20
24
|
return this;
|
|
21
25
|
}
|
|
22
26
|
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
23
27
|
for (const entry of entries) {
|
|
24
|
-
const fullPath =
|
|
28
|
+
const fullPath = path.join(directory, entry.name);
|
|
25
29
|
if (!entry.isDirectory()) continue;
|
|
26
|
-
const indexFile =
|
|
27
|
-
const indexJs =
|
|
30
|
+
const indexFile = path.join(fullPath, "index.ts");
|
|
31
|
+
const indexJs = path.join(fullPath, "index.js");
|
|
28
32
|
let commandFile = "";
|
|
29
33
|
if (await functions_js.exists(indexFile)) commandFile = indexFile;
|
|
30
34
|
else if (await functions_js.exists(indexJs)) commandFile = indexJs;
|
|
@@ -37,7 +41,7 @@ class CommandRegistry extends index_js.BaseRegistry {
|
|
|
37
41
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
38
42
|
);
|
|
39
43
|
for (const file of subcommandFiles) {
|
|
40
|
-
const subcommand = await this.importFile(
|
|
44
|
+
const subcommand = await this.importFile(path.join(fullPath, file));
|
|
41
45
|
if (!subcommand) continue;
|
|
42
46
|
if (!subcommand.data.name || !(subcommand.data instanceof discord_js.SlashCommandSubcommandBuilder))
|
|
43
47
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/command.registry.ts"],"names":["BaseRegistry","Collection","
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/command.registry.ts"],"names":["BaseRegistry","Collection","resolveUserPath","path","exists","fs","join","SlashCommandSubcommandBuilder"],"mappings":";;;;;;;;;;;;AAeA,MAAO,wBAAsCA,qBAAA,CAAyB;AAAA,EAC3D,KAAA,GAAQ,IAAIC,qBAAA,EAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrD,MAAM,KAAK,SAAA,GAAoBC,4BAAA,CAAgBC,sBAAK,IAAA,CAAK,KAAA,EAAO,UAAU,CAAC,CAAA,EAAG;AAC7E,IAAA,IAAI,CAAE,MAAMC,mBAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMC,WAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SA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AgBC,wCAAA,CAAA;AACzD,YAAA;AAED,UAAA,OAAA,CAAQ,IAAA,CAAK,aAAA,CAAc,UAAA,CAAW,IAAI,CAAA;AAC1C,UAAA,OAAA,CAAQ,SAAS,WAAA,CAAY,GAAA,CAAI,UAAA,CAAW,IAAA,CAAK,MAAM,UAAU,CAAA;AAAA,QAClE;AAAA,MACD;AAEA,MAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,OAAA,CAAQ,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,IAC1C;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"command.registry.cjs","sourcesContent":["import { Collection, SlashCommandSubcommandBuilder } from \"discord.js\";\nimport { BaseRegistry, AnyCommand } from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport Subcommand from \"../commands/subcommand.base.js\";\n\n/**\n * Registry to load and get all commands.\n *\n * @export\n * @class CommandRegistry\n * @typedef {CommandRegistry}\n * @extends {BaseRegistry<AnyCommand>}\n */\nexport default class CommandRegistry extends BaseRegistry<AnyCommand> {\n\tprotected items = new Collection<string, AnyCommand>();\n\n\t/**\n\t * Load all commands and their subcommands\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"commands\" })]\n\t * @returns {unknown}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"commands\"))) {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst indexFile = join(fullPath, \"index.ts\");\n\t\t\tconst indexJs = join(fullPath, \"index.js\");\n\n\t\t\tlet commandFile = \"\";\n\t\t\tif (await exists(indexFile)) commandFile = indexFile;\n\t\t\telse if (await exists(indexJs)) commandFile = indexJs;\n\t\t\telse continue;\n\n\t\t\tconst command = await this.importFile<AnyCommand>(commandFile);\n\t\t\tif (!command) continue;\n\t\t\tif (!command.metadata.active) continue;\n\n\t\t\tif (command.isSlashCommand()) {\n\t\t\t\tconst subcommandFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\t\tfile =>\n\t\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t\t);\n\n\t\t\t\tfor (const file of subcommandFiles) {\n\t\t\t\t\tconst subcommand = await this.importFile<Subcommand>(join(fullPath, file));\n\t\t\t\t\tif (!subcommand) continue;\n\t\t\t\t\tif (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tcommand.data.addSubcommand(subcommand.data);\n\t\t\t\t\tcommand.metadata.subcommands.set(subcommand.data.name, subcommand);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.items.set(command.data.name, command);\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Collection, SlashCommandSubcommandBuilder } from 'discord.js';
|
|
2
2
|
import { BaseRegistry } from '../../shared/typings/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveUserPath, exists } from '../../shared/utility/functions.js';
|
|
4
4
|
import { promises } from 'fs';
|
|
5
|
-
import { join } from 'node:path';
|
|
5
|
+
import path, { join } from 'node:path';
|
|
6
6
|
|
|
7
7
|
class CommandRegistry extends BaseRegistry {
|
|
8
8
|
items = new Collection();
|
|
@@ -13,7 +13,7 @@ class CommandRegistry extends BaseRegistry {
|
|
|
13
13
|
* @param {string} [directory=getCorePath({ coreDirectory: "commands" })]
|
|
14
14
|
* @returns {unknown}
|
|
15
15
|
*/
|
|
16
|
-
async load(directory =
|
|
16
|
+
async load(directory = resolveUserPath(path.join("src", "commands"))) {
|
|
17
17
|
if (!await exists(directory)) {
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/command.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,wBAAsC,YAAA,CAAyB;AAAA,EAC3D,KAAA,GAAQ,IAAI,UAAA,EAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrD,MAAM,KAAK,SAAA,GAAoB,
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/command.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,wBAAsC,YAAA,CAAyB;AAAA,EAC3D,KAAA,GAAQ,IAAI,UAAA,EAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrD,MAAM,KAAK,SAAA,GAAoB,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,UAAU,CAAC,CAAA,EAAG;AAC7E,IAAA,IAAI,CAAE,MAAM,MAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMA,QAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,SAAA,GAAY,IAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AAC3C,MAAA,MAAM,OAAA,GAAU,IAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AAEzC,MAAA,IAAI,WAAA,GAAc,EAAA;AAClB,MAAA,IAAI,MAAM,MAAA,CAAO,SAAS,CA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.js","sourcesContent":["import { Collection, SlashCommandSubcommandBuilder } from \"discord.js\";\nimport { BaseRegistry, AnyCommand } from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport Subcommand from \"../commands/subcommand.base.js\";\n\n/**\n * Registry to load and get all commands.\n *\n * @export\n * @class CommandRegistry\n * @typedef {CommandRegistry}\n * @extends {BaseRegistry<AnyCommand>}\n */\nexport default class CommandRegistry extends BaseRegistry<AnyCommand> {\n\tprotected items = new Collection<string, AnyCommand>();\n\n\t/**\n\t * Load all commands and their subcommands\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"commands\" })]\n\t * @returns {unknown}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"commands\"))) {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst indexFile = join(fullPath, \"index.ts\");\n\t\t\tconst indexJs = join(fullPath, \"index.js\");\n\n\t\t\tlet commandFile = \"\";\n\t\t\tif (await exists(indexFile)) commandFile = indexFile;\n\t\t\telse if (await exists(indexJs)) commandFile = indexJs;\n\t\t\telse continue;\n\n\t\t\tconst command = await this.importFile<AnyCommand>(commandFile);\n\t\t\tif (!command) continue;\n\t\t\tif (!command.metadata.active) continue;\n\n\t\t\tif (command.isSlashCommand()) {\n\t\t\t\tconst subcommandFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\t\tfile =>\n\t\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t\t);\n\n\t\t\t\tfor (const file of subcommandFiles) {\n\t\t\t\t\tconst subcommand = await this.importFile<Subcommand>(join(fullPath, file));\n\t\t\t\t\tif (!subcommand) continue;\n\t\t\t\t\tif (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tcommand.data.addSubcommand(subcommand.data);\n\t\t\t\t\tcommand.metadata.subcommands.set(subcommand.data.name, subcommand);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.items.set(command.data.name, command);\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
|
|
@@ -4,7 +4,11 @@ var discord_js = require('discord.js');
|
|
|
4
4
|
var index_js = require('../../shared/typings/index.js');
|
|
5
5
|
var functions_js = require('../../shared/utility/functions.js');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var
|
|
7
|
+
var path = require('node:path');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
8
12
|
|
|
9
13
|
class ComponentRegistry extends index_js.BaseRegistry {
|
|
10
14
|
items = new discord_js.Collection();
|
|
@@ -15,19 +19,19 @@ class ComponentRegistry extends index_js.BaseRegistry {
|
|
|
15
19
|
* @param {string} [directory=getCorePath({ coreDirectory: "components" })]
|
|
16
20
|
* @returns {Promise<this>}
|
|
17
21
|
*/
|
|
18
|
-
async load(directory = functions_js.
|
|
22
|
+
async load(directory = functions_js.resolveUserPath(path__default.default.join("src", "components"))) {
|
|
19
23
|
if (!await functions_js.exists(directory)) {
|
|
20
24
|
return this;
|
|
21
25
|
}
|
|
22
26
|
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
23
27
|
for (const entry of entries) {
|
|
24
|
-
const fullPath =
|
|
28
|
+
const fullPath = path.join(directory, entry.name);
|
|
25
29
|
if (!entry.isDirectory()) continue;
|
|
26
30
|
const componentFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
27
31
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
28
32
|
);
|
|
29
33
|
for (const file of componentFiles) {
|
|
30
|
-
const component = await this.importFile(
|
|
34
|
+
const component = await this.importFile(path.join(fullPath, file));
|
|
31
35
|
if (!component) continue;
|
|
32
36
|
const { data } = index_js.deconstructCustomId(component.metadata.customId);
|
|
33
37
|
this.items.set(data, component);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/component.registry.ts"],"names":["BaseRegistry","Collection","
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/component.registry.ts"],"names":["BaseRegistry","Collection","resolveUserPath","path","exists","fs","join","deconstructCustomId"],"mappings":";;;;;;;;;;;;AAeA,MAAO,0BAAwCA,qBAAA,CAAwB;AAAA,EAC5D,KAAA,GAAQ,IAAIC,qBAAA,EAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpD,MAAM,KAAK,SAAA,GAAoBC,4BAAA,CAAgBC,sBAAK,IAAA,CAAK,KAAA,EAAO,YAAY,CAAC,CAAA,EAAkB;AAC9F,IAAA,IAAI,CAAE,MAAMC,mBAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMC,WAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAWC,SAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,cAAA,GAAA,CAAkB,MAAMD,WAAA,CAAG,OAAA,CAAQ,QAAQ,CAAA,EAAG,MAAA;AAAA,QACnD,WACE,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,IAAK,KAAK,QAAA,CAAS,KAAK,CAAA,KAC5C,CAAC,KAAK,UAAA,CAAW,QAAQ,KACzB,CAAC,IAAA,CAAK,SAAS,OAAO;AAAA,OACxB;AAEA,MAAA,KAAA,MAAW,QAAQ,cAAA,EAAgB;AAClC,QAAA,MAAM,YAAY,MAAM,IAAA,CAAK,WAAsBC,SAAA,CAAK,QAAA,EAAU,IAAI,CAAC,CAAA;AACvE,QAAA,IAAI,CAAC,SAAA,EAAW;AAEhB,QAAA,MAAM,EAAE,IAAA,EAAK,GAAIC,4BAAA,CAAoB,SAAA,CAAU,SAAS,QAAQ,CAAA;AAChE,QAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,IAAA,EAAM,SAAS,CAAA;AAAA,MAC/B;AAAA,IACD;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"component.registry.cjs","sourcesContent":["import { Collection } from \"discord.js\";\nimport { BaseRegistry, deconstructCustomId } from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport Component from \"../components/component.base.js\";\n\n/**\n * Registry to load and get all components.\n *\n * @export\n * @class ComponentRegistry\n * @typedef {ComponentRegistry}\n * @extends {BaseRegistry<Component>}\n */\nexport default class ComponentRegistry extends BaseRegistry<Component> {\n\tprotected items = new Collection<string, Component>();\n\n\t/**\n\t * Load all components.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"components\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"components\"))): Promise<this> {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst componentFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\tfile =>\n\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t);\n\n\t\t\tfor (const file of componentFiles) {\n\t\t\t\tconst component = await this.importFile<Component>(join(fullPath, file));\n\t\t\t\tif (!component) continue;\n\n\t\t\t\tconst { data } = deconstructCustomId(component.metadata.customId);\n\t\t\t\tthis.items.set(data, component);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
2
|
import { BaseRegistry, deconstructCustomId } from '../../shared/typings/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveUserPath, exists } from '../../shared/utility/functions.js';
|
|
4
4
|
import { promises } from 'fs';
|
|
5
|
-
import { join } from 'node:path';
|
|
5
|
+
import path, { join } from 'node:path';
|
|
6
6
|
|
|
7
7
|
class ComponentRegistry extends BaseRegistry {
|
|
8
8
|
items = new Collection();
|
|
@@ -13,7 +13,7 @@ class ComponentRegistry extends BaseRegistry {
|
|
|
13
13
|
* @param {string} [directory=getCorePath({ coreDirectory: "components" })]
|
|
14
14
|
* @returns {Promise<this>}
|
|
15
15
|
*/
|
|
16
|
-
async load(directory =
|
|
16
|
+
async load(directory = resolveUserPath(path.join("src", "components"))) {
|
|
17
17
|
if (!await exists(directory)) {
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/component.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,0BAAwC,YAAA,CAAwB;AAAA,EAC5D,KAAA,GAAQ,IAAI,UAAA,EAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpD,MAAM,KAAK,SAAA,GAAoB,
|
|
1
|
+
{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A,CAAI,IAAA,EAAM,SAAS,CAAA;AAAA,MAC/B;AAAA,IACD;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AACD","file":"component.registry.js","sourcesContent":["import { Collection } from \"discord.js\";\nimport { BaseRegistry, deconstructCustomId } from \"src/shared/typings/index.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport Component from \"../components/component.base.js\";\n\n/**\n * Registry to load and get all components.\n *\n * @export\n * @class ComponentRegistry\n * @typedef {ComponentRegistry}\n * @extends {BaseRegistry<Component>}\n */\nexport default class ComponentRegistry extends BaseRegistry<Component> {\n\tprotected items = new Collection<string, Component>();\n\n\t/**\n\t * Load all components.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"components\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"components\"))): Promise<this> {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst componentFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\tfile =>\n\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t);\n\n\t\t\tfor (const file of componentFiles) {\n\t\t\t\tconst component = await this.importFile<Component>(join(fullPath, file));\n\t\t\t\tif (!component) continue;\n\n\t\t\t\tconst { data } = deconstructCustomId(component.metadata.customId);\n\t\t\t\tthis.items.set(data, component);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
|
|
@@ -4,7 +4,11 @@ var discord_js = require('discord.js');
|
|
|
4
4
|
var functions_js = require('../../shared/utility/functions.js');
|
|
5
5
|
var index_js = require('../../shared/typings/index.js');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var
|
|
7
|
+
var path = require('node:path');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
8
12
|
|
|
9
13
|
class EventRegistry extends index_js.BaseRegistry {
|
|
10
14
|
items = new discord_js.Collection();
|
|
@@ -16,10 +20,11 @@ class EventRegistry extends index_js.BaseRegistry {
|
|
|
16
20
|
* @returns {Promise<this>}
|
|
17
21
|
*/
|
|
18
22
|
async loadPresetEvents() {
|
|
19
|
-
const directory = functions_js.getCorePath({ coreDirectory: "events" });
|
|
23
|
+
const directory = functions_js.getCorePath({ coreDirectory: "core/events" });
|
|
24
|
+
if (!directory) return;
|
|
20
25
|
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
21
26
|
for (const entry of entries) {
|
|
22
|
-
const fullPath =
|
|
27
|
+
const fullPath = path.join(directory, entry.name);
|
|
23
28
|
if (!entry.isFile() || !entry.name.endsWith(".js")) continue;
|
|
24
29
|
const event = await this.importFile(fullPath);
|
|
25
30
|
if (!event) continue;
|
|
@@ -35,11 +40,11 @@ class EventRegistry extends index_js.BaseRegistry {
|
|
|
35
40
|
* @param {string} [directory=getCorePath({ coreDirectory: "events" })]
|
|
36
41
|
* @returns {Promise<this>}
|
|
37
42
|
*/
|
|
38
|
-
async load(directory = functions_js.
|
|
43
|
+
async load(directory = functions_js.resolveUserPath(path__default.default.join("src", "events"))) {
|
|
39
44
|
if (!await functions_js.exists(directory)) return this;
|
|
40
45
|
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
41
46
|
for (const entry of entries) {
|
|
42
|
-
const fullPath =
|
|
47
|
+
const fullPath = path.join(directory, entry.name);
|
|
43
48
|
if (entry.isDirectory()) {
|
|
44
49
|
await this.load(fullPath);
|
|
45
50
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/event.registry.ts"],"names":["BaseRegistry","Collection","getCorePath","fs","join","exists"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/event.registry.ts"],"names":["BaseRegistry","Collection","getCorePath","fs","join","resolveUserPath","path","exists"],"mappings":";;;;;;;;;;;;AAeA,MAAO,sBAAoCA,qBAAA,CAAoB;AAAA,EACpD,KAAA,GAAQ,IAAIC,qBAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShD,MAAgB,gBAAA,GAAmB;AAClC,IAAA,MAAM,SAAA,GAAYC,wBAAA,CAAY,EAAE,aAAA,EAAe,eAAe,CAAA;AAC9D,IAAA,IAAI,CAAC,SAAA,EAAW;AAEhB,IAAA,MAAM,OAAA,GAAU,MAAMC,WAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AACnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAWC,SAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,MAAM,MAAA,EAAO,IAAK,CAAC,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,EAAG;AAEpD,MAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,UAAA,CAAkB,QAAQ,CAAA;AACnD,MAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,MAAA,IAAI,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AAChC,MAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,KAAA,CAAM,IAAA,EAAM,KAAK,CAAA;AAAA,IACjC;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,KAA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C,MAAA,CAAO,EAAA,CAAG,KAAA,CAAM,IAAA,EAAM,OAAO,CAAA;AAAA,IACnC;AAAA,EACD;AACD","file":"event.registry.cjs","sourcesContent":["import { ClientEvents, Collection } from \"discord.js\";\nimport { exists, getCorePath, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Event } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\n/**\n * Registry to load, get and bind events.\n *\n * @export\n * @class EventRegistry\n * @typedef {EventRegistry}\n * @extends {BaseRegistry<Event>}\n */\nexport default class EventRegistry extends BaseRegistry<Event> {\n\tprotected items = new Collection<string, Event>();\n\n\t/**\n\t * Load all preset events, can be overridden by user-provided events.\n\t *\n\t * @async\n\t * @protected\n\t * @returns {Promise<this>}\n\t */\n\tprotected async loadPresetEvents() {\n\t\tconst directory = getCorePath({ coreDirectory: \"core/events\" });\n\t\tif (!directory) return;\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isFile() || !entry.name.endsWith(\".js\")) continue;\n\n\t\t\tconst event = await this.importFile<Event>(fullPath);\n\t\t\tif (!event) continue;\n\n\t\t\tif (this.items.has(event.name)) continue;\n\t\t\tthis.items.set(event.name, event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Load all events.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"events\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"events\"))): Promise<this> {\n\t\tif (!(await exists(directory))) return this;\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait this.load(fullPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isFile() && entry.name.endsWith(\".js\")) {\n\t\t\t\tconst event = await this.importFile<Event>(fullPath);\n\t\t\t\tif (!event) continue;\n\n\t\t\t\tthis.items.set(event.name, event);\n\t\t\t}\n\t\t}\n\n\t\tawait this.loadPresetEvents();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Bind loaded events to their client events respectively.\n\t *\n\t * @param {TriviousClient} client\n\t */\n\tbind(client: TriviousClient) {\n\t\tfor (const event of this.items.values()) {\n\t\t\tconst handler = (...args: ClientEvents[typeof event.name]) =>\n\t\t\t\tvoid event.execute(client, ...args);\n\n\t\t\tif (event.once) client.once(event.name, handler);\n\t\t\telse client.on(event.name, handler);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
|
-
import { getCorePath, exists } from '../../shared/utility/functions.js';
|
|
2
|
+
import { getCorePath, resolveUserPath, exists } from '../../shared/utility/functions.js';
|
|
3
3
|
import { BaseRegistry } from '../../shared/typings/index.js';
|
|
4
4
|
import { promises } from 'fs';
|
|
5
|
-
import { join } from 'node:path';
|
|
5
|
+
import path, { join } from 'node:path';
|
|
6
6
|
|
|
7
7
|
class EventRegistry extends BaseRegistry {
|
|
8
8
|
items = new Collection();
|
|
@@ -14,7 +14,8 @@ class EventRegistry extends BaseRegistry {
|
|
|
14
14
|
* @returns {Promise<this>}
|
|
15
15
|
*/
|
|
16
16
|
async loadPresetEvents() {
|
|
17
|
-
const directory = getCorePath({ coreDirectory: "events" });
|
|
17
|
+
const directory = getCorePath({ coreDirectory: "core/events" });
|
|
18
|
+
if (!directory) return;
|
|
18
19
|
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
19
20
|
for (const entry of entries) {
|
|
20
21
|
const fullPath = join(directory, entry.name);
|
|
@@ -33,7 +34,7 @@ class EventRegistry extends BaseRegistry {
|
|
|
33
34
|
* @param {string} [directory=getCorePath({ coreDirectory: "events" })]
|
|
34
35
|
* @returns {Promise<this>}
|
|
35
36
|
*/
|
|
36
|
-
async load(directory =
|
|
37
|
+
async load(directory = resolveUserPath(path.join("src", "events"))) {
|
|
37
38
|
if (!await exists(directory)) return this;
|
|
38
39
|
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
39
40
|
for (const entry of entries) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/event.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,sBAAoC,YAAA,CAAoB;AAAA,EACpD,KAAA,GAAQ,IAAI,UAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShD,MAAgB,gBAAA,GAAmB;AAClC,IAAA,MAAM,SAAA,GAAY,WAAA,CAAY,EAAE,aAAA,EAAe,
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/event.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,sBAAoC,YAAA,CAAoB;AAAA,EACpD,KAAA,GAAQ,IAAI,UAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShD,MAAgB,gBAAA,GAAmB;AAClC,IAAA,MAAM,SAAA,GAAY,WAAA,CAAY,EAAE,aAAA,EAAe,eAAe,CAAA;AAC9D,IAAA,IAAI,CAAC,SAAA,EAAW;AAEhB,IAAA,MAAM,OAAA,GAAU,MAAMA,QAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AACnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,MAAM,MAAA,EAAO,IAAK,CAAC,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,EAAG;AAEpD,MAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CA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AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,MAAA,EAAwB;AAC5B,IAAA,KAAA,MAAW,KAAA,IAAS,IAAA,CAAK,KAAA,CAAM,MAAA,EAAO,EAAG;AACxC,MAAA,MAAM,OAAA,GAAU,IAAI,IAAA,KACnB,KAAK,MAAM,OAAA,CAAQ,MAAA,EAAQ,GAAG,IAAI,CAAA;AAEnC,MAAA,IAAI,MAAM,IAAA,EAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,MAAM,OAAO,CAAA;AAAA,WAC1C,MAAA,CAAO,EAAA,CAAG,KAAA,CAAM,IAAA,EAAM,OAAO,CAAA;AAAA,IACnC;AAAA,EACD;AACD","file":"event.registry.js","sourcesContent":["import { ClientEvents, Collection } from \"discord.js\";\nimport { exists, getCorePath, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Event } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\n/**\n * Registry to load, get and bind events.\n *\n * @export\n * @class EventRegistry\n * @typedef {EventRegistry}\n * @extends {BaseRegistry<Event>}\n */\nexport default class EventRegistry extends BaseRegistry<Event> {\n\tprotected items = new Collection<string, Event>();\n\n\t/**\n\t * Load all preset events, can be overridden by user-provided events.\n\t *\n\t * @async\n\t * @protected\n\t * @returns {Promise<this>}\n\t */\n\tprotected async loadPresetEvents() {\n\t\tconst directory = getCorePath({ coreDirectory: \"core/events\" });\n\t\tif (!directory) return;\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isFile() || !entry.name.endsWith(\".js\")) continue;\n\n\t\t\tconst event = await this.importFile<Event>(fullPath);\n\t\t\tif (!event) continue;\n\n\t\t\tif (this.items.has(event.name)) continue;\n\t\t\tthis.items.set(event.name, event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Load all events.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"events\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"events\"))): Promise<this> {\n\t\tif (!(await exists(directory))) return this;\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait this.load(fullPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isFile() && entry.name.endsWith(\".js\")) {\n\t\t\t\tconst event = await this.importFile<Event>(fullPath);\n\t\t\t\tif (!event) continue;\n\n\t\t\t\tthis.items.set(event.name, event);\n\t\t\t}\n\t\t}\n\n\t\tawait this.loadPresetEvents();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Bind loaded events to their client events respectively.\n\t *\n\t * @param {TriviousClient} client\n\t */\n\tbind(client: TriviousClient) {\n\t\tfor (const event of this.items.values()) {\n\t\t\tconst handler = (...args: ClientEvents[typeof event.name]) =>\n\t\t\t\tvoid event.execute(client, ...args);\n\n\t\t\tif (event.once) client.once(event.name, handler);\n\t\t\telse client.on(event.name, handler);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-
|
|
1
|
+
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-SutqlRMo.cjs';
|
|
2
2
|
import '../../shared/typings/registry.cjs';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-
|
|
1
|
+
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-D5NcshUu.js';
|
|
2
2
|
import '../../shared/typings/registry.js';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
|
|
@@ -4,7 +4,11 @@ var discord_js = require('discord.js');
|
|
|
4
4
|
var functions_js = require('../../shared/utility/functions.js');
|
|
5
5
|
var index_js = require('../../shared/typings/index.js');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var
|
|
7
|
+
var path = require('node:path');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
8
12
|
|
|
9
13
|
class ModuleRegistry extends index_js.BaseRegistry {
|
|
10
14
|
items = new discord_js.Collection();
|
|
@@ -15,19 +19,19 @@ class ModuleRegistry extends index_js.BaseRegistry {
|
|
|
15
19
|
* @param {string} [directory=getCorePath({ coreDirectory: "module" })]
|
|
16
20
|
* @returns {Promise<this>}
|
|
17
21
|
*/
|
|
18
|
-
async load(directory = functions_js.
|
|
22
|
+
async load(directory = functions_js.resolveUserPath(path__default.default.join("src", "modules"))) {
|
|
19
23
|
if (!await functions_js.exists(directory)) {
|
|
20
24
|
return this;
|
|
21
25
|
}
|
|
22
26
|
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
23
27
|
for (const entry of entries) {
|
|
24
|
-
const fullPath =
|
|
28
|
+
const fullPath = path.join(directory, entry.name);
|
|
25
29
|
if (!entry.isDirectory()) continue;
|
|
26
30
|
const moduleFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
27
31
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
28
32
|
);
|
|
29
33
|
for (const file of moduleFiles) {
|
|
30
|
-
const moduleEvent = await this.importFile(
|
|
34
|
+
const moduleEvent = await this.importFile(path.join(fullPath, file));
|
|
31
35
|
if (!moduleEvent || !moduleEvent.events) continue;
|
|
32
36
|
this.items.set(moduleEvent.name, moduleEvent);
|
|
33
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/module.registry.ts"],"names":["BaseRegistry","Collection","
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/module.registry.ts"],"names":["BaseRegistry","Collection","resolveUserPath","path","exists","fs","join"],"mappings":";;;;;;;;;;;;AAeA,MAAO,uBAAqCA,qBAAA,CAAqB;AAAA,EACtD,KAAA,GAAQ,IAAIC,qBAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjD,MAAM,KAAK,SAAA,GAAoBC,4BAAA,CAAgBC,sBAAK,IAAA,CAAK,KAAA,EAAO,SAAS,CAAC,CAAA,EAAkB;AAC3F,IAAA,IAAI,CAAE,MAAMC,mBAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMC,WAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAWC,SAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,WAAA,GAAA,CAAe,MAAMD,WAAA,CAAG,OAAA,CAAQ,QAAQ,CAAA,EAAG,MAAA;AAAA,QAChD,WACE,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,IAAK,KAAK,QAAA,CAAS,KAAK,CAAA,KAC5C,CAAC,KAAK,UAAA,CAAW,QAAQ,KACzB,CAAC,IAAA,CAAK,SAAS,OAAO;AAAA,OACxB;AAEA,MAAA,KAAA,MAAW,QAAQ,WAAA,EAAa;AAC/B,QAAA,MAAM,cAAc,MAAM,IAAA,CAAK,WAAmBC,SAAA,CAAK,QAAA,EAAU,IAAI,CAAC,CAAA;AACtE,QAAA,IAAI,CAAC,WAAA,IAAe,CAAC,WAAA,CAAY,MAAA,EAAQ;AAEzC,QAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,WAAA,CAAY,IAAA,EAAM,WAAW,CAAA;AAAA,MAC7C;AAAA,IACD;AAEA,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,MAAA,EAAwB;AAC5B,IAAA,KAAA,MAAW,GAAA,IAAO,IAAA,CAAK,KAAA,CAAM,MAAA,EAAO,EAAG;AACtC,MAAA,KAAA,MAAW,CAAC,WAAW,OAAO,CAAA,IAAK,OAAO,OAAA,CAAQ,GAAA,CAAI,MAAO,CAAA,EAAG;AAC/D,QAAA,IAAI,OAAO,YAAY,UAAA,EAAY;AAEnC,QAAA,MAAM,QAAA,GAAW,IAAI,IAAA,KAAoB;AACxC,UAAA,KAAM,OAAA,CAAgE,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,QACtF,CAAA;AAEA,QAAC,MAAA,CAAO,EAAA,CAAW,SAAA,EAAW,QAAQ,CAAA;AAAA,MACvC;AAAA,IACD;AAAA,EACD;AACD","file":"module.registry.cjs","sourcesContent":["import { Collection } from \"discord.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Module } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\n/**\n * Registry to load, get and bind modules.\n *\n * @export\n * @class ModuleRegistry\n * @typedef {ModuleRegistry}\n * @extends {BaseRegistry<Module>}\n */\nexport default class ModuleRegistry extends BaseRegistry<Module> {\n\tprotected items = new Collection<string, Module>();\n\n\t/**\n\t * Load all modules.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"module\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"modules\"))): Promise<this> {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst moduleFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\tfile =>\n\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t);\n\n\t\t\tfor (const file of moduleFiles) {\n\t\t\t\tconst moduleEvent = await this.importFile<Module>(join(fullPath, file));\n\t\t\t\tif (!moduleEvent || !moduleEvent.events) continue;\n\n\t\t\t\tthis.items.set(moduleEvent.name, moduleEvent);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Bind all loaded modules to their client event respectively.\n\t *\n\t * @param {TriviousClient} client\n\t */\n\tbind(client: TriviousClient) {\n\t\tfor (const mod of this.items.values()) {\n\t\t\tfor (const [eventName, handler] of Object.entries(mod.events!)) {\n\t\t\t\tif (typeof handler !== \"function\") continue;\n\n\t\t\t\tconst listener = (...args: unknown[]) => {\n\t\t\t\t\tvoid (handler as (client: TriviousClient, ...args: unknown[]) => any)(client, ...args);\n\t\t\t\t};\n\n\t\t\t\t(client.on as any)(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveUserPath, exists } from '../../shared/utility/functions.js';
|
|
3
3
|
import { BaseRegistry } from '../../shared/typings/index.js';
|
|
4
4
|
import { promises } from 'fs';
|
|
5
|
-
import { join } from 'node:path';
|
|
5
|
+
import path, { join } from 'node:path';
|
|
6
6
|
|
|
7
7
|
class ModuleRegistry extends BaseRegistry {
|
|
8
8
|
items = new Collection();
|
|
@@ -13,7 +13,7 @@ class ModuleRegistry extends BaseRegistry {
|
|
|
13
13
|
* @param {string} [directory=getCorePath({ coreDirectory: "module" })]
|
|
14
14
|
* @returns {Promise<this>}
|
|
15
15
|
*/
|
|
16
|
-
async load(directory =
|
|
16
|
+
async load(directory = resolveUserPath(path.join("src", "modules"))) {
|
|
17
17
|
if (!await exists(directory)) {
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/registry/module.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,uBAAqC,YAAA,CAAqB;AAAA,EACtD,KAAA,GAAQ,IAAI,UAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjD,MAAM,KAAK,SAAA,GAAoB,
|
|
1
|
+
{"version":3,"sources":["../../../src/core/registry/module.registry.ts"],"names":["fs"],"mappings":";;;;;;AAeA,MAAO,uBAAqC,YAAA,CAAqB;AAAA,EACtD,KAAA,GAAQ,IAAI,UAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjD,MAAM,KAAK,SAAA,GAAoB,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,SAAS,CAAC,CAAA,EAAkB;AAC3F,IAAA,IAAI,CAAE,MAAM,MAAA,CAAO,SAAS,CAAA,EAAI;AAC/B,MAAA,OAAO,IAAA;AAAA,IACR;AAEA,IAAA,MAAM,OAAA,GAAU,MAAMA,QAAA,CAAG,OAAA,CAAQ,WAAW,EAAE,aAAA,EAAe,MAAM,CAAA;AAEnE,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC5B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,SAAA,EAAW,KAAA,C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{ Collection } from \"discord.js\";\nimport { exists, resolveUserPath } from \"src/shared/utility/functions.js\";\nimport { BaseRegistry, Module } from \"src/shared/typings/index.js\";\nimport { promises as fs } from \"fs\";\nimport path, { join } from \"node:path\";\nimport TriviousClient from \"../client/trivious.client.js\";\n\n/**\n * Registry to load, get and bind modules.\n *\n * @export\n * @class ModuleRegistry\n * @typedef {ModuleRegistry}\n * @extends {BaseRegistry<Module>}\n */\nexport default class ModuleRegistry extends BaseRegistry<Module> {\n\tprotected items = new Collection<string, Module>();\n\n\t/**\n\t * Load all modules.\n\t *\n\t * @async\n\t * @param {string} [directory=getCorePath({ coreDirectory: \"module\" })]\n\t * @returns {Promise<this>}\n\t */\n\tasync load(directory: string = resolveUserPath(path.join(\"src\", \"modules\"))): Promise<this> {\n\t\tif (!(await exists(directory))) {\n\t\t\treturn this;\n\t\t}\n\n\t\tconst entries = await fs.readdir(directory, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(directory, entry.name);\n\t\t\tif (!entry.isDirectory()) continue;\n\n\t\t\tconst moduleFiles = (await fs.readdir(fullPath)).filter(\n\t\t\t\tfile =>\n\t\t\t\t\t(file.endsWith(\".ts\") || file.endsWith(\".js\")) &&\n\t\t\t\t\t!file.startsWith(\"index.\") &&\n\t\t\t\t\t!file.endsWith(\".d.ts\")\n\t\t\t);\n\n\t\t\tfor (const file of moduleFiles) {\n\t\t\t\tconst moduleEvent = await this.importFile<Module>(join(fullPath, file));\n\t\t\t\tif (!moduleEvent || !moduleEvent.events) continue;\n\n\t\t\t\tthis.items.set(moduleEvent.name, moduleEvent);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Bind all loaded modules to their client event respectively.\n\t *\n\t * @param {TriviousClient} client\n\t */\n\tbind(client: TriviousClient) {\n\t\tfor (const mod of this.items.values()) {\n\t\t\tfor (const [eventName, handler] of Object.entries(mod.events!)) {\n\t\t\t\tif (typeof handler !== \"function\") continue;\n\n\t\t\t\tconst listener = (...args: unknown[]) => {\n\t\t\t\t\tvoid (handler as (client: TriviousClient, ...args: unknown[]) => any)(client, ...args);\n\t\t\t\t};\n\n\t\t\t\t(client.on as any)(eventName, listener);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -609,6 +609,19 @@ interface TriviousClientOptions extends ClientOptions {
|
|
|
609
609
|
* @type {string[]}
|
|
610
610
|
*/
|
|
611
611
|
botOwnerIds?: string[];
|
|
612
|
+
/**
|
|
613
|
+
* Configuration for auto-command deployment based on hashes
|
|
614
|
+
* i.e. commands are only deployed if changes to the builders are detected.
|
|
615
|
+
*
|
|
616
|
+
* @type {{
|
|
617
|
+
* enabled: boolean;
|
|
618
|
+
* filePath: string;
|
|
619
|
+
* }}
|
|
620
|
+
*/
|
|
621
|
+
commandHashConfig: {
|
|
622
|
+
enabled: boolean;
|
|
623
|
+
filePath: string;
|
|
624
|
+
};
|
|
612
625
|
}
|
|
613
626
|
|
|
614
627
|
/**
|
|
@@ -712,7 +725,7 @@ declare class EventRegistry extends BaseRegistry<Event> {
|
|
|
712
725
|
* @protected
|
|
713
726
|
* @returns {Promise<this>}
|
|
714
727
|
*/
|
|
715
|
-
protected loadPresetEvents(): Promise<this>;
|
|
728
|
+
protected loadPresetEvents(): Promise<this | undefined>;
|
|
716
729
|
/**
|
|
717
730
|
* Load all events.
|
|
718
731
|
*
|
|
@@ -609,6 +609,19 @@ interface TriviousClientOptions extends ClientOptions {
|
|
|
609
609
|
* @type {string[]}
|
|
610
610
|
*/
|
|
611
611
|
botOwnerIds?: string[];
|
|
612
|
+
/**
|
|
613
|
+
* Configuration for auto-command deployment based on hashes
|
|
614
|
+
* i.e. commands are only deployed if changes to the builders are detected.
|
|
615
|
+
*
|
|
616
|
+
* @type {{
|
|
617
|
+
* enabled: boolean;
|
|
618
|
+
* filePath: string;
|
|
619
|
+
* }}
|
|
620
|
+
*/
|
|
621
|
+
commandHashConfig: {
|
|
622
|
+
enabled: boolean;
|
|
623
|
+
filePath: string;
|
|
624
|
+
};
|
|
612
625
|
}
|
|
613
626
|
|
|
614
627
|
/**
|
|
@@ -712,7 +725,7 @@ declare class EventRegistry extends BaseRegistry<Event> {
|
|
|
712
725
|
* @protected
|
|
713
726
|
* @returns {Promise<this>}
|
|
714
727
|
*/
|
|
715
|
-
protected loadPresetEvents(): Promise<this>;
|
|
728
|
+
protected loadPresetEvents(): Promise<this | undefined>;
|
|
716
729
|
/**
|
|
717
730
|
* Load all events.
|
|
718
731
|
*
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-
|
|
2
|
+
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-SutqlRMo.cjs';
|
|
3
3
|
export { BaseRegistry } from './shared/typings/registry.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-
|
|
2
|
+
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-D5NcshUu.js';
|
|
3
3
|
export { BaseRegistry } from './shared/typings/registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-SutqlRMo.cjs';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import './registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-D5NcshUu.js';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import './registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-
|
|
2
|
+
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-SutqlRMo.cjs';
|
|
3
3
|
import './registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-
|
|
2
|
+
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-D5NcshUu.js';
|
|
3
3
|
import './registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-SutqlRMo.cjs';
|
|
2
2
|
export { BaseRegistry } from './registry.cjs';
|
|
3
3
|
import 'discord.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-D5NcshUu.js';
|
|
2
2
|
export { BaseRegistry } from './registry.js';
|
|
3
3
|
import 'discord.js';
|
|
@@ -25,16 +25,16 @@ function getCorePath(options) {
|
|
|
25
25
|
if (userPath) {
|
|
26
26
|
return resolveUserPath(userPath);
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
node_path.join(FRAMEWORK_PACKAGE_ROOT, "
|
|
30
|
-
node_path.join(FRAMEWORK_PACKAGE_ROOT, "
|
|
28
|
+
const candidates = [
|
|
29
|
+
node_path.join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory),
|
|
30
|
+
node_path.join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory)
|
|
31
31
|
];
|
|
32
|
-
for (const candidate of
|
|
32
|
+
for (const candidate of candidates) {
|
|
33
33
|
if (fs.existsSync(candidate)) {
|
|
34
34
|
return candidate;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return void 0;
|
|
38
38
|
}
|
|
39
39
|
function resolveUserPath(relativePath) {
|
|
40
40
|
const candidates = [
|
|
@@ -70,11 +70,19 @@ function hasPermission(client, options) {
|
|
|
70
70
|
}
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
|
+
async function hashCommands(commands) {
|
|
74
|
+
const json = JSON.stringify(commands.sort((a, b) => a.name.localeCompare(b.name)));
|
|
75
|
+
const encoder = new TextEncoder();
|
|
76
|
+
const data = encoder.encode(json);
|
|
77
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
78
|
+
return Buffer.from(hashBuffer).toString("hex");
|
|
79
|
+
}
|
|
73
80
|
|
|
74
81
|
exports.FRAMEWORK_PACKAGE_ROOT = FRAMEWORK_PACKAGE_ROOT;
|
|
75
82
|
exports.exists = exists;
|
|
76
83
|
exports.getCorePath = getCorePath;
|
|
77
84
|
exports.hasPermission = hasPermission;
|
|
85
|
+
exports.hashCommands = hashCommands;
|
|
78
86
|
exports.resolveUserPath = resolveUserPath;
|
|
79
87
|
//# sourceMappingURL=functions.cjs.map
|
|
80
88
|
//# sourceMappingURL=functions.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shared/utility/functions.ts"],"names":["__filename","fileURLToPath","__dirname","dirname","existsSync","join","resolve","fs","PermissionLevel","getPermissionLevel"],"mappings":";;;;;;;;;AAQA,MAAMA,YAAA,GAAaC,iBAAA,CAAc,+PAAe,CAAA;AAChD,MAAMC,WAAA,GAAYC,aAAQH,YAAU,CAAA;AAOpC,MAAM,iBAAiB,MAAc;AACpC,EAAA,IAAI,GAAA,GAAME,WAAA;AAEV,EAAA,OAAO,GAAA,KAAQC,YAAA,CAAQ,GAAG,CAAA,EAAG;AAC5B,IAAA,IAAIC,aAAA,CAAWC,cAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,IAAKD,aAAA,CAAWC,cAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,EAAG;AACnF,MAAA,OAAO,GAAA;AAAA,IACR;AACA,IAAA,GAAA,GAAMF,aAAQ,GAAG,CAAA;AAAA,EAClB;AACA,EAAA,OAAOD,WAAA;AACR,CAAA;AAOO,MAAM,yBAAyB,cAAA;AAS/B,SAAS,YAAY,OAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/utility/functions.ts"],"names":["__filename","fileURLToPath","__dirname","dirname","existsSync","join","resolve","fs","PermissionLevel","getPermissionLevel"],"mappings":";;;;;;;;;AAQA,MAAMA,YAAA,GAAaC,iBAAA,CAAc,+PAAe,CAAA;AAChD,MAAMC,WAAA,GAAYC,aAAQH,YAAU,CAAA;AAOpC,MAAM,iBAAiB,MAAc;AACpC,EAAA,IAAI,GAAA,GAAME,WAAA;AAEV,EAAA,OAAO,GAAA,KAAQC,YAAA,CAAQ,GAAG,CAAA,EAAG;AAC5B,IAAA,IAAIC,aAAA,CAAWC,cAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,IAAKD,aAAA,CAAWC,cAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,EAAG;AACnF,MAAA,OAAO,GAAA;AAAA,IACR;AACA,IAAA,GAAA,GAAMF,aAAQ,GAAG,CAAA;AAAA,EAClB;AACA,EAAA,OAAOD,WAAA;AACR,CAAA;AAOO,MAAM,yBAAyB,cAAA;AAS/B,SAAS,YAAY,OAAA,EAGL;AACtB,EAAA,MAAM,EAAE,QAAA,EAAU,aAAA,EAAc,GAAI,OAAA;AACpC,EAAA,IAAI,QAAA,EAAU;AACb,IAAA,OAAO,gBAAgB,QAAQ,CAAA;AAAA,EAChC;AAEA,EAAA,MAAM,UAAA,GAAa;AAAA,IAClBG,cAAA,CAAK,sBAAA,EAAwB,MAAA,EAAQ,aAAa,CAAA;AAAA,IAClDA,cAAA,CAAK,sBAAA,EAAwB,KAAA,EAAO,aAAa;AAAA,GAClD;AAEA,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AACnC,IAAA,IAAID,aAAA,CAAW,SAAS,CAAA,EAAG;AAC1B,MAAA,OAAO,SAAA;AAAA,IACR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AAE,CAAA,GAC5C,MAAA,GACC,OAAO,QAAA,CAAS,WAAA,CAAY,QAAA,CAAS,MAAA,CAAO,EAAE,CAAA,GAC9C,KAAA;AAGL,EAAA,IAAI,MAAM,OAAO,IAAA;AAGjB,EAAA,IAAI,MAAA,EAAQ;AACX,IAAA,MAAM,gBAAA,GAAmBC,iCAAA,CAAmB,MAAA,EAAQ,MAAM,CAAA;AAC1D,IAAA,OAAO,gBAAA,IAAoB,UAAA;AAAA,EAC5B;AAEA,EAAA,OAAO,KAAA;AACR;AAEA,eAAsB,aAAa,QAAA,EAAoD;AACtF,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,KAAK,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,IAAA,CAAK,aAAA,CAAc,CAAA,CAAE,IAAI,CAAC,CAAC,CAAA;AAEjF,EAAA,MAAM,OAAA,GAAU,IAAI,WAAA,EAAY;AAChC,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA;AAChC,EAAA,MAAM,aAAa,MAAM,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,WAAW,IAAI,CAAA;AAE7D,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,UAAU,CAAA,CAAE,SAAS,KAAK,CAAA;AAC9C","file":"functions.cjs","sourcesContent":["import TriviousClient from \"src/core/client/trivious.client.js\";\nimport { promises as fs, existsSync } from \"fs\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"url\";\nimport { dirname } from \"path\";\nimport { getPermissionLevel, PermissionLevel } from \"../typings/permissions.js\";\nimport { GuildMember, RESTPostAPIApplicationCommandsJSONBody, User } from \"discord.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Get the package root.\n *\n * @returns {string}\n */\nconst getPackageRoot = (): string => {\n\tlet dir = __dirname;\n\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\")) || existsSync(join(dir, \"node_modules\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\treturn __dirname;\n};\n\n/**\n * Framework package root.\n *\n * @type {string}\n */\nexport const FRAMEWORK_PACKAGE_ROOT = getPackageRoot();\n\n/**\n * Get the core path.\n *\n * @export\n * @param {{ userPath?: string; coreDirectory: string }} options\n * @returns {string}\n */\nexport function getCorePath(options: {\n\tuserPath?: string;\n\tcoreDirectory: string;\n}): string | undefined {\n\tconst { userPath, coreDirectory } = options;\n\tif (userPath) {\n\t\treturn resolveUserPath(userPath);\n\t}\n\n\tconst candidates = [\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"dist\", coreDirectory),\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"lib\", coreDirectory),\n\t];\n\n\tfor (const candidate of candidates) {\n\t\tif (existsSync(candidate)) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Resolve a user given core path.\n *\n * @export\n * @param {string} relativePath\n * @returns {string}\n */\nexport function resolveUserPath(relativePath: string): string {\n\tconst candidates = [\n\t\tjoin(process.cwd(), relativePath),\n\n\t\tjoin(process.cwd(), \"lib\", relativePath),\n\t\tjoin(process.cwd(), \"dist\", relativePath),\n\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, relativePath),\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"lib\", relativePath),\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"dist\", relativePath),\n\t];\n\n\tfor (const candidate of candidates) {\n\t\tconst full = resolve(candidate);\n\t\tif (existsSync(full)) return full;\n\t}\n\n\treturn join(process.cwd(), relativePath);\n}\n\n/**\n * Whether a directory or file exists.\n *\n * @export\n * @async\n * @param {string} path\n * @returns {unknown}\n */\nexport async function exists(path: string) {\n\ttry {\n\t\tawait fs.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Whether a user/member has permission.\n *\n * @export\n * @param {{\n * \tpermission: PermissionLevel;\n * \tuser?: User;\n * \tmember?: GuildMember;\n * }} options\n * @returns {boolean}\n */\nexport function hasPermission(\n\tclient: TriviousClient,\n\toptions: {\n\t\tpermission: PermissionLevel;\n\t\tuser?: User;\n\t\tmember?: GuildMember;\n\t}\n) {\n\tconst { permission, user, member } = options;\n\n\t// Bot owner check\n\tif (permission === PermissionLevel.BOT_OWNER && client._options.botOwnerIds)\n\t\treturn user\n\t\t\t? client._options.botOwnerIds.includes(user.id)\n\t\t\t: member\n\t\t\t\t? client._options.botOwnerIds.includes(member.id)\n\t\t\t\t: false;\n\n\t// Outside of a guild\n\tif (user) return true;\n\n\t// Inside a guild\n\tif (member) {\n\t\tconst memberPermission = getPermissionLevel(client, member);\n\t\treturn memberPermission >= permission;\n\t}\n\n\treturn false;\n}\n\nexport async function hashCommands(commands: RESTPostAPIApplicationCommandsJSONBody[]) {\n\tconst json = JSON.stringify(commands.sort((a, b) => a.name.localeCompare(b.name)));\n\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(json);\n\tconst hashBuffer = await crypto.subtle.digest(\"SHA-256\", data);\n\n\treturn Buffer.from(hashBuffer).toString(\"hex\");\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
2
|
-
import { User, GuildMember } from 'discord.js';
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-SutqlRMo.cjs';
|
|
2
|
+
import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
|
|
3
3
|
import '../typings/registry.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -18,7 +18,7 @@ declare const FRAMEWORK_PACKAGE_ROOT: string;
|
|
|
18
18
|
declare function getCorePath(options: {
|
|
19
19
|
userPath?: string;
|
|
20
20
|
coreDirectory: string;
|
|
21
|
-
}): string;
|
|
21
|
+
}): string | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* Resolve a user given core path.
|
|
24
24
|
*
|
|
@@ -52,5 +52,6 @@ declare function hasPermission(client: TriviousClient, options: {
|
|
|
52
52
|
user?: User;
|
|
53
53
|
member?: GuildMember;
|
|
54
54
|
}): boolean;
|
|
55
|
+
declare function hashCommands(commands: RESTPostAPIApplicationCommandsJSONBody[]): Promise<string>;
|
|
55
56
|
|
|
56
|
-
export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, resolveUserPath };
|
|
57
|
+
export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, hashCommands, resolveUserPath };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
2
|
-
import { User, GuildMember } from 'discord.js';
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-D5NcshUu.js';
|
|
2
|
+
import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
|
|
3
3
|
import '../typings/registry.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -18,7 +18,7 @@ declare const FRAMEWORK_PACKAGE_ROOT: string;
|
|
|
18
18
|
declare function getCorePath(options: {
|
|
19
19
|
userPath?: string;
|
|
20
20
|
coreDirectory: string;
|
|
21
|
-
}): string;
|
|
21
|
+
}): string | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* Resolve a user given core path.
|
|
24
24
|
*
|
|
@@ -52,5 +52,6 @@ declare function hasPermission(client: TriviousClient, options: {
|
|
|
52
52
|
user?: User;
|
|
53
53
|
member?: GuildMember;
|
|
54
54
|
}): boolean;
|
|
55
|
+
declare function hashCommands(commands: RESTPostAPIApplicationCommandsJSONBody[]): Promise<string>;
|
|
55
56
|
|
|
56
|
-
export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, resolveUserPath };
|
|
57
|
+
export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, hashCommands, resolveUserPath };
|
|
@@ -22,16 +22,16 @@ function getCorePath(options) {
|
|
|
22
22
|
if (userPath) {
|
|
23
23
|
return resolveUserPath(userPath);
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
join(FRAMEWORK_PACKAGE_ROOT, "
|
|
27
|
-
join(FRAMEWORK_PACKAGE_ROOT, "
|
|
25
|
+
const candidates = [
|
|
26
|
+
join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory),
|
|
27
|
+
join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory)
|
|
28
28
|
];
|
|
29
|
-
for (const candidate of
|
|
29
|
+
for (const candidate of candidates) {
|
|
30
30
|
if (existsSync(candidate)) {
|
|
31
31
|
return candidate;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return void 0;
|
|
35
35
|
}
|
|
36
36
|
function resolveUserPath(relativePath) {
|
|
37
37
|
const candidates = [
|
|
@@ -67,7 +67,14 @@ function hasPermission(client, options) {
|
|
|
67
67
|
}
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
|
+
async function hashCommands(commands) {
|
|
71
|
+
const json = JSON.stringify(commands.sort((a, b) => a.name.localeCompare(b.name)));
|
|
72
|
+
const encoder = new TextEncoder();
|
|
73
|
+
const data = encoder.encode(json);
|
|
74
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
75
|
+
return Buffer.from(hashBuffer).toString("hex");
|
|
76
|
+
}
|
|
70
77
|
|
|
71
|
-
export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, resolveUserPath };
|
|
78
|
+
export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, hashCommands, resolveUserPath };
|
|
72
79
|
//# sourceMappingURL=functions.js.map
|
|
73
80
|
//# sourceMappingURL=functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shared/utility/functions.ts"],"names":["__filename","__dirname","fs"],"mappings":";;;;;;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ent":["import TriviousClient from \"src/core/client/trivious.client.js\";\nimport { promises as fs, existsSync } from \"fs\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"url\";\nimport { dirname } from \"path\";\nimport { getPermissionLevel, PermissionLevel } from \"../typings/permissions.js\";\nimport { GuildMember, RESTPostAPIApplicationCommandsJSONBody, User } from \"discord.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Get the package root.\n *\n * @returns {string}\n */\nconst getPackageRoot = (): string => {\n\tlet dir = __dirname;\n\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\")) || existsSync(join(dir, \"node_modules\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\treturn __dirname;\n};\n\n/**\n * Framework package root.\n *\n * @type {string}\n */\nexport const FRAMEWORK_PACKAGE_ROOT = getPackageRoot();\n\n/**\n * Get the core path.\n *\n * @export\n * @param {{ userPath?: string; coreDirectory: string }} options\n * @returns {string}\n */\nexport function getCorePath(options: {\n\tuserPath?: string;\n\tcoreDirectory: string;\n}): string | undefined {\n\tconst { userPath, coreDirectory } = options;\n\tif (userPath) {\n\t\treturn resolveUserPath(userPath);\n\t}\n\n\tconst candidates = [\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"dist\", coreDirectory),\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"lib\", coreDirectory),\n\t];\n\n\tfor (const candidate of candidates) {\n\t\tif (existsSync(candidate)) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Resolve a user given core path.\n *\n * @export\n * @param {string} relativePath\n * @returns {string}\n */\nexport function resolveUserPath(relativePath: string): string {\n\tconst candidates = [\n\t\tjoin(process.cwd(), relativePath),\n\n\t\tjoin(process.cwd(), \"lib\", relativePath),\n\t\tjoin(process.cwd(), \"dist\", relativePath),\n\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, relativePath),\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"lib\", relativePath),\n\t\tjoin(FRAMEWORK_PACKAGE_ROOT, \"dist\", relativePath),\n\t];\n\n\tfor (const candidate of candidates) {\n\t\tconst full = resolve(candidate);\n\t\tif (existsSync(full)) return full;\n\t}\n\n\treturn join(process.cwd(), relativePath);\n}\n\n/**\n * Whether a directory or file exists.\n *\n * @export\n * @async\n * @param {string} path\n * @returns {unknown}\n */\nexport async function exists(path: string) {\n\ttry {\n\t\tawait fs.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Whether a user/member has permission.\n *\n * @export\n * @param {{\n * \tpermission: PermissionLevel;\n * \tuser?: User;\n * \tmember?: GuildMember;\n * }} options\n * @returns {boolean}\n */\nexport function hasPermission(\n\tclient: TriviousClient,\n\toptions: {\n\t\tpermission: PermissionLevel;\n\t\tuser?: User;\n\t\tmember?: GuildMember;\n\t}\n) {\n\tconst { permission, user, member } = options;\n\n\t// Bot owner check\n\tif (permission === PermissionLevel.BOT_OWNER && client._options.botOwnerIds)\n\t\treturn user\n\t\t\t? client._options.botOwnerIds.includes(user.id)\n\t\t\t: member\n\t\t\t\t? client._options.botOwnerIds.includes(member.id)\n\t\t\t\t: false;\n\n\t// Outside of a guild\n\tif (user) return true;\n\n\t// Inside a guild\n\tif (member) {\n\t\tconst memberPermission = getPermissionLevel(client, member);\n\t\treturn memberPermission >= permission;\n\t}\n\n\treturn false;\n}\n\nexport async function hashCommands(commands: RESTPostAPIApplicationCommandsJSONBody[]) {\n\tconst json = JSON.stringify(commands.sort((a, b) => a.name.localeCompare(b.name)));\n\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(json);\n\tconst hashBuffer = await crypto.subtle.digest(\"SHA-256\", data);\n\n\treturn Buffer.from(hashBuffer).toString(\"hex\");\n}\n"]}
|