trivious 1.3.20 → 1.3.22

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 (129) hide show
  1. package/dist/index.cjs +1445 -67
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +973 -3
  4. package/dist/index.d.ts +973 -3
  5. package/dist/index.js +1434 -10
  6. package/dist/index.js.map +1 -1
  7. package/package.json +3 -2
  8. package/dist/core/client/trivious.client.cjs +0 -90
  9. package/dist/core/client/trivious.client.cjs.map +0 -1
  10. package/dist/core/client/trivious.client.d.cts +0 -3
  11. package/dist/core/client/trivious.client.d.ts +0 -3
  12. package/dist/core/client/trivious.client.js +0 -88
  13. package/dist/core/client/trivious.client.js.map +0 -1
  14. package/dist/core/commands/command.base.cjs +0 -224
  15. package/dist/core/commands/command.base.cjs.map +0 -1
  16. package/dist/core/commands/command.base.d.cts +0 -3
  17. package/dist/core/commands/command.base.d.ts +0 -3
  18. package/dist/core/commands/command.base.js +0 -214
  19. package/dist/core/commands/command.base.js.map +0 -1
  20. package/dist/core/commands/contextcommand.base.cjs +0 -98
  21. package/dist/core/commands/contextcommand.base.cjs.map +0 -1
  22. package/dist/core/commands/contextcommand.base.d.cts +0 -3
  23. package/dist/core/commands/contextcommand.base.d.ts +0 -3
  24. package/dist/core/commands/contextcommand.base.js +0 -93
  25. package/dist/core/commands/contextcommand.base.js.map +0 -1
  26. package/dist/core/commands/subcommand.base.cjs +0 -96
  27. package/dist/core/commands/subcommand.base.cjs.map +0 -1
  28. package/dist/core/commands/subcommand.base.d.cts +0 -3
  29. package/dist/core/commands/subcommand.base.d.ts +0 -3
  30. package/dist/core/commands/subcommand.base.js +0 -91
  31. package/dist/core/commands/subcommand.base.js.map +0 -1
  32. package/dist/core/components/component.base.cjs +0 -111
  33. package/dist/core/components/component.base.cjs.map +0 -1
  34. package/dist/core/components/component.base.d.cts +0 -3
  35. package/dist/core/components/component.base.d.ts +0 -3
  36. package/dist/core/components/component.base.js +0 -106
  37. package/dist/core/components/component.base.js.map +0 -1
  38. package/dist/core/events/interactionCreate.cjs +0 -68
  39. package/dist/core/events/interactionCreate.cjs.map +0 -1
  40. package/dist/core/events/interactionCreate.d.cts +0 -10
  41. package/dist/core/events/interactionCreate.d.ts +0 -10
  42. package/dist/core/events/interactionCreate.js +0 -66
  43. package/dist/core/events/interactionCreate.js.map +0 -1
  44. package/dist/core/registry/command.registry.cjs +0 -56
  45. package/dist/core/registry/command.registry.cjs.map +0 -1
  46. package/dist/core/registry/command.registry.d.cts +0 -3
  47. package/dist/core/registry/command.registry.d.ts +0 -3
  48. package/dist/core/registry/command.registry.js +0 -54
  49. package/dist/core/registry/command.registry.js.map +0 -1
  50. package/dist/core/registry/component.registry.cjs +0 -42
  51. package/dist/core/registry/component.registry.cjs.map +0 -1
  52. package/dist/core/registry/component.registry.d.cts +0 -3
  53. package/dist/core/registry/component.registry.d.ts +0 -3
  54. package/dist/core/registry/component.registry.js +0 -40
  55. package/dist/core/registry/component.registry.js.map +0 -1
  56. package/dist/core/registry/event.registry.cjs +0 -57
  57. package/dist/core/registry/event.registry.cjs.map +0 -1
  58. package/dist/core/registry/event.registry.d.cts +0 -3
  59. package/dist/core/registry/event.registry.d.ts +0 -3
  60. package/dist/core/registry/event.registry.js +0 -51
  61. package/dist/core/registry/event.registry.js.map +0 -1
  62. package/dist/core/registry/index.cjs +0 -49
  63. package/dist/core/registry/index.cjs.map +0 -1
  64. package/dist/core/registry/index.d.cts +0 -19
  65. package/dist/core/registry/index.d.ts +0 -19
  66. package/dist/core/registry/index.js +0 -39
  67. package/dist/core/registry/index.js.map +0 -1
  68. package/dist/core/registry/module.registry.cjs +0 -57
  69. package/dist/core/registry/module.registry.cjs.map +0 -1
  70. package/dist/core/registry/module.registry.d.cts +0 -3
  71. package/dist/core/registry/module.registry.d.ts +0 -3
  72. package/dist/core/registry/module.registry.js +0 -55
  73. package/dist/core/registry/module.registry.js.map +0 -1
  74. package/dist/index-BPaYmWRO.d.ts +0 -927
  75. package/dist/index-CU2Xl9Xo.d.cts +0 -927
  76. package/dist/shared/typings/client.cjs +0 -4
  77. package/dist/shared/typings/client.cjs.map +0 -1
  78. package/dist/shared/typings/client.d.cts +0 -3
  79. package/dist/shared/typings/client.d.ts +0 -3
  80. package/dist/shared/typings/client.js +0 -3
  81. package/dist/shared/typings/client.js.map +0 -1
  82. package/dist/shared/typings/commands.cjs +0 -4
  83. package/dist/shared/typings/commands.cjs.map +0 -1
  84. package/dist/shared/typings/commands.d.cts +0 -3
  85. package/dist/shared/typings/commands.d.ts +0 -3
  86. package/dist/shared/typings/commands.js +0 -3
  87. package/dist/shared/typings/commands.js.map +0 -1
  88. package/dist/shared/typings/components.cjs +0 -22
  89. package/dist/shared/typings/components.cjs.map +0 -1
  90. package/dist/shared/typings/components.d.cts +0 -3
  91. package/dist/shared/typings/components.d.ts +0 -3
  92. package/dist/shared/typings/components.js +0 -19
  93. package/dist/shared/typings/components.js.map +0 -1
  94. package/dist/shared/typings/events.cjs +0 -4
  95. package/dist/shared/typings/events.cjs.map +0 -1
  96. package/dist/shared/typings/events.d.cts +0 -3
  97. package/dist/shared/typings/events.d.ts +0 -3
  98. package/dist/shared/typings/events.js +0 -3
  99. package/dist/shared/typings/events.js.map +0 -1
  100. package/dist/shared/typings/index.cjs +0 -56
  101. package/dist/shared/typings/index.cjs.map +0 -1
  102. package/dist/shared/typings/index.d.cts +0 -3
  103. package/dist/shared/typings/index.d.ts +0 -3
  104. package/dist/shared/typings/index.js +0 -9
  105. package/dist/shared/typings/index.js.map +0 -1
  106. package/dist/shared/typings/module.cjs +0 -4
  107. package/dist/shared/typings/module.cjs.map +0 -1
  108. package/dist/shared/typings/module.d.cts +0 -3
  109. package/dist/shared/typings/module.d.ts +0 -3
  110. package/dist/shared/typings/module.js +0 -3
  111. package/dist/shared/typings/module.js.map +0 -1
  112. package/dist/shared/typings/permissions.cjs +0 -22
  113. package/dist/shared/typings/permissions.cjs.map +0 -1
  114. package/dist/shared/typings/permissions.d.cts +0 -3
  115. package/dist/shared/typings/permissions.d.ts +0 -3
  116. package/dist/shared/typings/permissions.js +0 -19
  117. package/dist/shared/typings/permissions.js.map +0 -1
  118. package/dist/shared/typings/registry.cjs +0 -63
  119. package/dist/shared/typings/registry.cjs.map +0 -1
  120. package/dist/shared/typings/registry.d.cts +0 -51
  121. package/dist/shared/typings/registry.d.ts +0 -51
  122. package/dist/shared/typings/registry.js +0 -61
  123. package/dist/shared/typings/registry.js.map +0 -1
  124. package/dist/shared/utility/functions.cjs +0 -81
  125. package/dist/shared/utility/functions.cjs.map +0 -1
  126. package/dist/shared/utility/functions.d.cts +0 -56
  127. package/dist/shared/utility/functions.d.ts +0 -56
  128. package/dist/shared/utility/functions.js +0 -74
  129. package/dist/shared/utility/functions.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,81 +1,1459 @@
