trivious 1.6.18 → 2.0.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.
Files changed (128) hide show
  1. package/README.md +53 -66
  2. package/dist/{core/builders/util.builders.d.ts → features/builders/utility.builders.d.ts} +0 -9
  3. package/dist/{core/builders/util.builders.js → features/builders/utility.builders.js} +2 -2
  4. package/dist/features/builders/utility.builders.js.map +1 -0
  5. package/dist/features/client/client.types.d.ts +85 -0
  6. package/dist/features/client/client.types.js +3 -0
  7. package/dist/{shared/typings/client.js.map → features/client/client.types.js.map} +1 -1
  8. package/dist/features/client/deploy.client.d.ts +7 -0
  9. package/dist/features/client/deploy.client.js +43 -0
  10. package/dist/features/client/deploy.client.js.map +1 -0
  11. package/dist/features/client/trivious.client.d.ts +3 -0
  12. package/dist/features/client/trivious.client.js +62 -0
  13. package/dist/features/client/trivious.client.js.map +1 -0
  14. package/dist/features/commands/commands.types.d.ts +3 -0
  15. package/dist/features/commands/commands.types.js +3 -0
  16. package/dist/{shared/typings/commands.js.map → features/commands/commands.types.js.map} +1 -1
  17. package/dist/features/commands/methods.commands.d.ts +13 -0
  18. package/dist/features/commands/methods.commands.js +70 -0
  19. package/dist/features/commands/methods.commands.js.map +1 -0
  20. package/dist/features/commands/registry.commands.d.ts +7 -0
  21. package/dist/features/commands/registry.commands.js +84 -0
  22. package/dist/features/commands/registry.commands.js.map +1 -0
  23. package/dist/features/components/components.types.d.ts +3 -0
  24. package/dist/features/components/components.types.js +10 -0
  25. package/dist/features/components/components.types.js.map +1 -0
  26. package/dist/features/components/registry.components.d.ts +7 -0
  27. package/dist/features/components/registry.components.js +23 -0
  28. package/dist/features/components/registry.components.js.map +1 -0
  29. package/dist/features/customId/customid.types.d.ts +13 -0
  30. package/dist/features/customId/customid.types.js +3 -0
  31. package/dist/features/customId/customid.types.js.map +1 -0
  32. package/dist/features/customId/methods.customid.d.ts +20 -0
  33. package/dist/features/customId/methods.customid.js +24 -0
  34. package/dist/features/customId/methods.customid.js.map +1 -0
  35. package/dist/features/events/events.types.d.ts +3 -0
  36. package/dist/features/events/events.types.js +3 -0
  37. package/dist/{shared/typings/events.js.map → features/events/events.types.js.map} +1 -1
  38. package/dist/features/events/presets/clientReady.d.ts +11 -0
  39. package/dist/{core/events → features/events/presets}/clientReady.js +1 -1
  40. package/dist/features/events/presets/clientReady.js.map +1 -0
  41. package/dist/features/events/presets/interactionCreate.d.ts +10 -0
  42. package/dist/features/events/presets/interactionCreate.js +49 -0
  43. package/dist/features/events/presets/interactionCreate.js.map +1 -0
  44. package/dist/features/events/registry.events.d.ts +8 -0
  45. package/dist/features/events/registry.events.js +45 -0
  46. package/dist/features/events/registry.events.js.map +1 -0
  47. package/dist/features/modules/modules.types.d.ts +3 -0
  48. package/dist/features/modules/modules.types.js +3 -0
  49. package/dist/{shared/typings/module.js.map → features/modules/modules.types.js.map} +1 -1
  50. package/dist/features/modules/registry.modules.d.ts +8 -0
  51. package/dist/features/modules/registry.modules.js +30 -0
  52. package/dist/features/modules/registry.modules.js.map +1 -0
  53. package/dist/features/structure/index.structure.d.ts +10 -0
  54. package/dist/features/structure/index.structure.js +51 -0
  55. package/dist/features/structure/index.structure.js.map +1 -0
  56. package/dist/index.d.ts +6 -5
  57. package/dist/index.js +4 -10
  58. package/dist/modules.types-Bn4HfuVk.d.ts +165 -0
  59. package/dist/shared/registries.d.ts +26 -0
  60. package/dist/shared/registries.js +25 -0
  61. package/dist/shared/registries.js.map +1 -0
  62. package/dist/shared/typings.d.ts +4 -0
  63. package/dist/shared/typings.js +9 -0
  64. package/dist/shared/typings.js.map +1 -0
  65. package/dist/utility/errors.d.ts +15 -0
  66. package/dist/utility/errors.js +24 -0
  67. package/dist/utility/errors.js.map +1 -0
  68. package/dist/utility/functions.d.ts +4 -0
  69. package/dist/utility/functions.js +32 -0
  70. package/dist/utility/functions.js.map +1 -0
  71. package/package.json +7 -3
  72. package/dist/core/builders/util.builders.js.map +0 -1
  73. package/dist/core/client/trivious.client.d.ts +0 -6
  74. package/dist/core/client/trivious.client.js +0 -115
  75. package/dist/core/client/trivious.client.js.map +0 -1
  76. package/dist/core/commands/methods.command.d.ts +0 -6
  77. package/dist/core/commands/methods.command.js +0 -90
  78. package/dist/core/commands/methods.command.js.map +0 -1
  79. package/dist/core/events/clientReady.d.ts +0 -14
  80. package/dist/core/events/clientReady.js.map +0 -1
  81. package/dist/core/events/interactionCreate.d.ts +0 -14
  82. package/dist/core/events/interactionCreate.js +0 -84
  83. package/dist/core/events/interactionCreate.js.map +0 -1
  84. package/dist/core/registry/command.registry.d.ts +0 -6
  85. package/dist/core/registry/command.registry.js +0 -54
  86. package/dist/core/registry/command.registry.js.map +0 -1
  87. package/dist/core/registry/component.registry.d.ts +0 -6
  88. package/dist/core/registry/component.registry.js +0 -41
  89. package/dist/core/registry/component.registry.js.map +0 -1
  90. package/dist/core/registry/event.registry.d.ts +0 -6
  91. package/dist/core/registry/event.registry.js +0 -71
  92. package/dist/core/registry/event.registry.js.map +0 -1
  93. package/dist/core/registry/index.d.ts +0 -22
  94. package/dist/core/registry/index.js +0 -39
  95. package/dist/core/registry/index.js.map +0 -1
  96. package/dist/core/registry/module.registry.d.ts +0 -6
  97. package/dist/core/registry/module.registry.js +0 -55
  98. package/dist/core/registry/module.registry.js.map +0 -1
  99. package/dist/index-DbWA_10I.d.ts +0 -439
  100. package/dist/shared/typings/client.d.ts +0 -74
  101. package/dist/shared/typings/client.js +0 -3
  102. package/dist/shared/typings/commands.d.ts +0 -6
  103. package/dist/shared/typings/commands.js +0 -3
  104. package/dist/shared/typings/components.d.ts +0 -6
  105. package/dist/shared/typings/components.js +0 -10
  106. package/dist/shared/typings/components.js.map +0 -1
  107. package/dist/shared/typings/events.d.ts +0 -6
  108. package/dist/shared/typings/events.js +0 -3
  109. package/dist/shared/typings/index.d.ts +0 -6
  110. package/dist/shared/typings/index.js +0 -9
  111. package/dist/shared/typings/index.js.map +0 -1
  112. package/dist/shared/typings/module.d.ts +0 -6
  113. package/dist/shared/typings/module.js +0 -3
  114. package/dist/shared/typings/permissions.d.ts +0 -16
  115. package/dist/shared/typings/permissions.js +0 -13
  116. package/dist/shared/typings/permissions.js.map +0 -1
  117. package/dist/shared/typings/registry.d.ts +0 -51
  118. package/dist/shared/typings/registry.js +0 -61
  119. package/dist/shared/typings/registry.js.map +0 -1
  120. package/dist/shared/utility/components.utility.d.ts +0 -6
  121. package/dist/shared/utility/components.utility.js +0 -17
  122. package/dist/shared/utility/components.utility.js.map +0 -1
  123. package/dist/shared/utility/functions.d.ts +0 -60
  124. package/dist/shared/utility/functions.js +0 -81
  125. package/dist/shared/utility/functions.js.map +0 -1
  126. package/dist/shared/utility/permissions.utility.d.ts +0 -6
  127. package/dist/shared/utility/permissions.utility.js +0 -12
  128. package/dist/shared/utility/permissions.utility.js.map +0 -1
