trivious 1.3.21 → 1.3.23

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 +1443 -67
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +979 -3
  4. package/dist/index.d.ts +979 -3
  5. package/dist/index.js +1432 -10
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  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,1457 @@
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 (permission === 5 /* BOT_OWNER */ && client._options.botOwnerIds) return user ? client._options.botOwnerIds.includes(user.id) : member ? client._options.botOwnerIds.includes(member.id) : false;
552
+ if (user) return true;
553
+ if (member) {
554
+ const memberPermission = getPermissionLevel(client, member);
555
+ return memberPermission >= permission;
556
+ }
557
+ return false;
558
+ }
559
+ var BaseRegistry = class {
560
+ /**
561
+ * Get all of loaded T
562
+ *
563
+ * @returns {Collection<string, T>}
564
+ */
565
+ get() {
566
+ return this.items;
567
+ }
568
+ /**
569
+ * Import a file from a path to be loaded.
570
+ *
571
+ * @protected
572
+ * @async
573
+ * @template T
574
+ * @param {string} filePath
575
+ * @returns {Promise<T | null>}
576
+ */
577
+ async importFile(filePath) {
578
+ try {
579
+ const { default: file } = await import(url.pathToFileURL(filePath).href);
580
+ const imports = file.default ?? file;
581
+ if (!imports) return null;
582
+ if (typeof imports === "function" && imports.prototype) {
583
+ return new imports();
584
+ }
585
+ if (typeof imports === "object") {
586
+ if (Object.keys(imports).length === 0) return null;
587
+ return imports;
588
+ }
589
+ console.error(`Invalid export in ${filePath}: expected class or object`);
590
+ return null;
591
+ } catch (error) {
592
+ console.error("Failed to import:", filePath, error);
593
+ return null;
594
+ }
595
+ }
596
+ /**
597
+ * Clear file path cache.
598
+ * Does not run in production environment.
599
+ *
600
+ * @protected
601
+ * @async
602
+ * @param {string} filePath
603
+ * @returns {*}
604
+ */
605
+ async clearCache(filePath) {
606
+ if (process.env.NODE_ENV === "production") return;
607
+ try {
608
+ const resvoled = __require.resolve(filePath);
609
+ delete __require.cache[resvoled];
610
+ } catch {
611
+ }
612
+ }
613
+ };
614
+
615
+ // src/shared/typings/components.ts
616
+ var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
617
+ ComponentType2["Button"] = "button";
618
+ ComponentType2["SelectMenu"] = "select";
619
+ ComponentType2["Modal"] = "modal";
620
+ return ComponentType2;
621
+ })(ComponentType || {});
622
+ var deconstructCustomId = (customId) => {
623
+ const [componentType, dataTags] = customId.split(":");
624
+ const [data, ...tags] = dataTags.split(".");
625
+ return {
626
+ componentType,
627
+ data,
628
+ tags
629
+ };
630
+ };
631
+ var CommandRegistry = class extends BaseRegistry {
632
+ items = new discord_js.Collection();
633
+ /**
634
+ * Load all commands and their subcommands
635
+ *
636
+ * @async
637
+ * @param {string} [directory=getCorePath({ coreDirectory: "commands" })]
638
+ * @returns {unknown}
639
+ */
640
+ async load(directory = getCorePath({ coreDirectory: "commands" })) {
641
+ if (!await exists(directory)) {
642
+ return this;
643
+ }
644
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
645
+ for (const entry of entries) {
646
+ const fullPath = path.join(directory, entry.name);
647
+ if (!entry.isDirectory()) continue;
648
+ const indexFile = path.join(fullPath, "index.ts");
649
+ const indexJs = path.join(fullPath, "index.js");
650
+ let commandFile = "";
651
+ if (await exists(indexFile)) commandFile = indexFile;
652
+ else if (await exists(indexJs)) commandFile = indexJs;
653
+ else continue;
654
+ const command = await this.importFile(commandFile);
655
+ if (!command) continue;
656
+ if (!command.metadata.active) continue;
657
+ if (command.isSlashCommand()) {
658
+ const subcommandFiles = (await fs.promises.readdir(fullPath)).filter(
659
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
660
+ );
661
+ for (const file of subcommandFiles) {
662
+ const subcommand = await this.importFile(path.join(fullPath, file));
663
+ if (!subcommand) continue;
664
+ if (!subcommand.data.name || !(subcommand.data instanceof discord_js.SlashCommandSubcommandBuilder))
665
+ continue;
666
+ command.data.addSubcommand(subcommand.data);
667
+ command.metadata.subcommands.set(subcommand.data.name, subcommand);
668
+ }
669
+ }
670
+ this.items.set(command.data.name, command);
671
+ }
672
+ return this;
673
+ }
674
+ };
675
+ var ComponentRegistry = class extends BaseRegistry {
676
+ items = new discord_js.Collection();
677
+ /**
678
+ * Load all components.
679
+ *
680
+ * @async
681
+ * @param {string} [directory=getCorePath({ coreDirectory: "components" })]
682
+ * @returns {Promise<this>}
683
+ */
684
+ async load(directory = getCorePath({ coreDirectory: "components" })) {
685
+ if (!await exists(directory)) {
686
+ return this;
687
+ }
688
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
689
+ for (const entry of entries) {
690
+ const fullPath = path.join(directory, entry.name);
691
+ if (!entry.isDirectory()) continue;
692
+ const componentFiles = (await fs.promises.readdir(fullPath)).filter(
693
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
694
+ );
695
+ for (const file of componentFiles) {
696
+ const component = await this.importFile(path.join(fullPath, file));
697
+ if (!component) continue;
698
+ const { data } = deconstructCustomId(component.metadata.customId);
699
+ this.items.set(data, component);
700
+ }
701
+ }
702
+ return this;
703
+ }
704
+ };
705
+ var interactionCreate_default = {
706
+ name: "interactionCreate",
707
+ execute: async (client, interaction) => {
708
+ if (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {
709
+ const { commandName } = interaction;
710
+ const registeredCommands = client.registries.commands.get();
711
+ const command = registeredCommands.get(commandName);
712
+ if (!command) {
713
+ await interaction.reply({
714
+ content: `Command is outdated, inactive or does not have a handler!`,
715
+ flags: ["Ephemeral"]
716
+ });
717
+ return;
718
+ }
719
+ const requiredPermission = command.metadata.permission;
720
+ const hasPermission2 = await command.validateGuildPermission(
721
+ client,
722
+ interaction,
723
+ requiredPermission
724
+ );
725
+ if (!hasPermission2) return;
726
+ if (!("execute" in command)) {
727
+ await command.reply(interaction, { content: "Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!" });
728
+ return;
729
+ }
730
+ await command.reply(interaction, { content: "Processing command..." });
731
+ if (interaction.isChatInputCommand() && command.isSlashCommand()) {
732
+ await command.execute(client, interaction);
733
+ } else if (interaction.isContextMenuCommand() && command.isContextMenuCommand()) {
734
+ await command.execute(client, interaction);
735
+ }
736
+ } else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
737
+ const { componentType, tags, data } = deconstructCustomId(interaction.customId);
738
+ if (componentType === "button" /* Button */ && !(interaction instanceof discord_js.ButtonInteraction))
739
+ return;
740
+ if (componentType === "modal" /* Modal */ && !(interaction instanceof discord_js.ModalSubmitInteraction))
741
+ return;
742
+ if (tags.includes("awaited")) return;
743
+ const registeredComponents = client.registries.components.get();
744
+ const component = registeredComponents.get(data);
745
+ if (!component) {
746
+ await interaction.reply({
747
+ content: `Command is outdated, inactive or does not have a handler!`,
748
+ flags: ["Ephemeral"]
749
+ });
750
+ return;
751
+ }
752
+ const requiredPermission = component.metadata.permission;
753
+ const hasPermission2 = await component.validateGuildPermission(
754
+ client,
755
+ interaction,
756
+ requiredPermission
757
+ );
758
+ if (!hasPermission2) return;
759
+ if (!interaction.isModalSubmit()) await interaction.deferUpdate();
760
+ await component.execute(client, interaction);
761
+ }
762
+ }
763
+ };
764
+
765
+ // src/core/registry/event.registry.ts
766
+ var EventRegistry = class extends BaseRegistry {
767
+ items = new discord_js.Collection();
768
+ /**
769
+ * Load all events.
770
+ *
771
+ * @async
772
+ * @param {string} [directory=getCorePath({ coreDirectory: "events" })]
773
+ * @returns {Promise<this>}
774
+ */
775
+ async load(directory = getCorePath({ coreDirectory: "events" })) {
776
+ if (!await exists(directory)) return this;
777
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
778
+ for (const entry of entries) {
779
+ const fullPath = path.join(directory, entry.name);
780
+ if (entry.isDirectory()) {
781
+ await this.load(fullPath);
782
+ continue;
783
+ }
784
+ if (entry.isFile() && entry.name.endsWith(".js")) {
785
+ const event = await this.importFile(fullPath);
786
+ if (!event) continue;
787
+ this.items.set(event.name, event);
788
+ }
789
+ }
790
+ this.items.set(interactionCreate_default.name, interactionCreate_default);
791
+ return this;
792
+ }
793
+ /**
794
+ * Bind loaded events to their client events respectively.
795
+ *
796
+ * @param {TriviousClient} client
797
+ */
798
+ bind(client) {
799
+ for (const event of this.items.values()) {
800
+ const handler = (...args) => void event.execute(client, ...args);
801
+ if (event.once) client.once(event.name, handler);
802
+ else client.on(event.name, handler);
803
+ }
804
+ }
805
+ };
806
+ var ModuleRegistry = class extends BaseRegistry {
807
+ items = new discord_js.Collection();
808
+ /**
809
+ * Load all modules.
810
+ *
811
+ * @async
812
+ * @param {string} [directory=getCorePath({ coreDirectory: "module" })]
813
+ * @returns {Promise<this>}
814
+ */
815
+ async load(directory = getCorePath({ coreDirectory: "module" })) {
816
+ if (!await exists(directory)) {
817
+ return this;
818
+ }
819
+ const entries = await fs.promises.readdir(directory, { withFileTypes: true });
820
+ for (const entry of entries) {
821
+ const fullPath = path.join(directory, entry.name);
822
+ if (!entry.isDirectory()) continue;
823
+ const moduleFiles = (await fs.promises.readdir(fullPath)).filter(
824
+ (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
825
+ );
826
+ for (const file of moduleFiles) {
827
+ const moduleEvent = await this.importFile(path.join(fullPath, file));
828
+ if (!moduleEvent || !moduleEvent.events) continue;
829
+ this.items.set(moduleEvent.name, moduleEvent);
830
+ }
831
+ }
832
+ return this;
833
+ }
834
+ /**
835
+ * Bind all loaded modules to their client event respectively.
836
+ *
837
+ * @param {TriviousClient} client
838
+ */
839
+ bind(client) {
840
+ for (const mod of this.items.values()) {
841
+ for (const [eventName, handler] of Object.entries(mod.events)) {
842
+ if (typeof handler !== "function") continue;
843
+ const listener = (...args) => {
844
+ void handler(client, ...args);
845
+ };
846
+ client.on(eventName, listener);
847
+ }
848
+ }
849
+ }
850
+ };
851
+ var registries = () => ({
852
+ commands: new CommandRegistry(),
853
+ components: new ComponentRegistry(),
854
+ events: new EventRegistry(),
855
+ modules: new ModuleRegistry(),
856
+ async loadAll(options) {
857
+ const corePaths = options.corePaths;
858
+ const corePath = options.corePath;
859
+ await Promise.all([
860
+ this.commands.load(
861
+ corePath ? resolveUserPath(path__default.default.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
862
+ ),
863
+ this.components.load(
864
+ corePath ? resolveUserPath(path__default.default.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
865
+ ),
866
+ this.events.load(
867
+ corePath ? resolveUserPath(path__default.default.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
868
+ ),
869
+ this.modules.load(
870
+ corePath ? resolveUserPath(path__default.default.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
871
+ )
872
+ ]);
873
+ },
874
+ bind(client) {
875
+ this.events.bind(client);
876
+ this.modules.bind(client);
877
+ }
79
878
  });
879
+
880
+ // src/core/client/trivious.client.ts
881
+ var TriviousClient = class extends discord_js.Client {
882
+ /**
883
+ * Client registries.
884
+ *
885
+ * @public
886
+ * @readonly
887
+ * @type {*}
888
+ */
889
+ registries = registries();
890
+ /**
891
+ * Client copy of the constructor options.
892
+ *
893
+ * @private
894
+ * @type {TriviousClientOptions}
895
+ */
896
+ _options;
897
+ /**
898
+ * Creates an instance of TriviousClient.
899
+ *
900
+ * @constructor
901
+ * @param {TriviousClientOptions} options
902
+ */
903
+ constructor(options) {
904
+ super(options);
905
+ this._options = options;
906
+ }
907
+ /**
908
+ * Load all registries.
909
+ *
910
+ * @async
911
+ * @returns {*}
912
+ */
913
+ async register() {
914
+ const { registries: registries2 } = this;
915
+ await registries2.loadAll(this._options);
916
+ console.log(
917
+ `[Trivious] Loaded all registries (${registries2.commands.get().size} commands, ${registries2.events.get().size} events, ${registries2.components.get().size} components, ${registries2.modules.get().size} modules)`
918
+ );
919
+ }
920
+ /**
921
+ * Login and start the bot.
922
+ *
923
+ * @async
924
+ * @returns {*}
925
+ */
926
+ async start() {
927
+ if (!process.env[this._options.tokenReference]) {
928
+ if (process.env.NODE_ENV !== "production") return;
929
+ else throw new Error("[Trivious] Invalid token reference");
930
+ }
931
+ this.registries.bind(this);
932
+ await this.login(process.env[this._options.tokenReference]);
933
+ }
934
+ /**
935
+ * Deploy all commands.
936
+ *
937
+ * @async
938
+ * @returns {*}
939
+ */
940
+ async deploy() {
941
+ const clientId = process.env[this._options.clientIdReference];
942
+ const token = process.env[this._options.tokenReference];
943
+ if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
944
+ const slashCommands = Array.from(this.registries.commands.get().values());
945
+ const body = [...slashCommands.map((command) => command.toJSON())];
946
+ const rest = new discord_js.REST({ version: "10" }).setToken(token);
947
+ await rest.put(discord_js.Routes.applicationCommands(clientId), { body });
948
+ console.log(`[Trivious] Deployed ${body.length} commands`);
949
+ }
950
+ /**
951
+ * Set the roles tied to a permission level.
952
+ *
953
+ * @param {Record<string, PermissionLevel>} roles
954
+ */
955
+ setRolePermissions(roles) {
956
+ this._options.rolePermissions = roles;
957
+ }
958
+ get rolePermissions() {
959
+ return this._options.rolePermissions ?? {};
960
+ }
961
+ };
962
+ var Command = class {
963
+ /**
964
+ * Returns whether the command is a SlashCommand.
965
+ *
966
+ * @public
967
+ * @param {Command} this
968
+ * @returns {this is SlashCommand}
969
+ */
970
+ isSlashCommand() {
971
+ return this.data instanceof discord_js.SlashCommandBuilder && this instanceof SlashCommand;
972
+ }
973
+ /**
974
+ * Returns whether the command is a ContextMenuCommand.
975
+ *
976
+ * @public
977
+ * @param {Command} this
978
+ * @returns {this is ContextMenuCommand}
979
+ */
980
+ isContextMenuCommand() {
981
+ return this.data instanceof discord_js.ContextMenuCommandBuilder && this instanceof ContextMenuCommand;
982
+ }
983
+ /**
984
+ * Returns JSON of the command builder.
985
+ *
986
+ * @public
987
+ * @returns {*}
988
+ */
989
+ toJSON() {
990
+ return this.data.toJSON();
991
+ }
992
+ /**
993
+ * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
994
+ *
995
+ * @public
996
+ * @async
997
+ * @param {CommandInteraction} interaction
998
+ * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
999
+ * @returns {*}
1000
+ */
1001
+ async reply(interaction, options) {
1002
+ if (interaction.replied) {
1003
+ await interaction.editReply(options);
1004
+ return;
1005
+ }
1006
+ const newOptions = { ...options };
1007
+ if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1008
+ await interaction.reply(newOptions);
1009
+ }
1010
+ /**
1011
+ * Validate permissions for a user/member in a guild.
1012
+ *
1013
+ * @async
1014
+ * @param {CommandInteraction} interaction
1015
+ * @param {PermissionLevel} permission
1016
+ * @param {boolean} [doReply=true]
1017
+ * @returns {unknown}
1018
+ */
1019
+ async validateGuildPermission(client, interaction, permission, doReply = true) {
1020
+ const isContextMenu = interaction.isContextMenuCommand();
1021
+ const isChatInput = interaction.isChatInputCommand();
1022
+ const requiresGuildCheck = isContextMenu || isChatInput && (this.isSlashCommand() ? this.metadata.guildOnly : false);
1023
+ if (!requiresGuildCheck) return true;
1024
+ const member = interaction.member;
1025
+ const memberHasPermission = hasPermission(client, { permission, member });
1026
+ if (!memberHasPermission && doReply) {
1027
+ await this.reply(interaction, {
1028
+ content: `You do not have permission to run this command, required permission: \`${PermissionLevel[permission]}\``
1029
+ });
1030
+ }
1031
+ return memberHasPermission;
1032
+ }
1033
+ };
1034
+ var SlashCommand = class extends Command {
1035
+ /**
1036
+ * Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
1037
+ *
1038
+ * @abstract
1039
+ * @type {?(
1040
+ * client: TriviousClient,
1041
+ * interaction: ChatInputCommandInteraction
1042
+ * ) => Promise<void>}
1043
+ */
1044
+ run;
1045
+ /**
1046
+ * General handler for the command and its subcommand, if applicable.
1047
+ *
1048
+ * @public
1049
+ * @async
1050
+ * @param {TriviousClient} client
1051
+ * @param {ChatInputCommandInteraction} interaction
1052
+ * @returns {*}
1053
+ */
1054
+ async execute(client, interaction) {
1055
+ const { run, reply, metadata } = this;
1056
+ const { options } = interaction;
1057
+ if (run) {
1058
+ const memberHasPermission2 = await this.validateGuildPermission(
1059
+ client,
1060
+ interaction,
1061
+ metadata.permission,
1062
+ false
1063
+ );
1064
+ if (memberHasPermission2) await run(client, interaction);
1065
+ }
1066
+ const subcommands = metadata.subcommands;
1067
+ if (subcommands.size <= 0) return;
1068
+ const subcommand = metadata.subcommands.find(
1069
+ (subcmd) => subcmd.data.name === options.getSubcommand()
1070
+ );
1071
+ if (!subcommand) {
1072
+ await reply(interaction, {
1073
+ content: "Ran subcommand is outdated or does not have a handler!"
1074
+ });
1075
+ return;
1076
+ }
1077
+ const memberHasPermission = await this.validateGuildPermission(
1078
+ client,
1079
+ interaction,
1080
+ subcommand.metadata.permission
1081
+ );
1082
+ if (!memberHasPermission) return;
1083
+ await subcommand.execute(client, interaction);
1084
+ }
1085
+ };
1086
+ var CommandBuilder = class extends discord_js.SlashCommandBuilder {
1087
+ _active = true;
1088
+ _guildOnly = false;
1089
+ _ownerOnly = false;
1090
+ _permission = 0 /* USER */;
1091
+ _subcommands = new discord_js.Collection();
1092
+ _ephemeralReply = false;
1093
+ /**
1094
+ * Set the command as disabled.
1095
+ *
1096
+ * @public
1097
+ * @returns {this}
1098
+ */
1099
+ disable() {
1100
+ this._active = false;
1101
+ return this;
1102
+ }
1103
+ /**
1104
+ * Set the command as guild only.
1105
+ *
1106
+ * @public
1107
+ * @returns {this}
1108
+ */
1109
+ setGuildOnly() {
1110
+ this._guildOnly = true;
1111
+ this._permission = 0 /* USER */;
1112
+ this.setContexts(discord_js.InteractionContextType.Guild);
1113
+ return this;
1114
+ }
1115
+ /**
1116
+ * Set the command as public only.
1117
+ *
1118
+ * @public
1119
+ * @returns {this}
1120
+ */
1121
+ setOwnerOnly() {
1122
+ this._permission = 5 /* BOT_OWNER */;
1123
+ return this;
1124
+ }
1125
+ /**
1126
+ * Set the permission level required to run the command.
1127
+ *
1128
+ * @public
1129
+ * @param {PermissionLevel} permission
1130
+ * @returns {this}
1131
+ */
1132
+ setPermission(permission) {
1133
+ if (!this._guildOnly) return this;
1134
+ this._permission = permission;
1135
+ return this;
1136
+ }
1137
+ /**
1138
+ * Set the interaction as ephemeral.
1139
+ *
1140
+ * @public
1141
+ * @returns {this}
1142
+ */
1143
+ setEphemeralReply() {
1144
+ this._ephemeralReply = true;
1145
+ return this;
1146
+ }
1147
+ /**
1148
+ * Build the builder.
1149
+ *
1150
+ * @public
1151
+ * @returns {{ data: CommandBuilder; metadata: CommandMetadata; }}
1152
+ */
1153
+ build() {
1154
+ return {
1155
+ data: this,
1156
+ metadata: {
1157
+ active: this._active,
1158
+ guildOnly: this._guildOnly,
1159
+ ownerOnly: this._ownerOnly,
1160
+ permission: this._permission,
1161
+ subcommands: this._subcommands,
1162
+ ephemeralReply: this._ephemeralReply
1163
+ }
1164
+ };
1165
+ }
1166
+ };
1167
+ var ContextMenuCommand = class extends Command {
1168
+ /**
1169
+ * Base command handler.
1170
+ *
1171
+ * @public
1172
+ * @async
1173
+ * @param {TriviousClient} client
1174
+ * @param {ContextMenuCommandInteraction} interaction
1175
+ * @returns {*}
1176
+ */
1177
+ async execute(client, interaction) {
1178
+ const { run, metadata } = this;
1179
+ const memberHasPermission = await this.validateGuildPermission(
1180
+ client,
1181
+ interaction,
1182
+ metadata.permission,
1183
+ false
1184
+ );
1185
+ if (memberHasPermission) await run(client, interaction);
1186
+ }
1187
+ };
1188
+ var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
1189
+ _active = true;
1190
+ _ownerOnly = false;
1191
+ _permission = 0 /* USER */;
1192
+ _ephemeralReply = false;
1193
+ /**
1194
+ * Set the command as disabled.
1195
+ *
1196
+ * @public
1197
+ * @returns {this}
1198
+ */
1199
+ disable() {
1200
+ this._active = false;
1201
+ return this;
1202
+ }
1203
+ /**
1204
+ * Set the command as owner only.
1205
+ *
1206
+ * @public
1207
+ * @returns {this}
1208
+ */
1209
+ setOwnerOnly() {
1210
+ this._permission = 5 /* BOT_OWNER */;
1211
+ this._ownerOnly = true;
1212
+ return this;
1213
+ }
1214
+ /**
1215
+ * Set the permission level required to run the command.
1216
+ *
1217
+ * @public
1218
+ * @param {PermissionLevel} permission
1219
+ * @returns {this}
1220
+ */
1221
+ setPermission(permission) {
1222
+ this._permission = permission;
1223
+ return this;
1224
+ }
1225
+ /**
1226
+ * Set the interaction as ephemeral.
1227
+ *
1228
+ * @public
1229
+ * @returns {this}
1230
+ */
1231
+ setEphemeralReply() {
1232
+ this._ephemeralReply = true;
1233
+ return this;
1234
+ }
1235
+ /**
1236
+ * Build the builder
1237
+ *
1238
+ * @public
1239
+ * @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
1240
+ */
1241
+ build() {
1242
+ return {
1243
+ data: this,
1244
+ metadata: {
1245
+ active: this._active,
1246
+ ownerOnly: this._ownerOnly,
1247
+ permission: this._permission,
1248
+ ephemeralReply: this._ephemeralReply
1249
+ }
1250
+ };
1251
+ }
1252
+ };
1253
+ var SubcommandBuilder = class extends discord_js.SlashCommandSubcommandBuilder {
1254
+ _active = true;
1255
+ _ownerOnly = false;
1256
+ _permission = 0 /* USER */;
1257
+ _ephemeralReply = false;
1258
+ /**
1259
+ * Set the subcommand as disabled.
1260
+ *
1261
+ * @public
1262
+ * @returns {this}
1263
+ */
1264
+ disable() {
1265
+ this._active = false;
1266
+ return this;
1267
+ }
1268
+ /**
1269
+ * Set the subcommand as owner only.
1270
+ *
1271
+ * @public
1272
+ * @returns {this}
1273
+ */
1274
+ setOwnerOnly() {
1275
+ this._permission = 5 /* BOT_OWNER */;
1276
+ this._ownerOnly = true;
1277
+ return this;
1278
+ }
1279
+ /**
1280
+ * Set the permission level required to run the subcommand.
1281
+ *
1282
+ * @public
1283
+ * @param {PermissionLevel} permission
1284
+ * @returns {this}
1285
+ */
1286
+ setPermission(permission) {
1287
+ this._permission = permission;
1288
+ return this;
1289
+ }
1290
+ /**
1291
+ * Set the interaction as ephemeral
1292
+ *
1293
+ * @public
1294
+ * @returns {this}
1295
+ */
1296
+ setEphemeralReply() {
1297
+ this._ephemeralReply = true;
1298
+ return this;
1299
+ }
1300
+ /**
1301
+ * Build the builder.
1302
+ *
1303
+ * @public
1304
+ * @returns {{ data: SlashCommandSubcommandBuilder; metadata: SubcommandMetadata; }}
1305
+ */
1306
+ build() {
1307
+ return {
1308
+ data: this,
1309
+ metadata: {
1310
+ active: this._active,
1311
+ ownerOnly: this._ownerOnly,
1312
+ permission: this._permission,
1313
+ ephemeralReply: this._ephemeralReply
1314
+ }
1315
+ };
1316
+ }
1317
+ };
1318
+ var Subcommand = class {
1319
+ /**
1320
+ * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
1321
+ *
1322
+ * @async
1323
+ * @param {ChatInputCommandInteraction<CacheType>} interaction
1324
+ * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
1325
+ * @returns {*}
1326
+ */
1327
+ async reply(interaction, options) {
1328
+ if (interaction.replied) {
1329
+ await interaction.editReply(options);
1330
+ return;
1331
+ }
1332
+ const newOptions = { ...options };
1333
+ if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1334
+ await interaction.reply(newOptions);
1335
+ }
1336
+ };
1337
+
1338
+ // src/core/components/component.base.ts
1339
+ var ComponentBuilder = class {
1340
+ _customId = "";
1341
+ _permission = 0 /* USER */;
1342
+ _ephemeralReply = false;
1343
+ /**
1344
+ * Set the customId for the component.
1345
+ *
1346
+ * @public
1347
+ * @param {{
1348
+ * type: ComponentType;
1349
+ * data: string;
1350
+ * tags?: ComponentCustomIdTag[];
1351
+ * }} options
1352
+ * @returns {this}
1353
+ */
1354
+ setCustomId(options) {
1355
+ const { data, type, tags } = options;
1356
+ this._customId = `${type}:${data}${tags ? `.${tags.join(".")}` : ""}`;
1357
+ return this;
1358
+ }
1359
+ /**
1360
+ * Set the permission required to use the component.
1361
+ *
1362
+ * @public
1363
+ * @param {PermissionLevel} permission
1364
+ * @returns {this}
1365
+ */
1366
+ setPermission(permission) {
1367
+ this._permission = permission;
1368
+ return this;
1369
+ }
1370
+ /**
1371
+ * Set the interaction as ephemeral.
1372
+ *
1373
+ * @public
1374
+ * @returns {this}
1375
+ */
1376
+ setEphemeralReply() {
1377
+ this._ephemeralReply = true;
1378
+ return this;
1379
+ }
1380
+ /**
1381
+ * Builder the builder.
1382
+ *
1383
+ * @public
1384
+ * @returns {{ metadata: ComponentMetadata; }}
1385
+ */
1386
+ build() {
1387
+ return {
1388
+ metadata: {
1389
+ customId: this._customId,
1390
+ permission: this._permission,
1391
+ ephemeralReply: this._ephemeralReply
1392
+ }
1393
+ };
1394
+ }
1395
+ };
1396
+ var Component = class {
1397
+ /**
1398
+ * Validate permissions for a user/member in a guild.
1399
+ *
1400
+ * @async
1401
+ * @param {ComponentInteraction} interaction
1402
+ * @param {PermissionLevel} permission
1403
+ * @param {boolean} [doReply=true] Defaults to `true`
1404
+ * @returns {unknown}
1405
+ */
1406
+ async validateGuildPermission(client, interaction, permission, doReply = true) {
1407
+ if (interaction.guild) {
1408
+ const member = interaction.member;
1409
+ const memberHasPermission = hasPermission(client, { permission, member });
1410
+ if (!memberHasPermission) {
1411
+ if (doReply)
1412
+ await this.reply(interaction, {
1413
+ content: `You do not have permission to run this command, required permission: \`${PermissionLevel[permission]}\``
1414
+ });
1415
+ return false;
1416
+ }
1417
+ }
1418
+ return true;
1419
+ }
1420
+ /**
1421
+ * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
1422
+ *
1423
+ * @async
1424
+ * @param {ComponentInteraction} interaction
1425
+ * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
1426
+ * @returns {*}
1427
+ */
1428
+ async reply(interaction, options) {
1429
+ if (interaction.replied) {
1430
+ await interaction.editReply(options);
1431
+ return;
1432
+ }
1433
+ const newOptions = { ...options };
1434
+ if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1435
+ await interaction.reply(newOptions);
1436
+ }
1437
+ };
1438
+
1439
+ exports.BaseRegistry = BaseRegistry;
1440
+ exports.Command = Command;
1441
+ exports.CommandBuilder = CommandBuilder;
1442
+ exports.CommandRegistry = CommandRegistry;
1443
+ exports.Component = Component;
1444
+ exports.ComponentBuilder = ComponentBuilder;
1445
+ exports.ComponentRegistry = ComponentRegistry;
1446
+ exports.ComponentType = ComponentType;
1447
+ exports.ContextMenuBuilder = ContextMenuBuilder;
1448
+ exports.ContextMenuCommand = ContextMenuCommand;
1449
+ exports.PermissionLevel = PermissionLevel;
1450
+ exports.SlashCommand = SlashCommand;
1451
+ exports.Subcommand = Subcommand;
1452
+ exports.SubcommandBuilder = SubcommandBuilder;
1453
+ exports.TriviousClient = TriviousClient;
1454
+ exports.deconstructCustomId = deconstructCustomId;
1455
+ exports.getPermissionLevel = getPermissionLevel;
80
1456
  //# sourceMappingURL=index.cjs.map
81
1457
  //# sourceMappingURL=index.cjs.map