1
1
  'use strict';
2
2
 
3
- require('dotenv/config');
4
- require('node:util');
5
- var trivious_client_js = require('./core/client/trivious.client.js');
6
- var command_base_js = require('./core/commands/command.base.js');
7
- var subcommand_base_js = require('./core/commands/subcommand.base.js');
8
- var contextcommand_base_js = require('./core/commands/contextcommand.base.js');
9
- var command_registry_js = require('./core/registry/command.registry.js');
10
- var component_base_js = require('./core/components/component.base.js');
11
- var component_registry_js = require('./core/registry/component.registry.js');
12
- var index_js = require('./shared/typings/index.js');
3
+ require('util');
4
+ var discord_js = require('discord.js');
5
+ var fs = require('fs');
6
+ var path = require('path');
7
+ var url = require('url');
13
8
 
9
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
14
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
11
 
16
- var trivious_client_js__default = /*#__PURE__*/_interopDefault(trivious_client_js);
17
- var command_base_js__default = /*#__PURE__*/_interopDefault(command_base_js);
18
- var subcommand_base_js__default = /*#__PURE__*/_interopDefault(subcommand_base_js);
19
- var contextcommand_base_js__default = /*#__PURE__*/_interopDefault(contextcommand_base_js);
20
- var command_registry_js__default = /*#__PURE__*/_interopDefault(command_registry_js);
21
- var component_base_js__default = /*#__PURE__*/_interopDefault(component_base_js);
22
- var component_registry_js__default = /*#__PURE__*/_interopDefault(component_registry_js);
12
+ var path__default = /*#__PURE__*/_interopDefault(path);
23
13
 
24
-
25
-
26
- Object.defineProperty(exports, "TriviousClient", {
27
- enumerable: true,
28
- get: function () { return trivious_client_js__default.default; }
29
- });
30
- Object.defineProperty(exports, "Command", {
31
- enumerable: true,
32
- get: function () { return command_base_js__default.default; }
33
- });
34
- Object.defineProperty(exports, "CommandBuilder", {
35
- enumerable: true,
36
- get: function () { return command_base_js.CommandBuilder; }
37
- });
38
- Object.defineProperty(exports, "SlashCommand", {
39
- enumerable: true,
40
- get: function () { return command_base_js.SlashCommand; }
41
- });
42
- Object.defineProperty(exports, "Subcommand", {
43
- enumerable: true,
44
- get: function () { return subcommand_base_js__default.default; }
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
16
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
17
+ }) : x)(function(x) {
18
+ if (typeof require !== "undefined") return require.apply(this, arguments);
19
+ throw Error('Dynamic require of "' + x + '" is not supported');
45
20
  });
