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