trivious 1.3.25 → 1.3.26
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.d.cts +1 -1
- package/dist/core/client/trivious.client.d.ts +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-5IsAwOsi.d.ts} +1 -1
- package/dist/{index-BYTZLXk8.d.cts → index-BjPKCNAw.d.cts} +1 -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 +5 -5
- package/dist/shared/utility/functions.cjs.map +1 -1
- package/dist/shared/utility/functions.d.cts +2 -2
- package/dist/shared/utility/functions.d.ts +2 -2
- package/dist/shared/utility/functions.js +5 -5
- package/dist/shared/utility/functions.js.map +1 -1
- package/package.json +1 -1
|
@@ -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-BjPKCNAw.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-5IsAwOsi.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,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,SAAA,GAAYA,SAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AAC3C,MAAA,MAAM,OAAA,GAAUA,SAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AAEzC,M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,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;AAA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IAAI,OAAA,CAAQ,gBAAe,EAAG;AAC7B,QAAA,MAAM,eAAA,GAAA,CAAmB,MAAMA,QAAA,CAAG,OAAA,CAAQ,QAAQ,CAAA,EAAG,MAAA;AAAA,UACpD,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,SACxB;AAEA,QAAA,KAAA,MAAW,QAAQ,eAAA,EAAiB;AACnC,UAAA,MAAM,aAAa,MAAM,IAAA,CAAK,WAAuB,IAAA,CAAK,QAAA,EAAU,IAAI,CAAC,CAAA;AACzE,UAAA,IAAI,CAAC,UAAA,EAAY;AACjB,UAAA,IAAI,CAAC,UAAA,CAAW,IAAA,CAAK,IAAA,IAAQ,EAAE,WAAW,IAAA,YAAgB,6BAAA,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.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
|
+
{"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,eAAA,CAAgB,KAAK,IAAA,CAAK,KAAA,EAAO,YAAY,CAAC,CAAA,EAAkB;AAC9F,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,cAAA,GAAA,CAAkB,MAAMA,QAAA,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,WAAsB,IAAA,CAAK,QAAA,EAAU,IAAI,CAAC,CAAA;AACvE,QAAA,IAAI,CAAC,SAAA,EAAW;AAEhB,QAAA,MAAM,EAAE,IAAA,EAAK,GAAI,mBAAA,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.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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EAAS;AAC5B,MAAA,MAAM,QAAA,GAAWC,SAAA,CAAK,SAAA,EAAW,KAAA,CAAM,IAAI,CAAA;AAE3C,MAAA,IAAI,KAAA,CAAM,aAAY,EAAG;AACxB,QAAA,MAAM,IAAA,CAAK,KAAK,QAAQ,CAAA;AACxB,QAAA;AAAA,MACD;AAEA,MAAA,IAAI,MAAM,MAAA,EAAO,IAAK,MAAM,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,EAAG;AACjD,QAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,UAAA,CAAkB,QAAQ,CAAA;AACnD,QAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,QAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,KAAA,CAAM,IAAA,EAAM,KAAK,CAAA;AAAA,MACjC;AAAA,IACD;AAEA,IAAA,MAAM,KAAK,gBAAA,EAAiB;AAC5B,IAAA,OAAO,IAAA;AAAA,EACR;AAAA;AAAA;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.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":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AA,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-BjPKCNAw.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-5IsAwOsi.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","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A,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,CAAM,IAAI,CAAA;AAC3C,MAAA,IAAI,CAAC,KAAA,CAAM,WAAA,EAAY,EAAG;AAE1B,MAAA,MAAM,WAAA,GAAA,CAAe,MAAMA,QAAA,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,WAAmB,IAAA,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.js","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"]}
|
|
@@ -712,7 +712,7 @@ declare class EventRegistry extends BaseRegistry<Event> {
|
|
|
712
712
|
* @protected
|
|
713
713
|
* @returns {Promise<this>}
|
|
714
714
|
*/
|
|
715
|
-
protected loadPresetEvents(): Promise<this>;
|
|
715
|
+
protected loadPresetEvents(): Promise<this | undefined>;
|
|
716
716
|
/**
|
|
717
717
|
* Load all events.
|
|
718
718
|
*
|
|
@@ -712,7 +712,7 @@ declare class EventRegistry extends BaseRegistry<Event> {
|
|
|
712
712
|
* @protected
|
|
713
713
|
* @returns {Promise<this>}
|
|
714
714
|
*/
|
|
715
|
-
protected loadPresetEvents(): Promise<this>;
|
|
715
|
+
protected loadPresetEvents(): Promise<this | undefined>;
|
|
716
716
|
/**
|
|
717
717
|
* Load all events.
|
|
718
718
|
*
|
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-BjPKCNAw.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-5IsAwOsi.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-BjPKCNAw.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-5IsAwOsi.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-BjPKCNAw.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-5IsAwOsi.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-BjPKCNAw.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-5IsAwOsi.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 = [
|
|
@@ -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,CA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kBAAQ,SAAS,CAAA;AAC9B,IAAA,IAAIF,aAAA,CAAW,IAAI,CAAA,EAAG,OAAO,IAAA;AAAA,EAC9B;AAEA,EAAA,OAAOC,cAAA,CAAK,OAAA,CAAQ,GAAA,EAAI,EAAG,YAAY,CAAA;AACxC;AAUA,eAAsB,OAAO,IAAA,EAAc;AAC1C,EAAA,IAAI;AACH,IAAA,MAAME,WAAA,CAAG,OAAO,IAAI,CAAA;AACpB,IAAA,OAAO,IAAA;AAAA,EACR,CAAA,CAAA,MAAQ;AACP,IAAA,OAAO,KAAA;AAAA,EACR;AACD;AAaO,SAAS,aAAA,CACf,QACA,OAAA,EAKC;AACD,EAAA,MAAM,EAAE,UAAA,EAAY,IAAA,EAAM,MAAA,EAAO,GAAI,OAAA;AAGrC,EAAA,IAAI,UAAA,KAAeC,8BAAA,CAAgB,SAAA,IAAa,MAAA,CAAO,QAAA,CAAS,WAAA;AAC/D,IAAA,OAAO,IAAA,GACJ,MAAA,CAAO,QAAA,CAAS,WAAA,CAAY,SAAS,IAAA,CAAK,EAAE,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","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, 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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-BjPKCNAw.cjs';
|
|
2
2
|
import { User, GuildMember } from 'discord.js';
|
|
3
3
|
import '../typings/registry.cjs';
|
|
4
4
|
|
|
@@ -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
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-5IsAwOsi.js';
|
|
2
2
|
import { User, GuildMember } from 'discord.js';
|
|
3
3
|
import '../typings/registry.js';
|
|
4
4
|
|
|
@@ -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
|
*
|
|
@@ -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 = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shared/utility/functions.ts"],"names":["__filename","__dirname","fs"],"mappings":";;;;;;AAQA,MAAMA,YAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAChD,MAAMC,WAAA,GAAY,QAAQD,YAAU,CAAA;AAOpC,MAAM,iBAAiB,MAAc;AACpC,EAAA,IAAI,GAAA,GAAMC,WAAA;AAEV,EAAA,OAAO,GAAA,KAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG;A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Ae,eAAA,CAAgB,SAAA,IAAa,MAAA,CAAO,QAAA,CAAS,WAAA;AAC/D,IAAA,OAAO,IAAA,GACJ,MAAA,CAAO,QAAA,CAAS,WAAA,CAAY,SAAS,IAAA,CAAK,EAAE,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,GAAmB,kBAAA,CAAmB,MAAA,EAAQ,MAAM,CAAA;AAC1D,IAAA,OAAO,gBAAA,IAAoB,UAAA;AAAA,EAC5B;AAEA,EAAA,OAAO,KAAA;AACR","file":"functions.js","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, 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"]}
|