46
- Object.defineProperty(exports, "SubcommandBuilder", {
47
- enumerable: true,
48
- get: function () { return subcommand_base_js.SubcommandBuilder; }
49
- });
50
- Object.defineProperty(exports, "ContextMenuBuilder", {
51
- enumerable: true,
52
- get: function () { return contextcommand_base_js.ContextMenuBuilder; }
53
- });
54
- Object.defineProperty(exports, "ContextMenuCommand", {
55
- enumerable: true,
56
- get: function () { return contextcommand_base_js__default.default; }
57
- });
58
- Object.defineProperty(exports, "CommandRegistry", {
59
- enumerable: true,
60
- get: function () { return command_registry_js__default.default; }
21
+ var __commonJS = (cb, mod) => function __require2() {
22
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
23
+ };
24
+
25
+ // node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
26
+ var require_package = __commonJS({
27
+ "node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(exports$1, module) {
28
+ module.exports = {
29
+ name: "dotenv",
30
+ version: "17.2.3",
31
+ description: "Loads environment variables from .env file",
32
+ main: "lib/main.js",
33
+ types: "lib/main.d.ts",
34
+ exports: {
35
+ ".": {
36
+ types: "./lib/main.d.ts",
37
+ require: "./lib/main.js",
38
+ default: "./lib/main.js"
39
+ },
40
+ "./config": "./config.js",
41
+ "./config.js": "./config.js",
42
+ "./lib/env-options": "./lib/env-options.js",
43
+ "./lib/env-options.js": "./lib/env-options.js",
44
+ "./lib/cli-options": "./lib/cli-options.js",
45
+ "./lib/cli-options.js": "./lib/cli-options.js",
46
+ "./package.json": "./package.json"
47
+ },
48
+ scripts: {
49
+ "dts-check": "tsc --project tests/types/tsconfig.json",
50
+ lint: "standard",
51
+ pretest: "npm run lint && npm run dts-check",
52
+ test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
53
+ "test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
54
+ prerelease: "npm test",
55
+ release: "standard-version"
56
+ },
57
+ repository: {
58
+ type: "git",
59
+ url: "git://github.com/motdotla/dotenv.git"
60
+ },
61
+ homepage: "https://github.com/motdotla/dotenv#readme",
62
+ funding: "https://dotenvx.com",
63
+ keywords: [
64
+ "dotenv",
65
+ "env",
66
+ ".env",
67
+ "environment",
68
+ "variables",
69
+ "config",
70
+ "settings"
71
+ ],
72
+ readmeFilename: "README.md",
73
+ license: "BSD-2-Clause",
74
+ devDependencies: {
75
+ "@types/node": "^18.11.3",
76
+ decache: "^4.6.2",
77
+ sinon: "^14.0.1",
78
+ standard: "^17.0.0",
79
+ "standard-version": "^9.5.0",
80
+ tap: "^19.2.0",
81
+ typescript: "^4.8.4"
82
+ },
83
+ engines: {
84
+ node: ">=12"
85
+ },
86
+ browser: {
87
+ fs: false
88
+ }
89
+ };
90
+ }
61
91
  });
62
- Object.defineProperty(exports, "Component", {
63
- enumerable: true,
64
- get: function () { return component_base_js__default.default; }
92
+
93
+ // node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
94
+ var require_main = __commonJS({
95
+ "node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(exports$1, module) {
96
+ var fs6 = __require("fs");
97
+ var path2 = __require("path");
98
+ var os = __require("os");
99
+ var crypto = __require("crypto");
100
+ var packageJson = require_package();
101
+ var version = packageJson.version;
102
+ var TIPS = [
103
+ "\u{1F510} encrypt with Dotenvx: https://dotenvx.com",
104
+ "\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit",
105
+ "\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild",
106
+ "\u{1F4E1} add observability to secrets: https://dotenvx.com/ops",
107
+ "\u{1F465} sync secrets across teammates & machines: https://dotenvx.com/ops",
108
+ "\u{1F5C2}\uFE0F backup and recover secrets: https://dotenvx.com/ops",
109
+ "\u2705 audit secrets and track compliance: https://dotenvx.com/ops",
110
+ "\u{1F504} add secrets lifecycle management: https://dotenvx.com/ops",
111
+ "\u{1F511} add access controls to secrets: https://dotenvx.com/ops",
112
+ "\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`",
113
+ "\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }",
114
+ "\u2699\uFE0F enable debug logging with { debug: true }",
115
+ "\u2699\uFE0F override existing env vars with { override: true }",
116
+ "\u2699\uFE0F suppress all logs with { quiet: true }",
117
+ "\u2699\uFE0F write to custom object with { processEnv: myObject }",
118
+ "\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"
119
+ ];
120
+ function _getRandomTip() {
121
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
122
+ }
123
+ function parseBoolean(value) {
124
+ if (typeof value === "string") {
125
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
126
+ }
127
+ return Boolean(value);
128
+ }
129
+ function supportsAnsi() {
130
+ return process.stdout.isTTY;
131
+ }
132
+ function dim(text) {
133
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
134
+ }
135
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
136
+ function parse(src) {
137
+ const obj = {};
138
+ let lines = src.toString();
139
+ lines = lines.replace(/\r\n?/mg, "\n");
140
+ let match;
141
+ while ((match = LINE.exec(lines)) != null) {
142
+ const key = match[1];
143
+ let value = match[2] || "";
144
+ value = value.trim();
145
+ const maybeQuote = value[0];
146
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
147
+ if (maybeQuote === '"') {
148
+ value = value.replace(/\\n/g, "\n");
149
+ value = value.replace(/\\r/g, "\r");
150
+ }
151
+ obj[key] = value;
152
+ }
153
+ return obj;
154
+ }
155
+ function _parseVault(options) {
156
+ options = options || {};
157
+ const vaultPath = _vaultPath(options);
158
+ options.path = vaultPath;
159
+ const result = DotenvModule.configDotenv(options);
160
+ if (!result.parsed) {
161
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
162
+ err.code = "MISSING_DATA";
163
+ throw err;
164
+ }
165
+ const keys = _dotenvKey(options).split(",");
166
+ const length = keys.length;
167
+ let decrypted;
168
+ for (let i = 0; i < length; i++) {
169
+ try {
170
+ const key = keys[i].trim();
171
+ const attrs = _instructions(result, key);
172
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
173
+ break;
174
+ } catch (error) {
175
+ if (i + 1 >= length) {
176
+ throw error;
177
+ }
178
+ }
179
+ }
180
+ return DotenvModule.parse(decrypted);
181
+ }
182
+ function _warn(message) {
183
+ console.error(`[dotenv@${version}][WARN] ${message}`);
184
+ }
185
+ function _debug(message) {
186
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
187
+ }
188
+ function _log(message) {
189
+ console.log(`[dotenv@${version}] ${message}`);
190
+ }
191
+ function _dotenvKey(options) {
192
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
193
+ return options.DOTENV_KEY;
194
+ }
195
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
196
+ return process.env.DOTENV_KEY;
197
+ }
198
+ return "";
199
+ }
200
+ function _instructions(result, dotenvKey) {
201
+ let uri;
202
+ try {
203
+ uri = new URL(dotenvKey);
204
+ } catch (error) {
205
+ if (error.code === "ERR_INVALID_URL") {
206
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
207
+ err.code = "INVALID_DOTENV_KEY";
208
+ throw err;
209
+ }
210
+ throw error;
211
+ }
212
+ const key = uri.password;
213
+ if (!key) {
214
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
215
+ err.code = "INVALID_DOTENV_KEY";
216
+ throw err;
217
+ }
218
+ const environment = uri.searchParams.get("environment");
219
+ if (!environment) {
220
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
221
+ err.code = "INVALID_DOTENV_KEY";
222
+ throw err;
223
+ }
224
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
225
+ const ciphertext = result.parsed[environmentKey];
226
+ if (!ciphertext) {
227
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
228
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
229
+ throw err;
230
+ }
231
+ return { ciphertext, key };
232
+ }
233
+ function _vaultPath(options) {
234
+ let possibleVaultPath = null;
235
+ if (options && options.path && options.path.length > 0) {
236
+ if (Array.isArray(options.path)) {
237
+ for (const filepath of options.path) {
238
+ if (fs6.existsSync(filepath)) {
239
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
240
+ }
241
+ }
242
+ } else {
243
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
244
+ }
245
+ } else {
246
+ possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
247
+ }
248
+ if (fs6.existsSync(possibleVaultPath)) {
249
+ return possibleVaultPath;
250
+ }
251
+ return null;
252
+ }
253
+ function _resolveHome(envPath) {
254
+ return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
255
+ }
256
+ function _configVault(options) {
257
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
258
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
259
+ if (debug || !quiet) {
260
+ _log("Loading env from encrypted .env.vault");
261
+ }
262
+ const parsed = DotenvModule._parseVault(options);
263
+ let processEnv = process.env;
264
+ if (options && options.processEnv != null) {
265
+ processEnv = options.processEnv;
266
+ }
267
+ DotenvModule.populate(processEnv, parsed, options);
268
+ return { parsed };
269
+ }
270
+ function configDotenv(options) {
271
+ const dotenvPath = path2.resolve(process.cwd(), ".env");
272
+ let encoding = "utf8";
273
+ let processEnv = process.env;
274
+ if (options && options.processEnv != null) {
275
+ processEnv = options.processEnv;
276
+ }
277
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
278
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
279
+ if (options && options.encoding) {
280
+ encoding = options.encoding;
281
+ } else {
282
+ if (debug) {
283
+ _debug("No encoding is specified. UTF-8 is used by default");
284
+ }
285
+ }
286
+ let optionPaths = [dotenvPath];
287
+ if (options && options.path) {
288
+ if (!Array.isArray(options.path)) {
289
+ optionPaths = [_resolveHome(options.path)];
290
+ } else {
291
+ optionPaths = [];
292
+ for (const filepath of options.path) {
293
+ optionPaths.push(_resolveHome(filepath));
294
+ }
295
+ }
296
+ }
297
+ let lastError;
298
+ const parsedAll = {};
299
+ for (const path3 of optionPaths) {
300
+ try {
301
+ const parsed = DotenvModule.parse(fs6.readFileSync(path3, { encoding }));
302
+ DotenvModule.populate(parsedAll, parsed, options);
303
+ } catch (e) {
304
+ if (debug) {
305
+ _debug(`Failed to load ${path3} ${e.message}`);
306
+ }
307
+ lastError = e;
308
+ }
309
+ }
310
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
311
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
312
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
313
+ if (debug || !quiet) {
314
+ const keysCount = Object.keys(populated).length;
315
+ const shortPaths = [];
316
+ for (const filePath of optionPaths) {
317
+ try {
318
+ const relative = path2.relative(process.cwd(), filePath);
319
+ shortPaths.push(relative);
320
+ } catch (e) {
321
+ if (debug) {
322
+ _debug(`Failed to load ${filePath} ${e.message}`);
323
+ }
324
+ lastError = e;
325
+ }
326
+ }
327
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
328
+ }
329
+ if (lastError) {
330
+ return { parsed: parsedAll, error: lastError };
331
+ } else {
332
+ return { parsed: parsedAll };
333
+ }
334
+ }
335
+ function config(options) {
336
+ if (_dotenvKey(options).length === 0) {
337
+ return DotenvModule.configDotenv(options);
338
+ }
339
+ const vaultPath = _vaultPath(options);
340
+ if (!vaultPath) {
341
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
342
+ return DotenvModule.configDotenv(options);
343
+ }
344
+ return DotenvModule._configVault(options);
345
+ }
346
+ function decrypt(encrypted, keyStr) {
347
+ const key = Buffer.from(keyStr.slice(-64), "hex");
348
+ let ciphertext = Buffer.from(encrypted, "base64");
349
+ const nonce = ciphertext.subarray(0, 12);
350
+ const authTag = ciphertext.subarray(-16);
351
+ ciphertext = ciphertext.subarray(12, -16);
352
+ try {
353
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
354
+ aesgcm.setAuthTag(authTag);
355
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
356
+ } catch (error) {
357
+ const isRange = error instanceof RangeError;
358
+ const invalidKeyLength = error.message === "Invalid key length";
359
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
360
+ if (isRange || invalidKeyLength) {
361
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
362
+ err.code = "INVALID_DOTENV_KEY";
363
+ throw err;
364
+ } else if (decryptionFailed) {
365
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
366
+ err.code = "DECRYPTION_FAILED";
367
+ throw err;
368
+ } else {
369
+ throw error;
370
+ }
371
+ }
372
+ }
373
+ function populate(processEnv, parsed, options = {}) {
374
+ const debug = Boolean(options && options.debug);
375
+ const override = Boolean(options && options.override);
376
+ const populated = {};
377
+ if (typeof parsed !== "object") {
378
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
379
+ err.code = "OBJECT_REQUIRED";
380
+ throw err;
381
+ }
382
+ for (const key of Object.keys(parsed)) {
383
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
384
+ if (override === true) {
385
+ processEnv[key] = parsed[key];
386
+ populated[key] = parsed[key];
387
+ }
388
+ if (debug) {
389
+ if (override === true) {
390
+ _debug(`"${key}" is already defined and WAS overwritten`);
391
+ } else {
392
+ _debug(`"${key}" is already defined and was NOT overwritten`);
393
+ }
394
+ }
395
+ } else {
396
+ processEnv[key] = parsed[key];
397
+ populated[key] = parsed[key];
398
+ }
399
+ }
400
+ return populated;
401
+ }
402
+ var DotenvModule = {
403
+ configDotenv,
404
+ _configVault,
405
+ _parseVault,
406
+ config,
407
+ decrypt,
408
+ parse,
409
+ populate
410
+ };
411
+ module.exports.configDotenv = DotenvModule.configDotenv;
412
+ module.exports._configVault = DotenvModule._configVault;
413
+ module.exports._parseVault = DotenvModule._parseVault;
414
+ module.exports.config = DotenvModule.config;
415
+ module.exports.decrypt = DotenvModule.decrypt;
416
+ module.exports.parse = DotenvModule.parse;
417
+ module.exports.populate = DotenvModule.populate;
418
+ module.exports = DotenvModule;
419
+ }
65
420
  });
