trivious 1.3.16 → 1.3.18

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 (131) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +126 -126
  3. package/dist/core/client/trivious.client.cjs +90 -0
  4. package/dist/core/client/trivious.client.cjs.map +1 -0
  5. package/dist/core/client/trivious.client.d.cts +3 -0
  6. package/dist/core/client/trivious.client.d.ts +3 -0
  7. package/dist/core/client/trivious.client.js +88 -0
  8. package/dist/core/client/trivious.client.js.map +1 -0
  9. package/dist/core/commands/command.base.cjs +224 -0
  10. package/dist/core/commands/command.base.cjs.map +1 -0
  11. package/dist/core/commands/command.base.d.cts +3 -0
  12. package/dist/core/commands/command.base.d.ts +3 -0
  13. package/dist/core/commands/command.base.js +214 -0
  14. package/dist/core/commands/command.base.js.map +1 -0
  15. package/dist/core/commands/contextcommand.base.cjs +98 -0
  16. package/dist/core/commands/contextcommand.base.cjs.map +1 -0
  17. package/dist/core/commands/contextcommand.base.d.cts +3 -0
  18. package/dist/core/commands/contextcommand.base.d.ts +3 -0
  19. package/dist/core/commands/contextcommand.base.js +93 -0
  20. package/dist/core/commands/contextcommand.base.js.map +1 -0
  21. package/dist/core/commands/subcommand.base.cjs +96 -0
  22. package/dist/core/commands/subcommand.base.cjs.map +1 -0
  23. package/dist/core/commands/subcommand.base.d.cts +3 -0
  24. package/dist/core/commands/subcommand.base.d.ts +3 -0
  25. package/dist/core/commands/subcommand.base.js +91 -0
  26. package/dist/core/commands/subcommand.base.js.map +1 -0
  27. package/dist/core/components/component.base.cjs +111 -0
  28. package/dist/core/components/component.base.cjs.map +1 -0
  29. package/dist/core/components/component.base.d.cts +3 -0
  30. package/dist/core/components/component.base.d.ts +3 -0
  31. package/dist/core/components/component.base.js +106 -0
  32. package/dist/core/components/component.base.js.map +1 -0
  33. package/dist/core/events/interactionCreate.cjs +68 -0
  34. package/dist/core/events/interactionCreate.cjs.map +1 -0
  35. package/dist/core/events/interactionCreate.d.cts +10 -0
  36. package/dist/core/events/interactionCreate.d.ts +10 -0
  37. package/dist/core/events/interactionCreate.js +66 -0
  38. package/dist/core/events/interactionCreate.js.map +1 -0
  39. package/dist/core/registry/command.registry.cjs +56 -0
  40. package/dist/core/registry/command.registry.cjs.map +1 -0
  41. package/dist/core/registry/command.registry.d.cts +3 -0
  42. package/dist/core/registry/command.registry.d.ts +3 -0
  43. package/dist/core/registry/command.registry.js +54 -0
  44. package/dist/core/registry/command.registry.js.map +1 -0
  45. package/dist/core/registry/component.registry.cjs +42 -0
  46. package/dist/core/registry/component.registry.cjs.map +1 -0
  47. package/dist/core/registry/component.registry.d.cts +3 -0
  48. package/dist/core/registry/component.registry.d.ts +3 -0
  49. package/dist/core/registry/component.registry.js +40 -0
  50. package/dist/core/registry/component.registry.js.map +1 -0
  51. package/dist/core/registry/event.registry.cjs +57 -0
  52. package/dist/core/registry/event.registry.cjs.map +1 -0
  53. package/dist/core/registry/event.registry.d.cts +3 -0
  54. package/dist/core/registry/event.registry.d.ts +3 -0
  55. package/dist/core/registry/event.registry.js +51 -0
  56. package/dist/core/registry/event.registry.js.map +1 -0
  57. package/dist/core/registry/index.cjs +49 -0
  58. package/dist/core/registry/index.cjs.map +1 -0
  59. package/dist/core/registry/index.d.cts +19 -0
  60. package/dist/core/registry/index.d.ts +19 -0
  61. package/dist/core/registry/index.js +39 -0
  62. package/dist/core/registry/index.js.map +1 -0
  63. package/dist/core/registry/module.registry.cjs +57 -0
  64. package/dist/core/registry/module.registry.cjs.map +1 -0
  65. package/dist/core/registry/module.registry.d.cts +3 -0
  66. package/dist/core/registry/module.registry.d.ts +3 -0
  67. package/dist/core/registry/module.registry.js +55 -0
  68. package/dist/core/registry/module.registry.js.map +1 -0
  69. package/dist/index-BCF4f686.d.cts +927 -0
  70. package/dist/index-uczj1Waw.d.ts +927 -0
  71. package/dist/index.cjs +67 -1430
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +2 -974
  74. package/dist/index.d.ts +2 -974
  75. package/dist/index.js +10 -1420
  76. package/dist/index.js.map +1 -1
  77. package/dist/shared/typings/client.cjs +4 -0
  78. package/dist/shared/typings/client.cjs.map +1 -0
  79. package/dist/shared/typings/client.d.cts +3 -0
  80. package/dist/shared/typings/client.d.ts +3 -0
  81. package/dist/shared/typings/client.js +3 -0
  82. package/dist/shared/typings/client.js.map +1 -0
  83. package/dist/shared/typings/commands.cjs +4 -0
  84. package/dist/shared/typings/commands.cjs.map +1 -0
  85. package/dist/shared/typings/commands.d.cts +3 -0
  86. package/dist/shared/typings/commands.d.ts +3 -0
  87. package/dist/shared/typings/commands.js +3 -0
  88. package/dist/shared/typings/commands.js.map +1 -0
  89. package/dist/shared/typings/components.cjs +22 -0
  90. package/dist/shared/typings/components.cjs.map +1 -0
  91. package/dist/shared/typings/components.d.cts +3 -0
  92. package/dist/shared/typings/components.d.ts +3 -0
  93. package/dist/shared/typings/components.js +19 -0
  94. package/dist/shared/typings/components.js.map +1 -0
  95. package/dist/shared/typings/events.cjs +4 -0
  96. package/dist/shared/typings/events.cjs.map +1 -0
  97. package/dist/shared/typings/events.d.cts +3 -0
  98. package/dist/shared/typings/events.d.ts +3 -0
  99. package/dist/shared/typings/events.js +3 -0
  100. package/dist/shared/typings/events.js.map +1 -0
  101. package/dist/shared/typings/index.cjs +56 -0
  102. package/dist/shared/typings/index.cjs.map +1 -0
  103. package/dist/shared/typings/index.d.cts +3 -0
  104. package/dist/shared/typings/index.d.ts +3 -0
  105. package/dist/shared/typings/index.js +9 -0
  106. package/dist/shared/typings/index.js.map +1 -0
  107. package/dist/shared/typings/module.cjs +4 -0
  108. package/dist/shared/typings/module.cjs.map +1 -0
  109. package/dist/shared/typings/module.d.cts +3 -0
  110. package/dist/shared/typings/module.d.ts +3 -0
  111. package/dist/shared/typings/module.js +3 -0
  112. package/dist/shared/typings/module.js.map +1 -0
  113. package/dist/shared/typings/permissions.cjs +22 -0
  114. package/dist/shared/typings/permissions.cjs.map +1 -0
  115. package/dist/shared/typings/permissions.d.cts +3 -0
  116. package/dist/shared/typings/permissions.d.ts +3 -0
  117. package/dist/shared/typings/permissions.js +19 -0
  118. package/dist/shared/typings/permissions.js.map +1 -0
  119. package/dist/shared/typings/registry.cjs +63 -0
  120. package/dist/shared/typings/registry.cjs.map +1 -0
  121. package/dist/shared/typings/registry.d.cts +51 -0
  122. package/dist/shared/typings/registry.d.ts +51 -0
  123. package/dist/shared/typings/registry.js +61 -0
  124. package/dist/shared/typings/registry.js.map +1 -0
  125. package/dist/shared/utility/functions.cjs +81 -0
  126. package/dist/shared/utility/functions.cjs.map +1 -0
  127. package/dist/shared/utility/functions.d.cts +56 -0
  128. package/dist/shared/utility/functions.d.ts +56 -0
  129. package/dist/shared/utility/functions.js +74 -0
  130. package/dist/shared/utility/functions.js.map +1 -0
  131. package/package.json +75 -75
