trivious 1.3.14 → 1.3.16
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/LICENSE +201 -201
- package/README.md +126 -126
- package/dist/index.cjs +211 -304
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +130 -212
- package/dist/index.js.map +1 -1
- package/package.json +75 -75
package/dist/index.cjs
CHANGED
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('util');
|
|
4
|
+
var discord_js = require('discord.js');
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var url = require('url');
|
|
8
|
+
|
|
9
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
13
|
+
|
|
5
14
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
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() {
|
|
9
22
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
23
|
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
24
|
|
|
33
25
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
|
|
34
26
|
var require_package = __commonJS({
|
|
35
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(
|
|
36
|
-
|
|
27
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(exports$1, module) {
|
|
28
|
+
module.exports = {
|
|
37
29
|
name: "dotenv",
|
|
38
30
|
version: "17.2.3",
|
|
39
31
|
description: "Loads environment variables from .env file",
|
|
@@ -100,12 +92,11 @@ var require_package = __commonJS({
|
|
|
100
92
|
|
|
101
93
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
|
|
102
94
|
var require_main = __commonJS({
|
|
103
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(
|
|
104
|
-
|
|
105
|
-
var
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var crypto = require("crypto");
|
|
95
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(exports$1, module) {
|
|
96
|
+
var fs6 = __require("fs");
|
|
97
|
+
var path2 = __require("path");
|
|
98
|
+
var os = __require("os");
|
|
99
|
+
var crypto = __require("crypto");
|
|
109
100
|
var packageJson = require_package();
|
|
110
101
|
var version = packageJson.version;
|
|
111
102
|
var TIPS = [
|
|
@@ -417,21 +408,20 @@ var require_main = __commonJS({
|
|
|
417
408
|
parse,
|
|
418
409
|
populate
|
|
419
410
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
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;
|
|
428
419
|
}
|
|
429
420
|
});
|
|
430
421
|
|
|
431
422
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js
|
|
432
423
|
var require_env_options = __commonJS({
|
|
433
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js"(
|
|
434
|
-
"use strict";
|
|
424
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js"(exports$1, module) {
|
|
435
425
|
var options = {};
|
|
436
426
|
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
437
427
|
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
@@ -451,16 +441,15 @@ var require_env_options = __commonJS({
|
|
|
451
441
|
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
452
442
|
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
453
443
|
}
|
|
454
|
-
|
|
444
|
+
module.exports = options;
|
|
455
445
|
}
|
|
456
446
|
});
|
|
457
447
|
|
|
458
448
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js
|
|
459
449
|
var require_cli_options = __commonJS({
|
|
460
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js"(
|
|
461
|
-
"use strict";
|
|
450
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js"(exports$1, module) {
|
|
462
451
|
var re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
463
|
-
|
|
452
|
+
module.exports = function optionMatcher(args) {
|
|
464
453
|
const options = args.reduce(function(acc, cur) {
|
|
465
454
|
const matches = cur.match(re);
|
|
466
455
|
if (matches) {
|
|
@@ -476,31 +465,6 @@ var require_cli_options = __commonJS({
|
|
|
476
465
|
}
|
|
477
466
|
});
|
|
478
467
|
|
|
479
|
-
// src/index.ts
|
|
480
|
-
var index_exports = {};
|
|
481
|
-
__export(index_exports, {
|
|
482
|
-
BaseRegistry: () => BaseRegistry,
|
|
483
|
-
ClientEvents: () => import_discord10.ClientEvents,
|
|
484
|
-
Collection: () => import_discord10.Collection,
|
|
485
|
-
Command: () => Command,
|
|
486
|
-
CommandBuilder: () => CommandBuilder,
|
|
487
|
-
CommandRegistry: () => CommandRegistry,
|
|
488
|
-
Component: () => Component,
|
|
489
|
-
ComponentBuilder: () => ComponentBuilder,
|
|
490
|
-
ComponentRegistry: () => ComponentRegistry,
|
|
491
|
-
ComponentType: () => ComponentType,
|
|
492
|
-
ContextMenuBuilder: () => ContextMenuBuilder,
|
|
493
|
-
ContextMenuCommand: () => ContextMenuCommand,
|
|
494
|
-
PermissionLevel: () => PermissionLevel,
|
|
495
|
-
SlashCommand: () => SlashCommand,
|
|
496
|
-
Subcommand: () => Subcommand,
|
|
497
|
-
SubcommandBuilder: () => SubcommandBuilder,
|
|
498
|
-
TriviousClient: () => TriviousClient,
|
|
499
|
-
deconstructCustomId: () => deconstructCustomId,
|
|
500
|
-
getPermissionLevel: () => getPermissionLevel
|
|
501
|
-
});
|
|
502
|
-
module.exports = __toCommonJS(index_exports);
|
|
503
|
-
|
|
504
468
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/config.js
|
|
505
469
|
(function() {
|
|
506
470
|
require_main().config(
|
|
@@ -512,17 +476,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
512
476
|
);
|
|
513
477
|
})();
|
|
514
478
|
|
|
515
|
-
// src/index.ts
|
|
516
|
-
var import_node_util = require("util");
|
|
517
|
-
|
|
518
|
-
// src/core/client/trivious.client.ts
|
|
519
|
-
var import_discord6 = require("discord.js");
|
|
520
|
-
|
|
521
|
-
// src/shared/utility/functions.ts
|
|
522
|
-
var import_fs = require("fs");
|
|
523
|
-
var import_node_path = require("path");
|
|
524
|
-
var import_path2 = require("path");
|
|
525
|
-
|
|
526
479
|
// src/shared/typings/permissions.ts
|
|
527
480
|
var PermissionLevel = /* @__PURE__ */ ((PermissionLevel2) => {
|
|
528
481
|
PermissionLevel2[PermissionLevel2["USER"] = 0] = "USER";
|
|
@@ -540,23 +493,18 @@ var getPermissionLevel = (client, member) => {
|
|
|
540
493
|
return rolePermissions[highestRole.name] ?? 0 /* USER */;
|
|
541
494
|
};
|
|
542
495
|
|
|
543
|
-
// src/shared/utility/paths.ts
|
|
544
|
-
var import_url = require("url");
|
|
545
|
-
var import_path = require("path");
|
|
546
|
-
var import_meta = {};
|
|
547
|
-
var __filename = typeof _filename === "string" ? _filename : (0, import_url.fileURLToPath)(import_meta.url);
|
|
548
|
-
var __dirname = typeof _dirname === "string" ? _dirname : (0, import_path.dirname)(__filename);
|
|
549
|
-
|
|
550
496
|
// src/shared/utility/functions.ts
|
|
497
|
+
var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
498
|
+
var __dirname$1 = path.dirname(__filename$1);
|
|
551
499
|
var getPackageRoot = () => {
|
|
552
|
-
let dir = __dirname;
|
|
553
|
-
while (dir !==
|
|
554
|
-
if (
|
|
500
|
+
let dir = __dirname$1;
|
|
501
|
+
while (dir !== path.dirname(dir)) {
|
|
502
|
+
if (fs.existsSync(path.join(dir, "package.json")) || fs.existsSync(path.join(dir, "node_modules"))) {
|
|
555
503
|
return dir;
|
|
556
504
|
}
|
|
557
|
-
dir =
|
|
505
|
+
dir = path.dirname(dir);
|
|
558
506
|
}
|
|
559
|
-
return __dirname;
|
|
507
|
+
return __dirname$1;
|
|
560
508
|
};
|
|
561
509
|
var FRAMEWORK_PACKAGE_ROOT = getPackageRoot();
|
|
562
510
|
function getCorePath(options) {
|
|
@@ -565,34 +513,34 @@ function getCorePath(options) {
|
|
|
565
513
|
return resolveUserPath(userPath);
|
|
566
514
|
}
|
|
567
515
|
const builtInCandidates = [
|
|
568
|
-
|
|
569
|
-
|
|
516
|
+
path.join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory),
|
|
517
|
+
path.join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory)
|
|
570
518
|
];
|
|
571
519
|
for (const candidate of builtInCandidates) {
|
|
572
|
-
if (
|
|
520
|
+
if (fs.existsSync(candidate)) {
|
|
573
521
|
return candidate;
|
|
574
522
|
}
|
|
575
523
|
}
|
|
576
|
-
return
|
|
524
|
+
return path.join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory);
|
|
577
525
|
}
|
|
578
526
|
function resolveUserPath(relativePath) {
|
|
579
527
|
const candidates = [
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
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)
|
|
586
534
|
];
|
|
587
535
|
for (const candidate of candidates) {
|
|
588
|
-
const full =
|
|
589
|
-
if (
|
|
536
|
+
const full = path.resolve(candidate);
|
|
537
|
+
if (fs.existsSync(full)) return full;
|
|
590
538
|
}
|
|
591
|
-
return
|
|
539
|
+
return path.join(process.cwd(), relativePath);
|
|
592
540
|
}
|
|
593
541
|
async function exists(path2) {
|
|
594
542
|
try {
|
|
595
|
-
await
|
|
543
|
+
await fs.promises.access(path2);
|
|
596
544
|
return true;
|
|
597
545
|
} catch {
|
|
598
546
|
return false;
|
|
@@ -610,12 +558,6 @@ function hasPermission(client, options) {
|
|
|
610
558
|
}
|
|
611
559
|
return false;
|
|
612
560
|
}
|
|
613
|
-
|
|
614
|
-
// src/core/registry/command.registry.ts
|
|
615
|
-
var import_discord = require("discord.js");
|
|
616
|
-
|
|
617
|
-
// src/shared/typings/registry.ts
|
|
618
|
-
var import_url2 = require("url");
|
|
619
561
|
var BaseRegistry = class {
|
|
620
562
|
/**
|
|
621
563
|
* Get all of loaded T
|
|
@@ -636,7 +578,7 @@ var BaseRegistry = class {
|
|
|
636
578
|
*/
|
|
637
579
|
async importFile(filePath) {
|
|
638
580
|
try {
|
|
639
|
-
const { default: file } = await import(
|
|
581
|
+
const { default: file } = await import(url.pathToFileURL(filePath).href);
|
|
640
582
|
const imports = file.default ?? file;
|
|
641
583
|
if (!imports) return null;
|
|
642
584
|
if (typeof imports === "function" && imports.prototype) {
|
|
@@ -665,8 +607,8 @@ var BaseRegistry = class {
|
|
|
665
607
|
async clearCache(filePath) {
|
|
666
608
|
if (process.env.NODE_ENV === "production") return;
|
|
667
609
|
try {
|
|
668
|
-
const resvoled =
|
|
669
|
-
delete
|
|
610
|
+
const resvoled = __require.resolve(filePath);
|
|
611
|
+
delete __require.cache[resvoled];
|
|
670
612
|
} catch {
|
|
671
613
|
}
|
|
672
614
|
}
|
|
@@ -688,12 +630,8 @@ var deconstructCustomId = (customId) => {
|
|
|
688
630
|
tags
|
|
689
631
|
};
|
|
690
632
|
};
|
|
691
|
-
|
|
692
|
-
// src/core/registry/command.registry.ts
|
|
693
|
-
var import_fs2 = require("fs");
|
|
694
|
-
var import_node_path2 = require("path");
|
|
695
633
|
var CommandRegistry = class extends BaseRegistry {
|
|
696
|
-
items = new
|
|
634
|
+
items = new discord_js.Collection();
|
|
697
635
|
/**
|
|
698
636
|
* Load all commands and their subcommands
|
|
699
637
|
*
|
|
@@ -705,12 +643,12 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
705
643
|
if (!await exists(directory)) {
|
|
706
644
|
return this;
|
|
707
645
|
}
|
|
708
|
-
const entries = await
|
|
646
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
709
647
|
for (const entry of entries) {
|
|
710
|
-
const fullPath =
|
|
648
|
+
const fullPath = path.join(directory, entry.name);
|
|
711
649
|
if (!entry.isDirectory()) continue;
|
|
712
|
-
const indexFile =
|
|
713
|
-
const indexJs =
|
|
650
|
+
const indexFile = path.join(fullPath, "index.ts");
|
|
651
|
+
const indexJs = path.join(fullPath, "index.js");
|
|
714
652
|
let commandFile = "";
|
|
715
653
|
if (await exists(indexFile)) commandFile = indexFile;
|
|
716
654
|
else if (await exists(indexJs)) commandFile = indexJs;
|
|
@@ -719,13 +657,13 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
719
657
|
if (!command) continue;
|
|
720
658
|
if (!command.metadata.active) continue;
|
|
721
659
|
if (command.isSlashCommand()) {
|
|
722
|
-
const subcommandFiles = (await
|
|
660
|
+
const subcommandFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
723
661
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
724
662
|
);
|
|
725
663
|
for (const file of subcommandFiles) {
|
|
726
|
-
const subcommand = await this.importFile(
|
|
664
|
+
const subcommand = await this.importFile(path.join(fullPath, file));
|
|
727
665
|
if (!subcommand) continue;
|
|
728
|
-
if (!subcommand.data.name || !(subcommand.data instanceof
|
|
666
|
+
if (!subcommand.data.name || !(subcommand.data instanceof discord_js.SlashCommandSubcommandBuilder))
|
|
729
667
|
continue;
|
|
730
668
|
command.data.addSubcommand(subcommand.data);
|
|
731
669
|
command.metadata.subcommands.set(subcommand.data.name, subcommand);
|
|
@@ -736,13 +674,8 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
736
674
|
return this;
|
|
737
675
|
}
|
|
738
676
|
};
|
|
739
|
-
|
|
740
|
-
// src/core/registry/component.registry.ts
|
|
741
|
-
var import_discord2 = require("discord.js");
|
|
742
|
-
var import_fs3 = require("fs");
|
|
743
|
-
var import_node_path3 = require("path");
|
|
744
677
|
var ComponentRegistry = class extends BaseRegistry {
|
|
745
|
-
items = new
|
|
678
|
+
items = new discord_js.Collection();
|
|
746
679
|
/**
|
|
747
680
|
* Load all components.
|
|
748
681
|
*
|
|
@@ -754,15 +687,15 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
754
687
|
if (!await exists(directory)) {
|
|
755
688
|
return this;
|
|
756
689
|
}
|
|
757
|
-
const entries = await
|
|
690
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
758
691
|
for (const entry of entries) {
|
|
759
|
-
const fullPath =
|
|
692
|
+
const fullPath = path.join(directory, entry.name);
|
|
760
693
|
if (!entry.isDirectory()) continue;
|
|
761
|
-
const componentFiles = (await
|
|
694
|
+
const componentFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
762
695
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
763
696
|
);
|
|
764
697
|
for (const file of componentFiles) {
|
|
765
|
-
const component = await this.importFile(
|
|
698
|
+
const component = await this.importFile(path.join(fullPath, file));
|
|
766
699
|
if (!component) continue;
|
|
767
700
|
const { data } = deconstructCustomId(component.metadata.customId);
|
|
768
701
|
this.items.set(data, component);
|
|
@@ -771,14 +704,6 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
771
704
|
return this;
|
|
772
705
|
}
|
|
773
706
|
};
|
|
774
|
-
|
|
775
|
-
// src/core/registry/event.registry.ts
|
|
776
|
-
var import_discord4 = require("discord.js");
|
|
777
|
-
var import_fs4 = require("fs");
|
|
778
|
-
var import_node_path4 = require("path");
|
|
779
|
-
|
|
780
|
-
// src/core/events/interactionCreate.ts
|
|
781
|
-
var import_discord3 = require("discord.js");
|
|
782
707
|
var interactionCreate_default = {
|
|
783
708
|
name: "interactionCreate",
|
|
784
709
|
execute: async (client, interaction) => {
|
|
@@ -808,9 +733,9 @@ var interactionCreate_default = {
|
|
|
808
733
|
}
|
|
809
734
|
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
810
735
|
const { componentType, tags, data } = deconstructCustomId(interaction.customId);
|
|
811
|
-
if (componentType === "button" /* Button */ && !(interaction instanceof
|
|
736
|
+
if (componentType === "button" /* Button */ && !(interaction instanceof discord_js.ButtonInteraction))
|
|
812
737
|
return;
|
|
813
|
-
if (componentType === "modal" /* Modal */ && !(interaction instanceof
|
|
738
|
+
if (componentType === "modal" /* Modal */ && !(interaction instanceof discord_js.ModalSubmitInteraction))
|
|
814
739
|
return;
|
|
815
740
|
if (tags.includes("awaited")) return;
|
|
816
741
|
const registeredComponents = client.registries.components.get();
|
|
@@ -837,7 +762,7 @@ var interactionCreate_default = {
|
|
|
837
762
|
|
|
838
763
|
// src/core/registry/event.registry.ts
|
|
839
764
|
var EventRegistry = class extends BaseRegistry {
|
|
840
|
-
items = new
|
|
765
|
+
items = new discord_js.Collection();
|
|
841
766
|
/**
|
|
842
767
|
* Load all events.
|
|
843
768
|
*
|
|
@@ -847,9 +772,9 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
847
772
|
*/
|
|
848
773
|
async load(directory = getCorePath({ coreDirectory: "events" })) {
|
|
849
774
|
if (!await exists(directory)) return this;
|
|
850
|
-
const entries = await
|
|
775
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
851
776
|
for (const entry of entries) {
|
|
852
|
-
const fullPath =
|
|
777
|
+
const fullPath = path.join(directory, entry.name);
|
|
853
778
|
if (entry.isDirectory()) {
|
|
854
779
|
await this.load(fullPath);
|
|
855
780
|
continue;
|
|
@@ -860,8 +785,7 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
860
785
|
this.items.set(event.name, event);
|
|
861
786
|
}
|
|
862
787
|
}
|
|
863
|
-
|
|
864
|
-
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
788
|
+
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
865
789
|
return this;
|
|
866
790
|
}
|
|
867
791
|
/**
|
|
@@ -877,13 +801,8 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
877
801
|
}
|
|
878
802
|
}
|
|
879
803
|
};
|
|
880
|
-
|
|
881
|
-
// src/core/registry/module.registry.ts
|
|
882
|
-
var import_discord5 = require("discord.js");
|
|
883
|
-
var import_fs5 = require("fs");
|
|
884
|
-
var import_node_path5 = require("path");
|
|
885
804
|
var ModuleRegistry = class extends BaseRegistry {
|
|
886
|
-
items = new
|
|
805
|
+
items = new discord_js.Collection();
|
|
887
806
|
/**
|
|
888
807
|
* Load all modules.
|
|
889
808
|
*
|
|
@@ -895,15 +814,15 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
895
814
|
if (!await exists(directory)) {
|
|
896
815
|
return this;
|
|
897
816
|
}
|
|
898
|
-
const entries = await
|
|
817
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
899
818
|
for (const entry of entries) {
|
|
900
|
-
const fullPath =
|
|
819
|
+
const fullPath = path.join(directory, entry.name);
|
|
901
820
|
if (!entry.isDirectory()) continue;
|
|
902
|
-
const moduleFiles = (await
|
|
821
|
+
const moduleFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
903
822
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
904
823
|
);
|
|
905
824
|
for (const file of moduleFiles) {
|
|
906
|
-
const moduleEvent = await this.importFile(
|
|
825
|
+
const moduleEvent = await this.importFile(path.join(fullPath, file));
|
|
907
826
|
if (!moduleEvent || !moduleEvent.events) continue;
|
|
908
827
|
this.items.set(moduleEvent.name, moduleEvent);
|
|
909
828
|
}
|
|
@@ -927,9 +846,6 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
927
846
|
}
|
|
928
847
|
}
|
|
929
848
|
};
|
|
930
|
-
|
|
931
|
-
// src/core/registry/index.ts
|
|
932
|
-
var import_node_path6 = __toESM(require("path"), 1);
|
|
933
849
|
var registries = () => ({
|
|
934
850
|
commands: new CommandRegistry(),
|
|
935
851
|
components: new ComponentRegistry(),
|
|
@@ -940,16 +856,16 @@ var registries = () => ({
|
|
|
940
856
|
const corePath = options.corePath;
|
|
941
857
|
await Promise.all([
|
|
942
858
|
this.commands.load(
|
|
943
|
-
corePath ? resolveUserPath(
|
|
859
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
|
|
944
860
|
),
|
|
945
861
|
this.components.load(
|
|
946
|
-
corePath ? resolveUserPath(
|
|
862
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
|
|
947
863
|
),
|
|
948
864
|
this.events.load(
|
|
949
|
-
corePath ? resolveUserPath(
|
|
865
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
|
|
950
866
|
),
|
|
951
867
|
this.modules.load(
|
|
952
|
-
corePath ? resolveUserPath(
|
|
868
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
|
|
953
869
|
)
|
|
954
870
|
]);
|
|
955
871
|
},
|
|
@@ -960,7 +876,7 @@ var registries = () => ({
|
|
|
960
876
|
});
|
|
961
877
|
|
|
962
878
|
// src/core/client/trivious.client.ts
|
|
963
|
-
var TriviousClient = class extends
|
|
879
|
+
var TriviousClient = class extends discord_js.Client {
|
|
964
880
|
/**
|
|
965
881
|
* Client registries.
|
|
966
882
|
*
|
|
@@ -1025,8 +941,8 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1025
941
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
1026
942
|
const slashCommands = Array.from(this.registries.commands.get().values());
|
|
1027
943
|
const body = [...slashCommands.map((command) => command.toJSON())];
|
|
1028
|
-
const rest = new
|
|
1029
|
-
await rest.put(
|
|
944
|
+
const rest = new discord_js.REST({ version: "10" }).setToken(token);
|
|
945
|
+
await rest.put(discord_js.Routes.applicationCommands(clientId), { body });
|
|
1030
946
|
console.log(`[Trivious] Deployed ${body.length} commands`);
|
|
1031
947
|
}
|
|
1032
948
|
/**
|
|
@@ -1041,100 +957,6 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1041
957
|
return this._options.rolePermissions ?? {};
|
|
1042
958
|
}
|
|
1043
959
|
};
|
|
1044
|
-
|
|
1045
|
-
// src/core/commands/command.base.ts
|
|
1046
|
-
var import_discord8 = require("discord.js");
|
|
1047
|
-
|
|
1048
|
-
// src/core/commands/contextcommand.base.ts
|
|
1049
|
-
var import_discord7 = require("discord.js");
|
|
1050
|
-
var ContextMenuCommand = class extends Command {
|
|
1051
|
-
/**
|
|
1052
|
-
* Base command handler.
|
|
1053
|
-
*
|
|
1054
|
-
* @public
|
|
1055
|
-
* @async
|
|
1056
|
-
* @param {TriviousClient} client
|
|
1057
|
-
* @param {ContextMenuCommandInteraction} interaction
|
|
1058
|
-
* @returns {*}
|
|
1059
|
-
*/
|
|
1060
|
-
async execute(client, interaction) {
|
|
1061
|
-
const { run, metadata } = this;
|
|
1062
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1063
|
-
client,
|
|
1064
|
-
interaction,
|
|
1065
|
-
metadata.permission,
|
|
1066
|
-
false
|
|
1067
|
-
);
|
|
1068
|
-
if (memberHasPermission) await run(client, interaction);
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
var ContextMenuBuilder = class extends import_discord7.ContextMenuCommandBuilder {
|
|
1072
|
-
_active = true;
|
|
1073
|
-
_ownerOnly = false;
|
|
1074
|
-
_permission = 0 /* USER */;
|
|
1075
|
-
_ephemeralReply = false;
|
|
1076
|
-
/**
|
|
1077
|
-
* Set the command as disabled.
|
|
1078
|
-
*
|
|
1079
|
-
* @public
|
|
1080
|
-
* @returns {this}
|
|
1081
|
-
*/
|
|
1082
|
-
disable() {
|
|
1083
|
-
this._active = false;
|
|
1084
|
-
return this;
|
|
1085
|
-
}
|
|
1086
|
-
/**
|
|
1087
|
-
* Set the command as owner only.
|
|
1088
|
-
*
|
|
1089
|
-
* @public
|
|
1090
|
-
* @returns {this}
|
|
1091
|
-
*/
|
|
1092
|
-
setOwnerOnly() {
|
|
1093
|
-
this._permission = 5 /* BOT_OWNER */;
|
|
1094
|
-
this._ownerOnly = true;
|
|
1095
|
-
return this;
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* Set the permission level required to run the command.
|
|
1099
|
-
*
|
|
1100
|
-
* @public
|
|
1101
|
-
* @param {PermissionLevel} permission
|
|
1102
|
-
* @returns {this}
|
|
1103
|
-
*/
|
|
1104
|
-
setPermission(permission) {
|
|
1105
|
-
this._permission = permission;
|
|
1106
|
-
return this;
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Set the interaction as ephemeral.
|
|
1110
|
-
*
|
|
1111
|
-
* @public
|
|
1112
|
-
* @returns {this}
|
|
1113
|
-
*/
|
|
1114
|
-
setEphemeralReply() {
|
|
1115
|
-
this._ephemeralReply = true;
|
|
1116
|
-
return this;
|
|
1117
|
-
}
|
|
1118
|
-
/**
|
|
1119
|
-
* Build the builder
|
|
1120
|
-
*
|
|
1121
|
-
* @public
|
|
1122
|
-
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1123
|
-
*/
|
|
1124
|
-
build() {
|
|
1125
|
-
return {
|
|
1126
|
-
data: this,
|
|
1127
|
-
metadata: {
|
|
1128
|
-
active: this._active,
|
|
1129
|
-
ownerOnly: this._ownerOnly,
|
|
1130
|
-
permission: this._permission,
|
|
1131
|
-
ephemeralReply: this._ephemeralReply
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
|
-
// src/core/commands/command.base.ts
|
|
1138
960
|
var Command = class {
|
|
1139
961
|
/**
|
|
1140
962
|
* Returns whether the command is a SlashCommand.
|
|
@@ -1144,7 +966,7 @@ var Command = class {
|
|
|
1144
966
|
* @returns {this is SlashCommand}
|
|
1145
967
|
*/
|
|
1146
968
|
isSlashCommand() {
|
|
1147
|
-
return this.data instanceof
|
|
969
|
+
return this.data instanceof discord_js.SlashCommandBuilder;
|
|
1148
970
|
}
|
|
1149
971
|
/**
|
|
1150
972
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -1154,7 +976,7 @@ var Command = class {
|
|
|
1154
976
|
* @returns {this is ContextMenuCommand}
|
|
1155
977
|
*/
|
|
1156
978
|
isContextMenuCommand() {
|
|
1157
|
-
return this.data instanceof
|
|
979
|
+
return this.data instanceof discord_js.ContextMenuCommandBuilder;
|
|
1158
980
|
}
|
|
1159
981
|
/**
|
|
1160
982
|
* Returns JSON of the command builder.
|
|
@@ -1249,12 +1071,12 @@ var SlashCommand = class extends Command {
|
|
|
1249
1071
|
await subcommand.execute(client, interaction);
|
|
1250
1072
|
}
|
|
1251
1073
|
};
|
|
1252
|
-
var CommandBuilder = class extends
|
|
1074
|
+
var CommandBuilder = class extends discord_js.SlashCommandBuilder {
|
|
1253
1075
|
_active = true;
|
|
1254
1076
|
_guildOnly = false;
|
|
1255
1077
|
_ownerOnly = false;
|
|
1256
1078
|
_permission = 0 /* USER */;
|
|
1257
|
-
_subcommands = new
|
|
1079
|
+
_subcommands = new discord_js.Collection();
|
|
1258
1080
|
_ephemeralReply = false;
|
|
1259
1081
|
/**
|
|
1260
1082
|
* Set the command as disabled.
|
|
@@ -1275,7 +1097,7 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1275
1097
|
setGuildOnly() {
|
|
1276
1098
|
this._guildOnly = true;
|
|
1277
1099
|
this._permission = 0 /* USER */;
|
|
1278
|
-
this.setContexts(
|
|
1100
|
+
this.setContexts(discord_js.InteractionContextType.Guild);
|
|
1279
1101
|
return this;
|
|
1280
1102
|
}
|
|
1281
1103
|
/**
|
|
@@ -1330,10 +1152,7 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1330
1152
|
};
|
|
1331
1153
|
}
|
|
1332
1154
|
};
|
|
1333
|
-
|
|
1334
|
-
// src/core/commands/subcommand.base.ts
|
|
1335
|
-
var import_discord9 = require("discord.js");
|
|
1336
|
-
var SubcommandBuilder = class extends import_discord9.SlashCommandSubcommandBuilder {
|
|
1155
|
+
var SubcommandBuilder = class extends discord_js.SlashCommandSubcommandBuilder {
|
|
1337
1156
|
_active = true;
|
|
1338
1157
|
_ownerOnly = false;
|
|
1339
1158
|
_permission = 0 /* USER */;
|
|
@@ -1417,6 +1236,92 @@ var Subcommand = class {
|
|
|
1417
1236
|
await interaction.reply(newOptions);
|
|
1418
1237
|
}
|
|
1419
1238
|
};
|
|
1239
|
+
var ContextMenuCommand = class extends Command {
|
|
1240
|
+
/**
|
|
1241
|
+
* Base command handler.
|
|
1242
|
+
*
|
|
1243
|
+
* @public
|
|
1244
|
+
* @async
|
|
1245
|
+
* @param {TriviousClient} client
|
|
1246
|
+
* @param {ContextMenuCommandInteraction} interaction
|
|
1247
|
+
* @returns {*}
|
|
1248
|
+
*/
|
|
1249
|
+
async execute(client, interaction) {
|
|
1250
|
+
const { run, metadata } = this;
|
|
1251
|
+
const memberHasPermission = await this.validateGuildPermission(
|
|
1252
|
+
client,
|
|
1253
|
+
interaction,
|
|
1254
|
+
metadata.permission,
|
|
1255
|
+
false
|
|
1256
|
+
);
|
|
1257
|
+
if (memberHasPermission) await run(client, interaction);
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
|
|
1261
|
+
_active = true;
|
|
1262
|
+
_ownerOnly = false;
|
|
1263
|
+
_permission = 0 /* USER */;
|
|
1264
|
+
_ephemeralReply = false;
|
|
1265
|
+
/**
|
|
1266
|
+
* Set the command as disabled.
|
|
1267
|
+
*
|
|
1268
|
+
* @public
|
|
1269
|
+
* @returns {this}
|
|
1270
|
+
*/
|
|
1271
|
+
disable() {
|
|
1272
|
+
this._active = false;
|
|
1273
|
+
return this;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Set the command as owner only.
|
|
1277
|
+
*
|
|
1278
|
+
* @public
|
|
1279
|
+
* @returns {this}
|
|
1280
|
+
*/
|
|
1281
|
+
setOwnerOnly() {
|
|
1282
|
+
this._permission = 5 /* BOT_OWNER */;
|
|
1283
|
+
this._ownerOnly = true;
|
|
1284
|
+
return this;
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Set the permission level required to run the command.
|
|
1288
|
+
*
|
|
1289
|
+
* @public
|
|
1290
|
+
* @param {PermissionLevel} permission
|
|
1291
|
+
* @returns {this}
|
|
1292
|
+
*/
|
|
1293
|
+
setPermission(permission) {
|
|
1294
|
+
this._permission = permission;
|
|
1295
|
+
return this;
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Set the interaction as ephemeral.
|
|
1299
|
+
*
|
|
1300
|
+
* @public
|
|
1301
|
+
* @returns {this}
|
|
1302
|
+
*/
|
|
1303
|
+
setEphemeralReply() {
|
|
1304
|
+
this._ephemeralReply = true;
|
|
1305
|
+
return this;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Build the builder
|
|
1309
|
+
*
|
|
1310
|
+
* @public
|
|
1311
|
+
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1312
|
+
*/
|
|
1313
|
+
build() {
|
|
1314
|
+
return {
|
|
1315
|
+
data: this,
|
|
1316
|
+
metadata: {
|
|
1317
|
+
active: this._active,
|
|
1318
|
+
ownerOnly: this._ownerOnly,
|
|
1319
|
+
permission: this._permission,
|
|
1320
|
+
ephemeralReply: this._ephemeralReply
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1420
1325
|
|
|
1421
1326
|
// src/core/components/component.base.ts
|
|
1422
1327
|
var ComponentBuilder = class {
|
|
@@ -1519,28 +1424,30 @@ var Component = class {
|
|
|
1519
1424
|
}
|
|
1520
1425
|
};
|
|
1521
1426
|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
Collection
|
|
1529
|
-
Command,
|
|
1530
|
-
CommandBuilder,
|
|
1531
|
-
CommandRegistry,
|
|
1532
|
-
Component,
|
|
1533
|
-
ComponentBuilder,
|
|
1534
|
-
ComponentRegistry,
|
|
1535
|
-
ComponentType,
|
|
1536
|
-
ContextMenuBuilder,
|
|
1537
|
-
ContextMenuCommand,
|
|
1538
|
-
PermissionLevel,
|
|
1539
|
-
SlashCommand,
|
|
1540
|
-
Subcommand,
|
|
1541
|
-
SubcommandBuilder,
|
|
1542
|
-
TriviousClient,
|
|
1543
|
-
deconstructCustomId,
|
|
1544
|
-
getPermissionLevel
|
|
1427
|
+
Object.defineProperty(exports, "ClientEvents", {
|
|
1428
|
+
enumerable: true,
|
|
1429
|
+
get: function () { return discord_js.ClientEvents; }
|
|
1430
|
+
});
|
|
1431
|
+
Object.defineProperty(exports, "Collection", {
|
|
1432
|
+
enumerable: true,
|
|
1433
|
+
get: function () { return discord_js.Collection; }
|
|
1545
1434
|
});
|
|
1435
|
+
exports.BaseRegistry = BaseRegistry;
|
|
1436
|
+
exports.Command = Command;
|
|
1437
|
+
exports.CommandBuilder = CommandBuilder;
|
|
1438
|
+
exports.CommandRegistry = CommandRegistry;
|
|
1439
|
+
exports.Component = Component;
|
|
1440
|
+
exports.ComponentBuilder = ComponentBuilder;
|
|
1441
|
+
exports.ComponentRegistry = ComponentRegistry;
|
|
1442
|
+
exports.ComponentType = ComponentType;
|
|
1443
|
+
exports.ContextMenuBuilder = ContextMenuBuilder;
|
|
1444
|
+
exports.ContextMenuCommand = ContextMenuCommand;
|
|
1445
|
+
exports.PermissionLevel = PermissionLevel;
|
|
1446
|
+
exports.SlashCommand = SlashCommand;
|
|
1447
|
+
exports.Subcommand = Subcommand;
|
|
1448
|
+
exports.SubcommandBuilder = SubcommandBuilder;
|
|
1449
|
+
exports.TriviousClient = TriviousClient;
|
|
1450
|
+
exports.deconstructCustomId = deconstructCustomId;
|
|
1451
|
+
exports.getPermissionLevel = getPermissionLevel;
|
|
1452
|
+
//# sourceMappingURL=index.cjs.map
|
|
1546
1453
|
//# sourceMappingURL=index.cjs.map
|