trivious 1.3.24 → 1.3.26

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