package/dist/index.cjs CHANGED
@@ -1,1429 +1,77 @@
1
1
  'use strict';
2
2
 
3
- require('util');
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');
4
13
  var discord_js = require('discord.js');
5
- var fs = require('fs');
6
- var path = require('path');
7
- var url = require('url');
8
14
 
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
16
 
12
- var path__default = /*#__PURE__*/_interopDefault(path);
17
+ var trivious_client_js__default = /*#__PURE__*/_interopDefault(trivious_client_js);
18
+ var command_base_js__default = /*#__PURE__*/_interopDefault(command_base_js);
19
+ var subcommand_base_js__default = /*#__PURE__*/_interopDefault(subcommand_base_js);
20
+ var contextcommand_base_js__default = /*#__PURE__*/_interopDefault(contextcommand_base_js);
21
+ var command_registry_js__default = /*#__PURE__*/_interopDefault(command_registry_js);
22
+ var component_base_js__default = /*#__PURE__*/_interopDefault(component_base_js);
23
+ var component_registry_js__default = /*#__PURE__*/_interopDefault(component_registry_js);
13
24
 
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');
20
- });
21
- var __commonJS = (cb, mod) => function __require2() {
22
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
23
- };
24
25
 
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
- }
91
- });
92
26
 
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
- }
27
+ Object.defineProperty(exports, "TriviousClient", {
28
+ enumerable: true,
29
+ get: function () { return trivious_client_js__default.default; }
420
30
  });
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
- }
31
+ Object.defineProperty(exports, "Command", {
32
+ enumerable: true,
33
+ get: function () { return command_base_js__default.default; }
446
34
  });
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
- }
35
+ Object.defineProperty(exports, "CommandBuilder", {
36
+ enumerable: true,
37
+ get: function () { return command_base_js.CommandBuilder; }
466
38
  });
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
- await command.reply(interaction, { content: "Processing command..." });
729
- if (interaction.isChatInputCommand() && command.isSlashCommand()) {
730
- await command.execute(client, interaction);
731
- } else if (interaction.isContextMenuCommand() && command.isContextMenuCommand()) {
732
- await command.execute(client, interaction);
733
- }
734
- } else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
735
- const { componentType, tags, data } = deconstructCustomId(interaction.customId);
736
- if (componentType === "button" /* Button */ && !(interaction instanceof discord_js.ButtonInteraction))
737
- return;
738
- if (componentType === "modal" /* Modal */ && !(interaction instanceof discord_js.ModalSubmitInteraction))
739
- return;
740
- if (tags.includes("awaited")) return;
741
- const registeredComponents = client.registries.components.get();
742
- const component = registeredComponents.get(data);
743
- if (!component) {
744
- await interaction.reply({
745
- content: `Command is outdated, inactive or does not have a handler!`,
746
- flags: ["Ephemeral"]
747
- });
748
- return;
749
- }
750
- const requiredPermission = component.metadata.permission;
751
- const hasPermission2 = await component.validateGuildPermission(
752
- client,
753
- interaction,
754
- requiredPermission
755
- );
756
- if (!hasPermission2) return;
757
- if (!interaction.isModalSubmit()) await interaction.deferUpdate();
758
- await component.execute(client, interaction);
759
- }
760
- }
761
- };
762
-
763
- // src/core/registry/event.registry.ts
764
- var EventRegistry = class extends BaseRegistry {
765
- items = new discord_js.Collection();
766
- /**
767
- * Load all events.
768
- *
769
- * @async
770
- * @param {string} [directory=getCorePath({ coreDirectory: "events" })]
771
- * @returns {Promise<this>}
772
- */
773
- async load(directory = getCorePath({ coreDirectory: "events" })) {
774
- if (!await exists(directory)) return this;
775
- const entries = await fs.promises.readdir(directory, { withFileTypes: true });
776
- for (const entry of entries) {
777
- const fullPath = path.join(directory, entry.name);
778
- if (entry.isDirectory()) {
779
- await this.load(fullPath);
780
- continue;
781
- }
782
- if (entry.isFile() && entry.name.endsWith(".js")) {
783
- const event = await this.importFile(fullPath);
784
- if (!event) continue;
785
- this.items.set(event.name, event);
786
- }
787
- }
788
- this.items.set(interactionCreate_default.name, interactionCreate_default);
789
- return this;
790
- }
791
- /**
792
- * Bind loaded events to their client events respectively.
793
- *
794
- * @param {TriviousClient} client
795
- */
796
- bind(client) {
797
- for (const event of this.items.values()) {
798
- const handler = (...args) => void event.execute(client, ...args);
799
- if (event.once) client.once(event.name, handler);
800
- else client.on(event.name, handler);
801
- }
802
- }
803
- };
804
- var ModuleRegistry = class extends BaseRegistry {
805
- items = new discord_js.Collection();
806
- /**
807
- * Load all modules.
808
- *
809
- * @async
810
- * @param {string} [directory=getCorePath({ coreDirectory: "module" })]
811
- * @returns {Promise<this>}
812
- */
813
- async load(directory = getCorePath({ coreDirectory: "module" })) {
814
- if (!await exists(directory)) {
815
- return this;
816
- }
817
- const entries = await fs.promises.readdir(directory, { withFileTypes: true });
818
- for (const entry of entries) {
819
- const fullPath = path.join(directory, entry.name);
820
- if (!entry.isDirectory()) continue;
821
- const moduleFiles = (await fs.promises.readdir(fullPath)).filter(
822
- (file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
823
- );
824
- for (const file of moduleFiles) {
825
- const moduleEvent = await this.importFile(path.join(fullPath, file));
826
- if (!moduleEvent || !moduleEvent.events) continue;
827
- this.items.set(moduleEvent.name, moduleEvent);
828
- }
829
- }
830
- return this;
831
- }
832
- /**
833
- * Bind all loaded modules to their client event respectively.
834
- *
835
- * @param {TriviousClient} client
836
- */
837
- bind(client) {
838
- for (const mod of this.items.values()) {
839
- for (const [eventName, handler] of Object.entries(mod.events)) {
840
- if (typeof handler !== "function") continue;
841
- const listener = (...args) => {
842
- void handler(client, ...args);
843
- };
844
- client.on(eventName, listener);
845
- }
846
- }
847
- }
848
- };
849
- var registries = () => ({
850
- commands: new CommandRegistry(),
851
- components: new ComponentRegistry(),
852
- events: new EventRegistry(),
853
- modules: new ModuleRegistry(),
854
- async loadAll(options) {
855
- const corePaths = options.corePaths;
856
- const corePath = options.corePath;
857
- await Promise.all([
858
- this.commands.load(
859
- corePath ? resolveUserPath(path__default.default.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
860
- ),
861
- this.components.load(
862
- corePath ? resolveUserPath(path__default.default.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
863
- ),
864
- this.events.load(
865
- corePath ? resolveUserPath(path__default.default.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
866
- ),
867
- this.modules.load(
868
- corePath ? resolveUserPath(path__default.default.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
869
- )
870
- ]);
871
- },
872
- bind(client) {
873
- this.events.bind(client);
874
- this.modules.bind(client);
875
- }
39
+ Object.defineProperty(exports, "SlashCommand", {
40
+ enumerable: true,
41
+ get: function () { return command_base_js.SlashCommand; }
42
+ });
43
+ Object.defineProperty(exports, "Subcommand", {
44
+ enumerable: true,
45
+ get: function () { return subcommand_base_js__default.default; }
46
+ });
47
+ Object.defineProperty(exports, "SubcommandBuilder", {
48
+ enumerable: true,
49
+ get: function () { return subcommand_base_js.SubcommandBuilder; }
50
+ });
51
+ Object.defineProperty(exports, "ContextMenuBuilder", {
52
+ enumerable: true,
53
+ get: function () { return contextcommand_base_js.ContextMenuBuilder; }
54
+ });
55
+ Object.defineProperty(exports, "ContextMenuCommand", {
56
+ enumerable: true,
57
+ get: function () { return contextcommand_base_js__default.default; }
58
+ });
59
+ Object.defineProperty(exports, "CommandRegistry", {
60
+ enumerable: true,
61
+ get: function () { return command_registry_js__default.default; }
62
+ });
63
+ Object.defineProperty(exports, "Component", {
64
+ enumerable: true,
65
+ get: function () { return component_base_js__default.default; }
66
+ });
67
+ Object.defineProperty(exports, "ComponentBuilder", {
68
+ enumerable: true,
69
+ get: function () { return component_base_js.ComponentBuilder; }
70
+ });
71
+ Object.defineProperty(exports, "ComponentRegistry", {
72
+ enumerable: true,
73
+ get: function () { return component_registry_js__default.default; }
876
74
  });
877
-
878
- // src/core/client/trivious.client.ts
879
- var TriviousClient = class extends discord_js.Client {
880
- /**
881
- * Client registries.
882
- *
883
- * @public
884
- * @readonly
885
- * @type {*}
886
- */
887
- registries = registries();
888
- /**
889
- * Client copy of the constructor options.
890
- *
891
- * @private
892
- * @type {TriviousClientOptions}
893
- */
894
- _options;
895
- /**
896
- * Creates an instance of TriviousClient.
897
- *
898
- * @constructor
899
- * @param {TriviousClientOptions} options
900
- */
901
- constructor(options) {
902
- super(options);
903
- this._options = options;
904
- }
905
- /**
906
- * Load all registries.
907
- *
908
- * @async
909
- * @returns {*}
910
- */
911
- async register() {
912
- const { registries: registries2 } = this;
913
- await registries2.loadAll(this._options);
914
- console.log(
915
- `[Trivious] Loaded all registries (${registries2.commands.get().size} commands, ${registries2.events.get().size} events, ${registries2.components.get().size} components, ${registries2.modules.get().size} modules)`
916
- );
917
- }
918
- /**
919
- * Login and start the bot.
920
- *
921
- * @async
922
- * @returns {*}
923
- */
924
- async start() {
925
- if (!process.env[this._options.tokenReference]) {
926
- if (process.env.NODE_ENV !== "production") return;
927
- else throw new Error("[Trivious] Invalid token reference");
928
- }
929
- this.registries.bind(this);
930
- await this.login(process.env[this._options.tokenReference]);
931
- }
932
- /**
933
- * Deploy all commands.
934
- *
935
- * @async
936
- * @returns {*}
937
- */
938
- async deploy() {
939
- const clientId = process.env[this._options.clientIdReference];
940
- const token = process.env[this._options.tokenReference];
941
- if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
942
- const slashCommands = Array.from(this.registries.commands.get().values());
943
- const body = [...slashCommands.map((command) => command.toJSON())];
944
- const rest = new discord_js.REST({ version: "10" }).setToken(token);
945
- await rest.put(discord_js.Routes.applicationCommands(clientId), { body });
946
- console.log(`[Trivious] Deployed ${body.length} commands`);
947
- }
948
- /**
949
- * Set the roles tied to a permission level.
950
- *
951
- * @param {Record<string, PermissionLevel>} roles
952
- */
953
- setRolePermissions(roles) {
954
- this._options.rolePermissions = roles;
955
- }
956
- get rolePermissions() {
957
- return this._options.rolePermissions ?? {};
958
- }
959
- };
960
- var Command = class {
961
- /**
962
- * Returns whether the command is a SlashCommand.
963
- *
964
- * @public
965
- * @param {Command} this
966
- * @returns {this is SlashCommand}
967
- */
968
- isSlashCommand() {
969
- return this.data instanceof discord_js.SlashCommandBuilder;
970
- }
971
- /**
972
- * Returns whether the command is a ContextMenuCommand.
973
- *
974
- * @public
975
- * @param {Command} this
976
- * @returns {this is ContextMenuCommand}
977
- */
978
- isContextMenuCommand() {
979
- return this.data instanceof discord_js.ContextMenuCommandBuilder;
980
- }
981
- /**
982
- * Returns JSON of the command builder.
983
- *
984
- * @public
985
- * @returns {*}
986
- */
987
- toJSON() {
988
- return this.data.toJSON();
989
- }
990
- /**
991
- * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
992
- *
993
- * @public
994
- * @async
995
- * @param {CommandInteraction} interaction
996
- * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
997
- * @returns {*}
998
- */
999
- async reply(interaction, options) {
1000
- if (interaction.replied) {
1001
- await interaction.editReply(options);
1002
- return;
1003
- }
1004
- const newOptions = { ...options };
1005
- if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1006
- await interaction.reply(newOptions);
1007
- }
1008
- /**
1009
- * Validate permissions for a user/member in a guild.
1010
- *
1011
- * @async
1012
- * @param {CommandInteraction} interaction
1013
- * @param {PermissionLevel} permission
1014
- * @param {boolean} [doReply=true]
1015
- * @returns {unknown}
1016
- */
1017
- async validateGuildPermission(client, interaction, permission, doReply = true) {
1018
- const isContextMenu = interaction.isContextMenuCommand();
1019
- const isChatInput = interaction.isChatInputCommand();
1020
- const requiresGuildCheck = isContextMenu || isChatInput && (this.isSlashCommand() ? this.metadata.guildOnly : false);
1021
- if (!requiresGuildCheck) return true;
1022
- const member = interaction.member;
1023
- const memberHasPermission = hasPermission(client, { permission, member });
1024
- if (!memberHasPermission && doReply) {
1025
- await this.reply(interaction, {
1026
- content: `You do not have permission to run this command, required permission: \`${PermissionLevel[permission]}\``
1027
- });
1028
- }
1029
- return memberHasPermission;
1030
- }
1031
- };
1032
- var SlashCommand = class extends Command {
1033
- /**
1034
- * General handler for the command and its subcommand, if applicable.
1035
- *
1036
- * @public
1037
- * @async
1038
- * @param {TriviousClient} client
1039
- * @param {ChatInputCommandInteraction} interaction
1040
- * @returns {*}
1041
- */
1042
- async execute(client, interaction) {
1043
- const { run, reply, metadata } = this;
1044
- const { options } = interaction;
1045
- if (run) {
1046
- const memberHasPermission2 = await this.validateGuildPermission(
1047
- client,
1048
- interaction,
1049
- metadata.permission,
1050
- false
1051
- );
1052
- if (memberHasPermission2) await run(client, interaction);
1053
- }
1054
- const subcommands = metadata.subcommands;
1055
- if (subcommands.size <= 0) return;
1056
- const subcommand = metadata.subcommands.find(
1057
- (subcmd) => subcmd.data.name === options.getSubcommand()
1058
- );
1059
- if (!subcommand) {
1060
- await reply(interaction, {
1061
- content: "Ran subcommand is outdated or does not have a handler!"
1062
- });
1063
- return;
1064
- }
1065
- const memberHasPermission = await this.validateGuildPermission(
1066
- client,
1067
- interaction,
1068
- subcommand.metadata.permission
1069
- );
1070
- if (!memberHasPermission) return;
1071
- await subcommand.execute(client, interaction);
1072
- }
1073
- };
1074
- var CommandBuilder = class extends discord_js.SlashCommandBuilder {
1075
- _active = true;
1076
- _guildOnly = false;
1077
- _ownerOnly = false;
1078
- _permission = 0 /* USER */;
1079
- _subcommands = new discord_js.Collection();
1080
- _ephemeralReply = false;
1081
- /**
1082
- * Set the command as disabled.
1083
- *
1084
- * @public
1085
- * @returns {this}
1086
- */
1087
- disable() {
1088
- this._active = false;
1089
- return this;
1090
- }
1091
- /**
1092
- * Set the command as guild only.
1093
- *
1094
- * @public
1095
- * @returns {this}
1096
- */
1097
- setGuildOnly() {
1098
- this._guildOnly = true;
1099
- this._permission = 0 /* USER */;
1100
- this.setContexts(discord_js.InteractionContextType.Guild);
1101
- return this;
1102
- }
1103
- /**
1104
- * Set the command as public only.
1105
- *
1106
- * @public
1107
- * @returns {this}
1108
- */
1109
- setOwnerOnly() {
1110
- this._permission = 5 /* BOT_OWNER */;
1111
- return this;
1112
- }
1113
- /**
1114
- * Set the permission level required to run the command.
1115
- *
1116
- * @public
1117
- * @param {PermissionLevel} permission
1118
- * @returns {this}
1119
- */
1120
- setPermission(permission) {
1121
- if (!this._guildOnly) return this;
1122
- this._permission = permission;
1123
- return this;
1124
- }
1125
- /**
1126
- * Set the interaction as ephemeral.
1127
- *
1128
- * @public
1129
- * @returns {this}
1130
- */
1131
- setEphemeralReply() {
1132
- this._ephemeralReply = true;
1133
- return this;
1134
- }
1135
- /**
1136
- * Build the builder.
1137
- *
1138
- * @public
1139
- * @returns {{ data: CommandBuilder; metadata: CommandMetadata; }}
1140
- */
1141
- build() {
1142
- return {
1143
- data: this,
1144
- metadata: {
1145
- active: this._active,
1146
- guildOnly: this._guildOnly,
1147
- ownerOnly: this._ownerOnly,
1148
- permission: this._permission,
1149
- subcommands: this._subcommands,
1150
- ephemeralReply: this._ephemeralReply
1151
- }
1152
- };
1153
- }
1154
- };
1155
- var SubcommandBuilder = class extends discord_js.SlashCommandSubcommandBuilder {
1156
- _active = true;
1157
- _ownerOnly = false;
1158
- _permission = 0 /* USER */;
1159
- _ephemeralReply = false;
1160
- /**
1161
- * Set the subcommand as disabled.
1162
- *
1163
- * @public
1164
- * @returns {this}
1165
- */
1166
- disable() {
1167
- this._active = false;
1168
- return this;
1169
- }
1170
- /**
1171
- * Set the subcommand as owner only.
1172
- *
1173
- * @public
1174
- * @returns {this}
1175
- */
1176
- setOwnerOnly() {
1177
- this._permission = 5 /* BOT_OWNER */;
1178
- this._ownerOnly = true;
1179
- return this;
1180
- }
1181
- /**
1182
- * Set the permission level required to run the subcommand.
1183
- *
1184
- * @public
1185
- * @param {PermissionLevel} permission
1186
- * @returns {this}
1187
- */
1188
- setPermission(permission) {
1189
- this._permission = permission;
1190
- return this;
1191
- }
1192
- /**
1193
- * Set the interaction as ephemeral
1194
- *
1195
- * @public
1196
- * @returns {this}
1197
- */
1198
- setEphemeralReply() {
1199
- this._ephemeralReply = true;
1200
- return this;
1201
- }
1202
- /**
1203
- * Build the builder.
1204
- *
1205
- * @public
1206
- * @returns {{ data: SlashCommandSubcommandBuilder; metadata: SubcommandMetadata; }}
1207
- */
1208
- build() {
1209
- return {
1210
- data: this,
1211
- metadata: {
1212
- active: this._active,
1213
- ownerOnly: this._ownerOnly,
1214
- permission: this._permission,
1215
- ephemeralReply: this._ephemeralReply
1216
- }
1217
- };
1218
- }
1219
- };
1220
- var Subcommand = class {
1221
- /**
1222
- * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
1223
- *
1224
- * @async
1225
- * @param {ChatInputCommandInteraction<CacheType>} interaction
1226
- * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
1227
- * @returns {*}
1228
- */
1229
- async reply(interaction, options) {
1230
- if (interaction.replied) {
1231
- await interaction.editReply(options);
1232
- return;
1233
- }
1234
- const newOptions = { ...options };
1235
- if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1236
- await interaction.reply(newOptions);
1237
- }
1238
- };
1239
- var ContextMenuCommand = class extends Command {
1240
- /**
1241
- * Base command handler.
1242
- *
1243
- * @public
1244
- * @async
1245
- * @param {TriviousClient} client
1246
- * @param {ContextMenuCommandInteraction} interaction
1247
- * @returns {*}
1248
- */
1249
- async execute(client, interaction) {
1250
- const { run, metadata } = this;
1251
- const memberHasPermission = await this.validateGuildPermission(
1252
- client,
1253
- interaction,
1254
- metadata.permission,
1255
- false
1256
- );
1257
- if (memberHasPermission) await run(client, interaction);
1258
- }
1259
- };
1260
- var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
1261
- _active = true;
1262
- _ownerOnly = false;
1263
- _permission = 0 /* USER */;
1264
- _ephemeralReply = false;
1265
- /**
1266
- * Set the command as disabled.
1267
- *
1268
- * @public
1269
- * @returns {this}
1270
- */
1271
- disable() {
1272
- this._active = false;
1273
- return this;
1274
- }
1275
- /**
1276
- * Set the command as owner only.
1277
- *
1278
- * @public
1279
- * @returns {this}
1280
- */
1281
- setOwnerOnly() {
1282
- this._permission = 5 /* BOT_OWNER */;
1283
- this._ownerOnly = true;
1284
- return this;
1285
- }
1286
- /**
1287
- * Set the permission level required to run the command.
1288
- *
1289
- * @public
1290
- * @param {PermissionLevel} permission
1291
- * @returns {this}
1292
- */
1293
- setPermission(permission) {
1294
- this._permission = permission;
1295
- return this;
1296
- }
1297
- /**
1298
- * Set the interaction as ephemeral.
1299
- *
1300
- * @public
1301
- * @returns {this}
1302
- */
1303
- setEphemeralReply() {
1304
- this._ephemeralReply = true;
1305
- return this;
1306
- }
1307
- /**
1308
- * Build the builder
1309
- *
1310
- * @public
1311
- * @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
1312
- */
1313
- build() {
1314
- return {
1315
- data: this,
1316
- metadata: {
1317
- active: this._active,
1318
- ownerOnly: this._ownerOnly,
1319
- permission: this._permission,
1320
- ephemeralReply: this._ephemeralReply
1321
- }
1322
- };
1323
- }
1324
- };
1325
-
1326
- // src/core/components/component.base.ts
1327
- var ComponentBuilder = class {
1328
- _customId = "";
1329
- _permission = 0 /* USER */;
1330
- _ephemeralReply = false;
1331
- /**
1332
- * Set the customId for the component.
1333
- *
1334
- * @public
1335
- * @param {{
1336
- * type: ComponentType;
1337
- * data: string;
1338
- * tags?: ComponentCustomIdTag[];
1339
- * }} options
1340
- * @returns {this}
1341
- */
1342
- setCustomId(options) {
1343
- const { data, type, tags } = options;
1344
- this._customId = `${type}:${data}${tags ? `.${tags.join(".")}` : ""}`;
1345
- return this;
1346
- }
1347
- /**
1348
- * Set the permission required to use the component.
1349
- *
1350
- * @public
1351
- * @param {PermissionLevel} permission
1352
- * @returns {this}
1353
- */
1354
- setPermission(permission) {
1355
- this._permission = permission;
1356
- return this;
1357
- }
1358
- /**
1359
- * Set the interaction as ephemeral.
1360
- *
1361
- * @public
1362
- * @returns {this}
1363
- */
1364
- setEphemeralReply() {
1365
- this._ephemeralReply = true;
1366
- return this;
1367
- }
1368
- /**
1369
- * Builder the builder.
1370
- *
1371
- * @public
1372
- * @returns {{ metadata: ComponentMetadata; }}
1373
- */
1374
- build() {
1375
- return {
1376
- metadata: {
1377
- customId: this._customId,
1378
- permission: this._permission,
1379
- ephemeralReply: this._ephemeralReply
1380
- }
1381
- };
1382
- }
1383
- };
1384
- var Component = class {
1385
- /**
1386
- * Validate permissions for a user/member in a guild.
1387
- *
1388
- * @async
1389
- * @param {ComponentInteraction} interaction
1390
- * @param {PermissionLevel} permission
1391
- * @param {boolean} [doReply=true] Defaults to `true`
1392
- * @returns {unknown}
1393
- */
1394
- async validateGuildPermission(client, interaction, permission, doReply = true) {
1395
- if (interaction.guild) {
1396
- const member = interaction.member;
1397
- const memberHasPermission = hasPermission(client, { permission, member });
1398
- if (!memberHasPermission) {
1399
- if (doReply)
1400
- await this.reply(interaction, {
1401
- content: `You do not have permission to run this command, required permission: \`${PermissionLevel[permission]}\``
1402
- });
1403
- return false;
1404
- }
1405
- }
1406
- return true;
1407
- }
1408
- /**
1409
- * Reply to the interaction respecting command metadata and if the interaction has already been replied to.
1410
- *
1411
- * @async
1412
- * @param {ComponentInteraction} interaction
1413
- * @param {(MessagePayload | InteractionEditReplyOptions | InteractionReplyOptions)} options
1414
- * @returns {*}
1415
- */
1416
- async reply(interaction, options) {
1417
- if (interaction.replied) {
1418
- await interaction.editReply(options);
1419
- return;
1420
- }
1421
- const newOptions = { ...options };
1422
- if (this.metadata.ephemeralReply) newOptions.flags = ["Ephemeral"];
1423
- await interaction.reply(newOptions);
1424
- }
1425
- };
1426
-
1427
75
  Object.defineProperty(exports, "ClientEvents", {
1428
76
  enumerable: true,
1429
77
  get: function () { return discord_js.ClientEvents; }
@@ -1432,22 +80,11 @@ Object.defineProperty(exports, "Collection", {
1432
80
  enumerable: true,
1433
81
  get: function () { return discord_js.Collection; }
1434
82
  });
1435
- exports.BaseRegistry = BaseRegistry;
1436
- exports.Command = Command;
1437
- exports.CommandBuilder = CommandBuilder;
1438
- exports.CommandRegistry = CommandRegistry;
1439
- exports.Component = Component;
1440
- exports.ComponentBuilder = ComponentBuilder;
1441
- exports.ComponentRegistry = ComponentRegistry;
1442
- exports.ComponentType = ComponentType;
1443
- exports.ContextMenuBuilder = ContextMenuBuilder;
1444
- exports.ContextMenuCommand = ContextMenuCommand;
1445
- exports.PermissionLevel = PermissionLevel;
1446
- exports.SlashCommand = SlashCommand;
1447
- exports.Subcommand = Subcommand;
1448
- exports.SubcommandBuilder = SubcommandBuilder;
1449
- exports.TriviousClient = TriviousClient;
1450
- exports.deconstructCustomId = deconstructCustomId;
1451
- exports.getPermissionLevel = getPermissionLevel;
83
+ Object.keys(index_js).forEach(function (k) {
84
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
85
+ enumerable: true,
86
+ get: function () { return index_js[k]; }
87
+ });
88
+ });
1452
89
  //# sourceMappingURL=index.cjs.map
1453
90
  //# sourceMappingURL=index.cjs.map