@@ -1,61 +0,0 @@
1
- import { pathToFileURL } from 'url';
2
-
3
- class BaseRegistry {
4
- /**
5
- * Get all of loaded T
6
- *
7
- * @returns {Collection<string, T>}
8
- */
9
- get() {
10
- return this.items;
11
- }
12
- /**
13
- * Import a file from a path to be loaded.
14
- *
15
- * @protected
16
- * @async
17
- * @template T
18
- * @param {string} filePath
19
- * @returns {Promise<T | null>}
20
- */
21
- async importFile(filePath) {
22
- try {
23
- const { default: file } = await import(pathToFileURL(filePath).href);
24
- if (!file) return null;
25
- const imports = file.default || file;
26
- if (typeof imports === "function" && imports.prototype) {
27
- return new imports();
28
- }
29
- if (typeof imports === "object") {
30
- if (Object.keys(imports).length === 0) return null;
31
- return imports;
32
- }
33
- console.error(`Invalid export in ${filePath}: expected class or object`);
34
- return null;
35
- } catch (error) {
36
- console.error("Failed to import:", filePath, error);
37
- return null;
38
- }
39
- }
40
- /**
41
- * Clear file path cache.
42
- * Does not run in production environment.
43
- *
44
- * @protected
45
- * @async
46
- * @param {string} filePath
47
- * @returns {*}
48
- */
49
- async clearCache(filePath) {
50
- if (process.env.NODE_ENV === "production") return;
51
- try {
52
- const resvoled = require.resolve(filePath);
53
- delete require.cache[resvoled];
54
- } catch {
55
- }
56
- }
57
- }
58
-
59
- export { BaseRegistry };
60
- //# sourceMappingURL=registry.js.map
61
- //# sourceMappingURL=registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/shared/typings/registry.ts"],"names":[],"mappings":";;AAYO,MAAe,YAAA,CAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBrC,GAAA,GAAM;AACL,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAgB,WAAc,QAAA,EAAqC;AAClE,IAAA,IAAI;AACH,MAAA,MAAM,EAAE,SAAS,IAAA,EAAK,GAAI,MAAM,OAAO,aAAA,CAAc,QAAQ,CAAA,CAAE,IAAA,CAAA;AAC/D,MAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAElB,MAAA,MAAM,OAAA,GAAU,KAAK,OAAA,IAAW,IAAA;AAEhC,MAAA,IAAI,OAAO,OAAA,KAAY,UAAA,IAAc,OAAA,CAAQ,SAAA,EAAW;AACvD,QAAA,OAAO,IAAI,OAAA,EAAQ;AAAA,MACpB;AAEA,MAAA,IAAI,OAAO,YAAY,QAAA,EAAU;AAChC,QAAA,IAAI,OAAO,IAAA,CAAK,OAAO,CAAA,CAAE,MAAA,KAAW,GAAG,OAAO,IAAA;AAC9C,QAAA,OAAO,OAAA;AAAA,MACR;AAEA,MAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,kBAAA,EAAqB,QAAQ,CAAA,0BAAA,CAA4B,CAAA;AACvE,MAAA,OAAO,IAAA;AAAA,IACR,SAAS,KAAA,EAAY;AACpB,MAAA,OAAA,CAAQ,KAAA,CAAM,mBAAA,EAAqB,QAAA,EAAU,KAAK,CAAA;AAClD,MAAA,OAAO,IAAA;AAAA,IACR;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAgB,WAAW,QAAA,EAAkB;AAC5C,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AAC3C,IAAA,IAAI;AACH,MAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,OAAA,CAAQ,QAAQ,CAAA;AACzC,MAAA,OAAO,OAAA,CAAQ,MAAM,QAAQ,CAAA;AAAA,IAC9B,CAAA,CAAA,MAAQ;AAAA,IAAC;AAAA,EACV;AACD","file":"registry.js","sourcesContent":["import { Collection } from \"discord.js\";\nimport { pathToFileURL } from \"url\";\n\n/**\n * Base registry for loading, getting and binding core events and functions.\n *\n * @export\n * @abstract\n * @class BaseRegistry\n * @typedef {BaseRegistry}\n * @template T\n */\nexport abstract class BaseRegistry<T> {\n\tprotected abstract items: Collection<string, T>;\n\t/**\n\t * Load all of T\n\t *\n\t * @protected\n\t * @abstract\n\t * @param {string} directory\n\t * @returns {Promise<this>}\n\t */\n\tprotected abstract load(directory: string): Promise<this>;\n\n\t/**\n\t * Get all of loaded T\n\t *\n\t * @returns {Collection<string, T>}\n\t */\n\tget() {\n\t\treturn this.items;\n\t}\n\n\t/**\n\t * Import a file from a path to be loaded.\n\t *\n\t * @protected\n\t * @async\n\t * @template T\n\t * @param {string} filePath\n\t * @returns {Promise<T | null>}\n\t */\n\tprotected async importFile<T>(filePath: string): Promise<T | null> {\n\t\ttry {\n\t\t\tconst { default: file } = await import(pathToFileURL(filePath).href);\n\t\t\tif (!file) return null;\n\n\t\t\tconst imports = file.default || file;\n\n\t\t\tif (typeof imports === \"function\" && imports.prototype) {\n\t\t\t\treturn new imports();\n\t\t\t}\n\n\t\t\tif (typeof imports === \"object\") {\n\t\t\t\tif (Object.keys(imports).length === 0) return null;\n\t\t\t\treturn imports as T;\n\t\t\t}\n\n\t\t\tconsole.error(`Invalid export in ${filePath}: expected class or object`);\n\t\t\treturn null;\n\t\t} catch (error: any) {\n\t\t\tconsole.error(\"Failed to import:\", filePath, error);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Clear file path cache.\n\t * Does not run in production environment.\n\t *\n\t * @protected\n\t * @async\n\t * @param {string} filePath\n\t * @returns {*}\n\t */\n\tprotected async clearCache(filePath: string) {\n\t\tif (process.env.NODE_ENV === \"production\") return;\n\t\ttry {\n\t\t\tconst resvoled = require.resolve(filePath);\n\t\t\tdelete require.cache[resvoled];\n\t\t} catch {}\n\t}\n}\n"]}
@@ -1,6 +0,0 @@
1
- export { r as constructCustomId, q as deconstructCustomId } from '../../index-DbWA_10I.js';
2
- import '../typings/permissions.js';
3
- import '../typings/registry.js';
4
- import 'discord.js';
5
- import '../typings/client.js';
6
- import '../../core/builders/util.builders.js';
@@ -1,17 +0,0 @@
1
- const deconstructCustomId = (customId) => {
2
- const [componentType, dataTags] = customId.split(":");
3
- const [data, ...tags] = dataTags.split(".");
4
- return {
5
- compType: componentType,
6
- data,
7
- tags
8
- };
9
- };
10
- const constructCustomId = (options) => {
11
- const { data, compType, tags } = options;
12
- return `${compType}:${data}${tags ? `.${tags.join(".")}` : ""}`;
13
- };
14
-
15
- export { constructCustomId, deconstructCustomId };
16
- //# sourceMappingURL=components.utility.js.map
17
- //# sourceMappingURL=components.utility.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/shared/utility/components.utility.ts"],"names":[],"mappings":"AAYO,MAAM,mBAAA,GAAsB,CAAC,QAAA,KAAqB;AACxD,EAAA,MAAM,CAAC,aAAA,EAAe,QAAQ,CAAA,GAAI,QAAA,CAAS,MAAM,GAAG,CAAA;AACpD,EAAA,MAAM,CAAC,IAAA,EAAM,GAAG,IAAI,CAAA,GAAI,QAAA,CAAS,MAAM,GAAG,CAAA;AAE1C,EAAA,OAAO;AAAA,IACN,QAAA,EAAU,aAAA;AAAA,IACV,IAAA;AAAA,IACA;AAAA,GACD;AACD;AAQO,MAAM,iBAAA,GAAoB,CAAC,OAAA,KAAsC;AACvE,EAAA,MAAM,EAAE,IAAA,EAAM,QAAA,EAAU,IAAA,EAAK,GAAI,OAAA;AACjC,EAAA,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,IAAI,CAAA,EAAG,IAAA,GAAO,CAAA,CAAA,EAAI,IAAA,CAAK,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AAC9D","file":"components.utility.js","sourcesContent":["import {\n\tComponentCustomIdTag,\n\tComponentType,\n\tCustomIdConstructOptions,\n} from \"../typings/components.js\";\n\n/**\n * Deconstruct a component customId into its parts.\n *\n * @param {string} customId\n * @returns {CustomIdConstructOptions}\n */\nexport const deconstructCustomId = (customId: string) => {\n\tconst [componentType, dataTags] = customId.split(\":\") as [ComponentType, string];\n\tconst [data, ...tags] = dataTags.split(\".\") as [string, ...ComponentCustomIdTag[]];\n\n\treturn {\n\t\tcompType: componentType,\n\t\tdata,\n\t\ttags,\n\t} as CustomIdConstructOptions;\n};\n\n/**\n * Construct a component customId.\n *\n * @param {CustomIdConstructOptions} options\n * @returns {string}\n */\nexport const constructCustomId = (options: CustomIdConstructOptions) => {\n\tconst { data, compType, tags } = options;\n\treturn `${compType}:${data}${tags ? `.${tags.join(\".\")}` : \"\"}`;\n};\n"]}
@@ -1,60 +0,0 @@
1
- import { T as TriviousClient } from '../../index-DbWA_10I.js';
2
- import { PermissionLevel } from '../typings/permissions.js';
3
- import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
4
- import '../typings/registry.js';
5
- import '../typings/client.js';
6
- import '../../core/builders/util.builders.js';
7
-
8
- /**
9
- * Framework package root.
10
- *
11
- * @type {string}
12
- */
13
- declare const FRAMEWORK_PACKAGE_ROOT: string;
14
- /**
15
- * Get the core path.
16
- *
17
- * @export
18
- * @param {{ userPath?: string; coreDirectory: string }} options
19
- * @returns {string}
20
- */
21
- declare function getCorePath(options: {
22
- userPath?: string;
23
- coreDirectory: string;
24
- }): string | undefined;
25
- /**
26
- * Resolve a user given core path.
27
- *
28
- * @export
29
- * @param {string} relativePath
30
- * @returns {string}
31
- */
32
- declare function resolveUserPath(relativePath: string): string;
33
- /**
34
- * Whether a directory or file exists.
35
- *
36
- * @export
37
- * @async
38
- * @param {string} path
39
- * @returns {unknown}
40
- */
41
- declare function exists(path: string): Promise<boolean>;
42
- /**
43
- * Whether a user/member has permission.
44
- *
45
- * @export
46
- * @param {{
47
- * permission: PermissionLevel;
48
- * user?: User;
49
- * member?: GuildMember;
50
- * }} options
51
- * @returns {boolean}
52
- */
53
- declare function hasPermission(client: TriviousClient, options: {
54
- permission: PermissionLevel;
55
- user?: User;
56
- member?: GuildMember;
57
- }): boolean;
58
- declare function hashCommands(commands: RESTPostAPIApplicationCommandsJSONBody[]): Promise<string>;
59
-
60
- export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, hashCommands, resolveUserPath };
@@ -1,81 +0,0 @@
1
- import { existsSync, promises } from 'fs';
2
- import { join, resolve } from 'node:path';
3
- import { fileURLToPath } from 'url';
4
- import { dirname } from 'path';
5
- import { PermissionLevel } from '../typings/index.js';
6
- import { getPermissionLevel } from './permissions.utility.js';
7
-
8
- const __filename$1 = fileURLToPath(import.meta.url);
9
- const __dirname$1 = dirname(__filename$1);
10
- const getPackageRoot = () => {
11
- let dir = __dirname$1;
12
- while (dir !== dirname(dir)) {
13
- if (existsSync(join(dir, "package.json")) || existsSync(join(dir, "node_modules"))) {
14
- return dir;
15
- }
16
- dir = dirname(dir);
17
- }
18
- return __dirname$1;
19
- };
20
- const FRAMEWORK_PACKAGE_ROOT = getPackageRoot();
21
- function getCorePath(options) {
22
- const { userPath, coreDirectory } = options;
23
- if (userPath) {
24
- return resolveUserPath(userPath);
25
- }
26
- const candidates = [
27
- join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory),
28
- join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory)
29
- ];
30
- for (const candidate of candidates) {
31
- if (existsSync(candidate)) {
32
- return candidate;
33
- }
34
- }
35
- return void 0;
36
- }
37
- function resolveUserPath(relativePath) {
38
- const candidates = [
39
- join(process.cwd(), relativePath),
40
- join(process.cwd(), "lib", relativePath),
41
- join(process.cwd(), "dist", relativePath),
42
- join(FRAMEWORK_PACKAGE_ROOT, relativePath),
43
- join(FRAMEWORK_PACKAGE_ROOT, "lib", relativePath),
44
- join(FRAMEWORK_PACKAGE_ROOT, "dist", relativePath)
45
- ];
46
- for (const candidate of candidates) {
47
- const full = resolve(candidate);
48
- if (existsSync(full)) return full;
49
- }
50
- return join(process.cwd(), relativePath);
51
- }
52
- async function exists(path) {
53
- try {
54
- await promises.access(path);
55
- return true;
56
- } catch {
57
- return false;
58
- }
59
- }
60
- function hasPermission(client, options) {
61
- const { permission, user, member } = options;
62
- if (permission === PermissionLevel.BOT_OWNER && client._options.botOwnerIds)
63
- return user ? client._options.botOwnerIds.includes(user.id) : member ? client._options.botOwnerIds.includes(member.id) : false;
64
- if (user) return true;
65
- if (member) {
66
- const memberPermission = getPermissionLevel(client, member);
67
- return memberPermission >= permission;
68
- }
69
- return false;
70
- }
71
- async function hashCommands(commands) {
72
- const json = JSON.stringify(commands.sort((a, b) => a.name.localeCompare(b.name)));
73
- const encoder = new TextEncoder();
74
- const data = encoder.encode(json);
75
- const hashBuffer = await crypto.subtle.digest("SHA-256", data);
76
- return Buffer.from(hashBuffer).toString("hex");
77
- }
78
-
79
- export { FRAMEWORK_PACKAGE_ROOT, exists, getCorePath, hasPermission, hashCommands, resolveUserPath };
80
- //# sourceMappingURL=functions.js.map
81
- //# sourceMappingURL=functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/shared/utility/functions.ts"],"names":["__filename","__dirname","fs"],"mappings":";;;;;;;AASA,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,GAA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AAA,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.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 { PermissionLevel } from \"../typings/index.js\";\nimport { GuildMember, RESTPostAPIApplicationCommandsJSONBody, User } from \"discord.js\";\nimport { getPermissionLevel } from \"./permissions.utility.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,6 +0,0 @@
1
- import 'discord.js';
2
- import '../typings/permissions.js';
3
- export { s as getPermissionLevel } from '../../index-DbWA_10I.js';
4
- import '../typings/registry.js';
5
- import '../typings/client.js';
6
- import '../../core/builders/util.builders.js';
@@ -1,12 +0,0 @@
1
- import { PermissionLevel } from '../typings/index.js';
2
-
3
- const getPermissionLevel = (client, member) => {
4
- const highestRole = member.roles.highest;
5
- if (member.user.id === member.guild.ownerId) return PermissionLevel.GUILD_OWNER;
6
- const rolePermissions = client.rolePermissions;
7
- return rolePermissions[highestRole.name] ?? PermissionLevel.USER;
8
- };
9
-
10
- export { getPermissionLevel };
11
- //# sourceMappingURL=permissions.utility.js.map
12
- //# sourceMappingURL=permissions.utility.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/shared/utility/permissions.utility.ts"],"names":[],"mappings":";;AAUO,MAAM,kBAAA,GAAqB,CAAC,MAAA,EAAwB,MAAA,KAAwB;AAClF,EAAA,MAAM,WAAA,GAAc,OAAO,KAAA,CAAM,OAAA;AACjC,EAAA,IAAI,OAAO,IAAA,CAAK,EAAA,KAAO,OAAO,KAAA,CAAM,OAAA,SAAgB,eAAA,CAAgB,WAAA;AAEpE,EAAA,MAAM,kBAAkB,MAAA,CAAO,eAAA;AAC/B,EAAA,OAAO,eAAA,CAAgB,WAAA,CAAY,IAAI,CAAA,IAAK,eAAA,CAAgB,IAAA;AAC7D","file":"permissions.utility.js","sourcesContent":["import { GuildMember } from \"discord.js\";\nimport { PermissionLevel } from \"../typings/index.js\";\nimport TriviousClient from \"src/core/client/trivious.client.js\";\n\n/**\n * Get the permission level of a user.\n *\n * @param {GuildMember} member\n * @returns {*}\n */\nexport const getPermissionLevel = (client: TriviousClient, member: GuildMember) => {\n\tconst highestRole = member.roles.highest;\n\tif (member.user.id === member.guild.ownerId) return PermissionLevel.GUILD_OWNER;\n\n\tconst rolePermissions = client.rolePermissions;\n\treturn rolePermissions[highestRole.name] ?? PermissionLevel.USER;\n};\n"]}