66
- Object.defineProperty(exports, "ComponentBuilder", {
67
- enumerable: true,
68
- get: function () { return component_base_js.ComponentBuilder; }
421
+
422
+ // node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js
423
+ var require_env_options = __commonJS({
424
+ "node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js"(exports$1, module) {
425
+ var options = {};
426
+ if (process.env.DOTENV_CONFIG_ENCODING != null) {
427
+ options.encoding = process.env.DOTENV_CONFIG_ENCODING;
428
+ }
429
+ if (process.env.DOTENV_CONFIG_PATH != null) {
430
+ options.path = process.env.DOTENV_CONFIG_PATH;
431
+ }
432
+ if (process.env.DOTENV_CONFIG_QUIET != null) {
433
+ options.quiet = process.env.DOTENV_CONFIG_QUIET;
434
+ }
435
+ if (process.env.DOTENV_CONFIG_DEBUG != null) {
436
+ options.debug = process.env.DOTENV_CONFIG_DEBUG;
437
+ }
438
+ if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
439
+ options.override = process.env.DOTENV_CONFIG_OVERRIDE;
440
+ }
441
+ if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
442
+ options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
443
+ }
444
+ module.exports = options;
445
+ }
69
446
  });
70
- Object.defineProperty(exports, "ComponentRegistry", {
71
- enumerable: true,
72
- get: function () { return component_registry_js__default.default; }
447
+
448
+ // node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js
449
+ var require_cli_options = __commonJS({
450
+ "node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js"(exports$1, module) {
451
+ var re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
452
+ module.exports = function optionMatcher(args) {
453
+ const options = args.reduce(function(acc, cur) {
454
+ const matches = cur.match(re);
455
+ if (matches) {
456
+ acc[matches[1]] = matches[2];
457
+ }
458
+ return acc;
459
+ }, {});
460
+ if (!("quiet" in options)) {
461
+ options.quiet = "true";
462
+ }
463
+ return options;
464
+ };
465
+ }
73
466
  });
74
- Object.keys(index_js).forEach(function (k) {
75
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
76
- enumerable: true,
77
- get: function () { return index_js[k]; }
78
- });
467
+
468
+ // node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/config.js
469
+ (function() {
470
+ require_main().config(
471
+ Object.assign(
472
+ {},
473
+ require_env_options(),
474
+ require_cli_options()(process.argv)
475
+ )
476
+ );
477
+ })();
478
+
479
+ // src/shared/typings/permissions.ts
480
+ var PermissionLevel = /* @__PURE__ */ ((PermissionLevel2) => {
481
+ PermissionLevel2[PermissionLevel2["USER"] = 0] = "USER";
482
+ PermissionLevel2[PermissionLevel2["GUILD_STAFF"] = 1] = "GUILD_STAFF";
483
+ PermissionLevel2[PermissionLevel2["GUILD_MODERATOR"] = 2] = "GUILD_MODERATOR";
484
+ PermissionLevel2[PermissionLevel2["GUILD_ADMINISTRATOR"] = 3] = "GUILD_ADMINISTRATOR";
485
+ PermissionLevel2[PermissionLevel2["GUILD_OWNER"] = 4] = "GUILD_OWNER";
486
+ PermissionLevel2[PermissionLevel2["BOT_OWNER"] = 5] = "BOT_OWNER";
487
+ return PermissionLevel2;
488
+ })(PermissionLevel || {});
489
+ var getPermissionLevel = (client, member) => {
490
+ const highestRole = member.roles.highest;
491
+ if (member.user.id === member.guild.ownerId) return 4 /* GUILD_OWNER */;
492
+ const rolePermissions = client.rolePermissions;
493
+ return rolePermissions[highestRole.name] ?? 0 /* USER */;
494
+ };
495
+
496
+ // src/shared/utility/functions.ts
497
+ var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
498
+ var __dirname$1 = path.dirname(__filename$1);
499
+ var getPackageRoot = () => {
500
+ let dir = __dirname$1;
501
+ while (dir !== path.dirname(dir)) {
502
+ if (fs.existsSync(path.join(dir, "package.json")) || fs.existsSync(path.join(dir, "node_modules"))) {
503
+ return dir;
504
+ }
505
+ dir = path.dirname(dir);
506
+ }
507
+ return __dirname$1;
508
+ };
509
+ var FRAMEWORK_PACKAGE_ROOT = getPackageRoot();
510
+ function getCorePath(options) {
511
+ const { userPath, coreDirectory } = options;
512
+ if (userPath) {
513
+ return resolveUserPath(userPath);
514
+ }
515
+ const builtInCandidates = [
516
+ path.join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory),
517
+ path.join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory)
518
+ ];
519
+ for (const candidate of builtInCandidates) {
520
+ if (fs.existsSync(candidate)) {
521
+ return candidate;
522
+ }
523
+ }
524
+ return path.join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory);
525
+ }
526
+ function resolveUserPath(relativePath) {
527
+ const candidates = [
528
+ path.join(process.cwd(), relativePath),
529
+ path.join(process.cwd(), "lib", relativePath),
530
+ path.join(process.cwd(), "dist", relativePath),
531
+ path.join(FRAMEWORK_PACKAGE_ROOT, relativePath),
532
+ path.join(FRAMEWORK_PACKAGE_ROOT, "lib", relativePath),
533
+ path.join(FRAMEWORK_PACKAGE_ROOT, "dist", relativePath)
534
+ ];
535
+ for (const candidate of candidates) {
536
+ const full = path.resolve(candidate);
537
+ if (fs.existsSync(full)) return full;
538
+ }
539
+ return path.join(process.cwd(), relativePath);
540
+ }
541
+ async function exists(path2) {
542
+ try {
543
+ await fs.promises.access(path2);
544
+ return true;
545
+ } catch {
546
+ return false;
547
+ }
548
+ }
549
+ function hasPermission(client, options) {
550
+ const { permission, user, member } = options;
551
+ if (user) {
552
+ if (permission === 5 /* BOT_OWNER */) return user.id === "424764032667484171";
553
+ return true;
554
+ }
555
+ if (member) {
556
+ const memberPermission = getPermissionLevel(client, member);
557
+ return memberPermission >= permission;
558
+ }
559
+ return false;
560
+ }
561
+ var BaseRegistry = class {
562
+ /**
563
+ * Get all of loaded T
564
+ *
565
+ * @returns {Collection<string, T>}
566
+ */
567
+ get() {
568
+ return this.items;
569
+ }
570
+ /**
571
+ * Import a file from a path to be loaded.
572
+ *
573
+ * @protected
574
+ * @async
575
+ * @template T
576
+ * @param {string} filePath
577
+ * @returns {Promise<T | null>}
578
+ */
579
+ async importFile(filePath) {
580
+ try {
581
+ const { default: file } = await import(url.pathToFileURL(filePath).href);
582
+ const imports = file.default ?? file;
583
+ if (!imports) return null;
584
+ if (typeof imports === "function" && imports.prototype) {
585
+ return new imports();
586
+ }
587
+ if (typeof imports === "object") {
588
+ if (Object.keys(imports).length === 0) return null;
589
+ return imports;
590
+ }
591
+ console.error(`Invalid export in ${filePath}: expected class or object`);
592
+ return null;
593
+ } catch (error) {
594
+ console.error("Failed to import:", filePath, error);
595
+ return null;
596
+ }
597
+ }
598
+ /**
599
+ * Clear file path cache.
600
+ * Does not run in production environment.
601
+ *
602
+ * @protected
603
+ * @async
604
+ * @param {string} filePath
605
+ * @returns {*}
606
+ */
607
+ async clearCache(filePath) {
608
+ if (process.env.NODE_ENV === "production") return;
609
+ try {
610
+ const resvoled = __require.resolve(filePath);
611
+ delete __require.cache[resvoled];
612
+ } catch {
613
+ }
614
+ }
615
+ };
616
+
617
+ // src/shared/typings/components.ts
618
+ var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
619
+ ComponentType2["Button"] = "button";
620
+ ComponentType2["SelectMenu"] = "select";
621
+ ComponentType2["Modal"] = "modal";
622
+ return ComponentType2;
623
+ })(ComponentType || {});
624
+ var deconstructCustomId = (customId) => {
625
+ const [componentType, dataTags] = customId.split(":");
626
+ const [data, ...tags] = dataTags.split(".");
627
+ return {
628
+ componentType,
629
+ data,
630
+ tags
631
+ };
632
+ };
633
+ var CommandRegistry = class extends BaseRegistry {
634
+ items = new discord_js.Collection();
635
+ /**
636
+ * Load all commands and their subcommands
637
+ *
638
+ * @async
639
+ * @param {string} [directory=getCorePath({ coreDirectory: "commands" })]
640
+ * @returns {unknown}
641
+ */
642
+ async load(directory = getCorePath({ coreDirectory: "commands" })) {
643
+ if (!await exists(directory)) {
644
+ return this;
645
+ }
646
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
647
+ for (const entry of entries) {
648
+ const fullPath = path.join(directory, entry.name);
649
+ if (!entry.isDirectory()) continue;
650
+ const indexFile = path.join(fullPath, "index.ts");
651
+ const indexJs = path.join(fullPath, "index.js");
652
+ let commandFile = "";
653
+ if (await exists(indexFile)) commandFile = indexFile;
654
+ else if (await exists(indexJs)) commandFile = indexJs;
655
+ else continue;
656
+ const command = await this.importFile(commandFile);
657
+ if (!command) continue;
658
+ if (!command.metadata.active) continue;
659
+ if (command.isSlashCommand()) {
660
+ const subcommandFiles = (await fs.promises.readdir(fullPath)).filter(
661
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
662
+ );
663
+ for (const file of subcommandFiles) {
664
+ const subcommand = await this.importFile(path.join(fullPath, file));
665
+ if (!subcommand) continue;
666
+ if (!subcommand.data.name || !(subcommand.data instanceof discord_js.SlashCommandSubcommandBuilder))
667
+ continue;
668
+ command.data.addSubcommand(subcommand.data);
669
+ command.metadata.subcommands.set(subcommand.data.name, subcommand);
670
+ }
671
+ }
672
+ this.items.set(command.data.name, command);
673
+ }
674
+ return this;
675
+ }
676
+ };
677
+ var ComponentRegistry = class extends BaseRegistry {
678
+ items = new discord_js.Collection();
679
+ /**
680
+ * Load all components.
681
+ *
682
+ * @async
683
+ * @param {string} [directory=getCorePath({ coreDirectory: "components" })]
684
+ * @returns {Promise<this>}
685
+ */
686
+ async load(directory = getCorePath({ coreDirectory: "components" })) {
687
+ if (!await exists(directory)) {
688
+ return this;
689
+ }
690
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
691
+ for (const entry of entries) {
692
+ const fullPath = path.join(directory, entry.name);
693
+ if (!entry.isDirectory()) continue;
694
+ const componentFiles = (await fs.promises.readdir(fullPath)).filter(
695
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
696
+ );
697
+ for (const file of componentFiles) {
698
+ const component = await this.importFile(path.join(fullPath, file));
699
+ if (!component) continue;
700
+ const { data } = deconstructCustomId(component.metadata.customId);
701
+ this.items.set(data, component);
702
+ }
703
+ }
704
+ return this;
705
+ }
706
+ };
707
+ var interactionCreate_default = {
708
+ name: "interactionCreate",
709
+ execute: async (client, interaction) => {
710
+ if (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {
711
+ const { commandName } = interaction;
712
+ const registeredCommands = client.registries.commands.get();
713
+ const command = registeredCommands.get(commandName);
714
+ if (!command) {
715
+ await interaction.reply({
716
+ content: `Command is outdated, inactive or does not have a handler!`,
717
+ flags: ["Ephemeral"]
718
+ });
719
+ return;
720
+ }
721
+ const requiredPermission = command.metadata.permission;
722
+ const hasPermission2 = await command.validateGuildPermission(
723
+ client,
724
+ interaction,
725
+ requiredPermission
726
+ );
727
+ if (!hasPermission2) return;
728
+ if (!("execute" in command)) {
729
+ await command.reply(interaction, { content: "Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!" });
730
+ return;
731
+ }
732
+ await command.reply(interaction, { content: "Processing command..." });
733
+ if (interaction.isChatInputCommand() && command.isSlashCommand()) {
734
+ await command.execute(client, interaction);
735
+ } else if (interaction.isContextMenuCommand() && command.isContextMenuCommand()) {
736
+ await command.execute(client, interaction);
737
+ }
738
+ } else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
739
+ const { componentType, tags, data } = deconstructCustomId(interaction.customId);
740
+ if (componentType === "button" /* Button */ && !(interaction instanceof discord_js.ButtonInteraction))
741
+ return;
742
+ if (componentType === "modal" /* Modal */ && !(interaction instanceof discord_js.ModalSubmitInteraction))
743
+ return;
744
+ if (tags.includes("awaited")) return;
745
+ const registeredComponents = client.registries.components.get();
746
+ const component = registeredComponents.get(data);
747
+ if (!component) {
748
+ await interaction.reply({
749
+ content: `Command is outdated, inactive or does not have a handler!`,
750
+ flags: ["Ephemeral"]
751
+ });
752
+ return;
753
+ }
754
+ const requiredPermission = component.metadata.permission;
755
+ const hasPermission2 = await component.validateGuildPermission(
756
+ client,
757
+ interaction,
758
+ requiredPermission
759
+ );
760
+ if (!hasPermission2) return;
761
+ if (!interaction.isModalSubmit()) await interaction.deferUpdate();
762
+ await component.execute(client, interaction);
763
+ }
764
+ }
765
+ };
766
+
767
+ // src/core/registry/event.registry.ts
768
+ var EventRegistry = class extends BaseRegistry {
769
+ items = new discord_js.Collection();
770
+ /**
771
+ * Load all events.
772
+ *
773
+ * @async
774
+ * @param {string} [directory=getCorePath({ coreDirectory: "events" })]
775
+ * @returns {Promise<this>}
776
+ */
777
+ async load(directory = getCorePath({ coreDirectory: "events" })) {
778
+ if (!await exists(directory)) return this;
779
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
780
+ for (const entry of entries) {
781
+ const fullPath = path.join(directory, entry.name);
782
+ if (entry.isDirectory()) {
783
+ await this.load(fullPath);
784
+ continue;
785
+ }
786
+ if (entry.isFile() && entry.name.endsWith(".js")) {
787
+ const event = await this.importFile(fullPath);
788
+ if (!event) continue;
789
+ this.items.set(event.name, event);
790
+ }
791
+ }
792
+ this.items.set(interactionCreate_default.name, interactionCreate_default);
793
+ return this;
794
+ }
795
+ /**
796
+ * Bind loaded events to their client events respectively.
797
+ *
798
+ * @param {TriviousClient} client
799
+ */
800
+ bind(client) {
801
+ for (const event of this.items.values()) {
802
+ const handler = (...args) => void event.execute(client, ...args);
803
+ if (event.once) client.once(event.name, handler);
804
+ else client.on(event.name, handler);
805
+ }
806
+ }
807
+ };
808
+ var ModuleRegistry = class extends BaseRegistry {
809
+ items = new discord_js.Collection();
810
+ /**
811
+ * Load all modules.
812
+ *
813
+ * @async
814
+ * @param {string} [directory=getCorePath({ coreDirectory: "module" })]
815
+ * @returns {Promise<this>}
816
+ */
817
+ async load(directory = getCorePath({ coreDirectory: "module" })) {
818
+ if (!await exists(directory)) {
819
+ return this;
820
+ }
821
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
822
+ for (const entry of entries) {
823
+ const fullPath = path.join(directory, entry.name);
824
+ if (!entry.isDirectory()) continue;
825
+ const moduleFiles = (await fs.promises.readdir(fullPath)).filter(
826
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
827
+ );
828
+ for (const file of moduleFiles) {
829
+ const moduleEvent = await this.importFile(path.join(fullPath, file));
830
+ if (!moduleEvent || !moduleEvent.events) continue;
831
+ this.items.set(moduleEvent.name, moduleEvent);
832
+ }
833
+ }
834
+ return this;
835
+ }
836
+ /**
837
+ * Bind all loaded modules to their client event respectively.
838
+ *
839
+ * @param {TriviousClient} client
840
+ */
841
+ bind(client) {
842
+ for (const mod of this.items.values()) {
843
+ for (const [eventName, handler] of Object.entries(mod.events)) {
844
+ if (typeof handler !== "function") continue;
845
+ const listener = (...args) => {
846
+ void handler(client, ...args);
847
+ };
848
+ client.on(eventName, listener);
849
+ }
850
+ }
851
+ }
852
+ };
853
+ var registries = () => ({
854
+ commands: new CommandRegistry(),
855
+ components: new ComponentRegistry(),
856
+ events: new EventRegistry(),
857
+ modules: new ModuleRegistry(),
858
+ async loadAll(options) {
859
+ const corePaths = options.corePaths;
860
+ const corePath = options.corePath;
861
+ await Promise.all([
862
+ this.commands.load(
863
+ corePath ? resolveUserPath(path__default.default.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
864
+ ),
865
+ this.components.load(
866
+ corePath ? resolveUserPath(path__default.default.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
867
+ ),
868
+ this.events.load(
869
+ corePath ? resolveUserPath(path__default.default.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
870
+ ),
871
+ this.modules.load(
872
+ corePath ? resolveUserPath(path__default.default.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
873
+ )
874
+ ]);
875
+ },
876
+ bind(client) {
877
+ this.events.bind(client);
878
+ this.modules.bind(client);
879
+ }
79
880
  });
881
+
882
+ // src/core/client/trivious.client.ts
883
+ var TriviousClient = class extends discord_js.Client {
884
+ /**
885
+ * Client registries.
886
+ *
887
+ * @public
888
+ * @readonly
889
+ * @type {*}
890
+ */
891
+ registries = registries();
892
+ /**
893
+ * Client copy of the constructor options.
894
+ *
895
+ * @private
896
+ * @type {TriviousClientOptions}
897
+ */
898
+ _options;
899
+ /**
900
+ * Creates an instance of TriviousClient.
901
+ *
902
+ * @constructor
903
+ * @param {TriviousClientOptions} options
904
+ */
905
+ constructor(options) {
906
+ super(options);
907
+ this._options = options;
908
+ }
909
+ /**
910
+ * Load all registries.
911
+ *
912
+ * @async
913
+ * @returns {*}
914
+ */
915
+ async register() {
916
+ const { registries: registries2 } = this;
917
+ await registries2.loadAll(this._options);
918
+ console.log(
919
+ `[Trivious] Loaded all registries (${registries2.commands.get().size} commands, ${registries2.events.get().size} events, ${registries2.components.get().size} components, ${registries2.modules.get().size} modules)`
920
+ );
921
+ }
922
+ /**
923
+ * Login and start the bot.
924
+ *
925
+ * @async
926
+ * @returns {*}
927
+ */
928
+ async start() {
929
+ if (!process.env[this._options.tokenReference]) {
930
+ if (process.env.NODE_ENV !== "production") return;
931
+ else throw new Error("[Trivious] Invalid token reference");
932
+ }
933
+ this.registries.bind(this);
934
+ await this.login(process.env[this._options.tokenReference]);
935
+ }
936
+ /**
937
+ * Deploy all commands.
938
+ *
939
+ * @async
940
+ * @returns {*}
941
+ */
942
+ async deploy() {
943
+ const clientId = process.env[this._options.clientIdReference];
944
+ const token = process.env[this._options.tokenReference];
945
+ if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
946
+ const slashCommands = Array.from(this.registries.commands.get().values());
947
+ const body = [...slashCommands.map((command) => command.toJSON())];
948
+ const rest = new discord_js.REST({ version: "10" }).setToken(token);
949
+ await rest.put(discord_js.Routes.applicationCommands(clientId), { body });
950
+ console.log(`[Trivious] Deployed ${body.length} commands`);
951
+ }
952
+ /**
953
+ * Set the roles tied to a permission level.
954
+ *
955
+ * @param {Record<string, PermissionLevel>} roles
956
+ */
957
+ setRolePermissions(roles) {
958
+ this._options.rolePermissions = roles;
959
+ }
960
+ get rolePermissions() {
961
+ return this._options.rolePermissions ?? {};
962
+ }
963
+ };
964
+ var Command = class {
965
+ /**
966
+ * Returns whether the command is a SlashCommand.
967
+ *
968
+ * @public
969
+ * @param {Command} this
970
+ * @returns {this is SlashCommand}
971
+ */
972
+ isSlashCommand() {
973
+ return this.data instanceof discord_js.SlashCommandBuilder && this instanceof SlashCommand;
974
+ }
975
+ /**
976
+ * Returns whether the command is a ContextMenuCommand.
977
+ *
978
+ * @public
979
+ * @param {Command} this
980
+ * @returns {this is ContextMenuCommand}
981
+ */
982
+ isContextMenuCommand() {
983
+ return this.data instanceof discord_js.ContextMenuCommandBuilder && this instanceof ContextMenuCommand;
984
+ }
985
+ /**
986
+ * Returns JSON of the command builder.
987
+ *
988
+ * @public
989
+ * @returns {*}
990
+ */
991
+ toJSON() {
992
+ return this.data.toJSON();
993
+ }
994
+ /**
995
+ * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
996
+ *
997
+ * @public
998
+ * @async
999
+ * @param {CommandInteraction} interaction
1000
+ * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
1001
+ * @returns {*}
1002
+ */
1003
+ async reply(interaction, options) {
1004
+ if (interaction.replied) {
1005
+ await interaction.editReply(options);
1006
+ return;
1007
+ }
1008
+ const newOptions = { ...options };
1009
+ if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1010
+ await interaction.reply(newOptions);
1011
+ }
1012
+ /**
1013
+ * Validate permissions for a user/member in a guild.
1014
+ *
1015
+ * @async
1016
+ * @param {CommandInteraction} interaction
1017
+ * @param {PermissionLevel} permission
1018
+ * @param {boolean} [doReply=true]
1019
+ * @returns {unknown}
1020
+ */
1021
+ async validateGuildPermission(client, interaction, permission, doReply = true) {
1022
+ const isContextMenu = interaction.isContextMenuCommand();
1023
+ const isChatInput = interaction.isChatInputCommand();
1024
+ const requiresGuildCheck = isContextMenu || isChatInput && (this.isSlashCommand() ? this.metadata.guildOnly : false);
1025
+ if (!requiresGuildCheck) return true;
1026
+ const member = interaction.member;
1027
+ const memberHasPermission = hasPermission(client, { permission, member });
1028
+ if (!memberHasPermission && doReply) {
1029
+ await this.reply(interaction, {
1030
+ content: `You do not have permission to run this command, required permission: \`${PermissionLevel[permission]}\``
1031
+ });
1032
+ }
1033
+ return memberHasPermission;
1034
+ }
1035
+ };
1036
+ var SlashCommand = class extends Command {
1037
+ /**
1038
+ * Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
1039
+ *
1040
+ * @abstract
1041
+ * @type {?(
1042
+ * client: TriviousClient,
1043
+ * interaction: ChatInputCommandInteraction
1044
+ * ) => Promise<void>}
1045
+ */
1046
+ run;
1047
+ /**
1048
+ * General handler for the command and its subcommand, if applicable.
1049
+ *
1050
+ * @public
1051
+ * @async
1052
+ * @param {TriviousClient} client
1053
+ * @param {ChatInputCommandInteraction} interaction
1054
+ * @returns {*}
1055
+ */
1056
+ async execute(client, interaction) {
1057
+ const { run, reply, metadata } = this;
1058
+ const { options } = interaction;
1059
+ if (run) {
1060
+ const memberHasPermission2 = await this.validateGuildPermission(
1061
+ client,
1062
+ interaction,
1063
+ metadata.permission,
1064
+ false
1065
+ );
1066
+ if (memberHasPermission2) await run(client, interaction);
1067
+ }
1068
+ const subcommands = metadata.subcommands;
1069
+ if (subcommands.size <= 0) return;
1070
+ const subcommand = metadata.subcommands.find(
1071
+ (subcmd) => subcmd.data.name === options.getSubcommand()
1072
+ );
1073
+ if (!subcommand) {
1074
+ await reply(interaction, {
1075
+ content: "Ran subcommand is outdated or does not have a handler!"
1076
+ });
1077
+ return;
1078
+ }
1079
+ const memberHasPermission = await this.validateGuildPermission(
1080
+ client,
1081
+ interaction,
1082
+ subcommand.metadata.permission
1083
+ );
1084
+ if (!memberHasPermission) return;
1085
+ await subcommand.execute(client, interaction);
1086
+ }
1087
+ };
1088
+ var CommandBuilder = class extends discord_js.SlashCommandBuilder {
1089
+ _active = true;
1090
+ _guildOnly = false;
1091
+ _ownerOnly = false;
1092
+ _permission = 0 /* USER */;
1093
+ _subcommands = new discord_js.Collection();
1094
+ _ephemeralReply = false;
1095
+ /**
1096
+ * Set the command as disabled.
1097
+ *
1098
+ * @public
1099
+ * @returns {this}
1100
+ */
1101
+ disable() {
1102
+ this._active = false;
1103
+ return this;
1104
+ }
1105
+ /**
1106
+ * Set the command as guild only.
1107
+ *
1108
+ * @public
1109
+ * @returns {this}
1110
+ */
1111
+ setGuildOnly() {
1112
+ this._guildOnly = true;
1113
+ this._permission = 0 /* USER */;
1114
+ this.setContexts(discord_js.InteractionContextType.Guild);
1115
+ return this;
1116
+ }
1117
+ /**
1118
+ * Set the command as public only.
1119
+ *
1120
+ * @public
1121
+ * @returns {this}
1122
+ */
1123
+ setOwnerOnly() {
1124
+ this._permission = 5 /* BOT_OWNER */;
1125
+ return this;
1126
+ }
1127
+ /**
1128
+ * Set the permission level required to run the command.
1129
+ *
1130
+ * @public
1131
+ * @param {PermissionLevel} permission
1132
+ * @returns {this}
1133
+ */
1134
+ setPermission(permission) {
1135
+ if (!this._guildOnly) return this;
1136
+ this._permission = permission;
1137
+ return this;
1138
+ }
1139
+ /**
1140
+ * Set the interaction as ephemeral.
1141
+ *
1142
+ * @public
1143
+ * @returns {this}
1144
+ */
1145
+ setEphemeralReply() {
1146
+ this._ephemeralReply = true;
1147
+ return this;
1148
+ }
1149
+ /**
1150
+ * Build the builder.
1151
+ *
1152
+ * @public
1153
+ * @returns {{ data: CommandBuilder; metadata: CommandMetadata; }}
1154
+ */
1155
+ build() {
1156
+ return {
1157
+ data: this,
1158
+ metadata: {
1159
+ active: this._active,
1160
+ guildOnly: this._guildOnly,
1161
+ ownerOnly: this._ownerOnly,
1162
+ permission: this._permission,
1163
+ subcommands: this._subcommands,
1164
+ ephemeralReply: this._ephemeralReply
1165
+ }
1166
+ };
1167
+ }
1168
+ };
1169
+ var ContextMenuCommand = class extends Command {
1170
+ /**
1171
+ * Base command handler.
1172
+ *
1173
+ * @public
1174
+ * @async
1175
+ * @param {TriviousClient} client
1176
+ * @param {ContextMenuCommandInteraction} interaction
1177
+ * @returns {*}
1178
+ */
1179
+ async execute(client, interaction) {
1180
+ const { run, metadata } = this;
1181
+ const memberHasPermission = await this.validateGuildPermission(
1182
+ client,
1183
+ interaction,
1184
+ metadata.permission,
1185
+ false
1186
+ );
1187
+ if (memberHasPermission) await run(client, interaction);
1188
+ }
1189
+ };
1190
+ var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
1191
+ _active = true;
1192
+ _ownerOnly = false;
1193
+ _permission = 0 /* USER */;
1194
+ _ephemeralReply = false;
1195
+ /**
1196
+ * Set the command as disabled.
1197
+ *
1198
+ * @public
1199
+ * @returns {this}
1200
+ */
1201
+ disable() {
1202
+ this._active = false;
1203
+ return this;
1204
+ }
1205
+ /**
1206
+ * Set the command as owner only.
1207
+ *
1208
+ * @public
1209
+ * @returns {this}
1210
+ */
1211
+ setOwnerOnly() {
1212
+ this._permission = 5 /* BOT_OWNER */;
1213
+ this._ownerOnly = true;
1214
+ return this;
1215
+ }
1216
+ /**
1217
+ * Set the permission level required to run the command.
1218
+ *
1219
+ * @public
1220
+ * @param {PermissionLevel} permission
1221
+ * @returns {this}
1222
+ */
1223
+ setPermission(permission) {
1224
+ this._permission = permission;
1225
+ return this;
1226
+ }
1227
+ /**
1228
+ * Set the interaction as ephemeral.
1229
+ *
1230
+ * @public
1231
+ * @returns {this}
1232
+ */
1233
+ setEphemeralReply() {
1234
+ this._ephemeralReply = true;
1235
+ return this;
1236
+ }
1237
+ /**
1238
+ * Build the builder
1239
+ *
1240
+ * @public
1241
+ * @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
1242
+ */
1243
+ build() {
1244
+ return {
1245
+ data: this,
1246
+ metadata: {
1247
+ active: this._active,
1248
+ ownerOnly: this._ownerOnly,
1249
+ permission: this._permission,
1250
+ ephemeralReply: this._ephemeralReply
1251
+ }
1252
+ };
1253
+ }
1254
+ };
1255
+ var SubcommandBuilder = class extends discord_js.SlashCommandSubcommandBuilder {
1256
+ _active = true;
1257
+ _ownerOnly = false;
1258
+ _permission = 0 /* USER */;
1259
+ _ephemeralReply = false;
1260
+ /**
1261
+ * Set the subcommand as disabled.
1262
+ *
1263
+ * @public
1264
+ * @returns {this}
1265
+ */
1266
+ disable() {
1267
+ this._active = false;
1268
+ return this;
1269
+ }
1270
+ /**
1271
+ * Set the subcommand as owner only.
1272
+ *
1273
+ * @public
1274
+ * @returns {this}
1275
+ */
1276
+ setOwnerOnly() {
1277
+ this._permission = 5 /* BOT_OWNER */;
1278
+ this._ownerOnly = true;
1279
+ return this;
1280
+ }
1281
+ /**
1282
+ * Set the permission level required to run the subcommand.
1283
+ *
1284
+ * @public
1285
+ * @param {PermissionLevel} permission
1286
+ * @returns {this}
1287
+ */
1288
+ setPermission(permission) {
1289
+ this._permission = permission;
1290
+ return this;
1291
+ }
1292
+ /**
1293
+ * Set the interaction as ephemeral
1294
+ *
1295
+ * @public
1296
+ * @returns {this}
1297
+ */
1298
+ setEphemeralReply() {
1299
+ this._ephemeralReply = true;
1300
+ return this;
1301
+ }
1302
+ /**
1303
+ * Build the builder.
1304
+ *
1305
+ * @public
1306
+ * @returns {{ data: SlashCommandSubcommandBuilder; metadata: SubcommandMetadata; }}
1307
+ */
1308
+ build() {
1309
+ return {
1310
+ data: this,
1311
+ metadata: {
1312
+ active: this._active,
1313
+ ownerOnly: this._ownerOnly,
1314
+ permission: this._permission,
1315
+ ephemeralReply: this._ephemeralReply
1316
+ }
1317
+ };
1318
+ }
1319
+ };
1320
+ var Subcommand = class {
1321
+ /**
1322
+ * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
1323
+ *
1324
+ * @async
1325
+ * @param {ChatInputCommandInteraction<CacheType>} interaction
1326
+ * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
1327
+ * @returns {*}
1328
+ */
1329
+ async reply(interaction, options) {
1330
+ if (interaction.replied) {
1331
+ await interaction.editReply(options);
1332
+ return;
1333
+ }
1334
+ const newOptions = { ...options };
1335
+ if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1336
+ await interaction.reply(newOptions);
1337
+ }
1338
+ };
1339
+
1340
+ // src/core/components/component.base.ts
1341
+ var ComponentBuilder = class {
1342
+ _customId = "";
1343
+ _permission = 0 /* USER */;
1344
+ _ephemeralReply = false;
1345
+ /**
1346
+ * Set the customId for the component.
1347
+ *
1348
+ * @public
1349
+ * @param {{
1350
+ * type: ComponentType;
1351
+ * data: string;
1352
+ * tags?: ComponentCustomIdTag[];
1353
+ * }} options
1354
+ * @returns {this}
1355
+ */
1356
+ setCustomId(options) {
1357
+ const { data, type, tags } = options;
1358
+ this._customId = `${type}:${data}${tags ? `.${tags.join(".")}` : ""}`;
1359
+ return this;
1360
+ }
1361
+ /**
1362
+ * Set the permission required to use the component.
1363
+ *
1364
+ * @public
1365
+ * @param {PermissionLevel} permission
1366
+ * @returns {this}
1367
+ */
1368
+ setPermission(permission) {
1369
+ this._permission = permission;
1370
+ return this;
1371
+ }
1372
+ /**
1373
+ * Set the interaction as ephemeral.
1374
+ *
1375
+ * @public
1376
+ * @returns {this}
1377
+ */
1378
+ setEphemeralReply() {
1379
+ this._ephemeralReply = true;
1380
+ return this;
1381
+ }
1382
+ /**
1383
+ * Builder the builder.
1384
+ *
1385
+ * @public
1386
+ * @returns {{ metadata: ComponentMetadata; }}
1387
+ */
1388
+ build() {
1389
+ return {
1390
+ metadata: {
1391
+ customId: this._customId,
1392
+ permission: this._permission,
1393
+ ephemeralReply: this._ephemeralReply
1394
+ }
1395
+ };
1396
+ }
1397
+ };
1398
+ var Component = class {
1399
+ /**
1400
+ * Validate permissions for a user/member in a guild.
1401
+ *
1402
+ * @async
1403
+ * @param {ComponentInteraction} interaction
1404
+ * @param {PermissionLevel} permission
1405
+ * @param {boolean} [doReply=true] Defaults to `true`
1406
+ * @returns {unknown}
1407
+ */
1408
+ async validateGuildPermission(client, interaction, permission, doReply = true) {
1409
+ if (interaction.guild) {
1410
+ const member = interaction.member;
1411
+ const memberHasPermission = hasPermission(client, { permission, member });
1412
+ if (!memberHasPermission) {
1413
+ if (doReply)
1414
+ await this.reply(interaction, {
1415
+ content: `You do not have permission to run this command, required permission: \`${PermissionLevel[permission]}\``
1416
+ });
1417
+ return false;
1418
+ }
1419
+ }
1420
+ return true;
1421
+ }
1422
+ /**
1423
+ * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
1424
+ *
1425
+ * @async
1426
+ * @param {ComponentInteraction} interaction
1427
+ * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
1428
+ * @returns {*}
1429
+ */
1430
+ async reply(interaction, options) {
1431
+ if (interaction.replied) {
1432
+ await interaction.editReply(options);
1433
+ return;
1434
+ }
1435
+ const newOptions = { ...options };
1436
+ if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1437
+ await interaction.reply(newOptions);
1438
+ }
1439
+ };
1440
+
1441
+ exports.BaseRegistry = BaseRegistry;
1442
+ exports.Command = Command;
1443
+ exports.CommandBuilder = CommandBuilder;
1444
+ exports.CommandRegistry = CommandRegistry;
1445
+ exports.Component = Component;
1446
+ exports.ComponentBuilder = ComponentBuilder;
1447
+ exports.ComponentRegistry = ComponentRegistry;
1448
+ exports.ComponentType = ComponentType;
1449
+ exports.ContextMenuBuilder = ContextMenuBuilder;
1450
+ exports.ContextMenuCommand = ContextMenuCommand;
1451
+ exports.PermissionLevel = PermissionLevel;
1452
+ exports.SlashCommand = SlashCommand;
1453
+ exports.Subcommand = Subcommand;
1454
+ exports.SubcommandBuilder = SubcommandBuilder;
1455
+ exports.TriviousClient = TriviousClient;
1456
+ exports.deconstructCustomId = deconstructCustomId;
1457
+ exports.getPermissionLevel = getPermissionLevel;
80
1458
  //# sourceMappingURL=index.cjs.map
81
1459
  //# sourceMappingURL=index.cjs.map