trivious 1.3.13 → 1.3.15
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 +210 -343
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +128 -249
- 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,18 +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_url = require("url");
|
|
525
|
-
var import_path = require("path");
|
|
526
|
-
|
|
527
479
|
// src/shared/typings/permissions.ts
|
|
528
480
|
var PermissionLevel = /* @__PURE__ */ ((PermissionLevel2) => {
|
|
529
481
|
PermissionLevel2[PermissionLevel2["USER"] = 0] = "USER";
|
|
@@ -542,18 +494,17 @@ var getPermissionLevel = (client, member) => {
|
|
|
542
494
|
};
|
|
543
495
|
|
|
544
496
|
// src/shared/utility/functions.ts
|
|
545
|
-
var
|
|
546
|
-
var
|
|
547
|
-
var __dirname = (0, import_path.dirname)(__filename);
|
|
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);
|
|
548
499
|
var getPackageRoot = () => {
|
|
549
|
-
let dir = __dirname;
|
|
550
|
-
while (dir !==
|
|
551
|
-
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"))) {
|
|
552
503
|
return dir;
|
|
553
504
|
}
|
|
554
|
-
dir =
|
|
505
|
+
dir = path.dirname(dir);
|
|
555
506
|
}
|
|
556
|
-
return __dirname;
|
|
507
|
+
return __dirname$1;
|
|
557
508
|
};
|
|
558
509
|
var FRAMEWORK_PACKAGE_ROOT = getPackageRoot();
|
|
559
510
|
function getCorePath(options) {
|
|
@@ -562,34 +513,34 @@ function getCorePath(options) {
|
|
|
562
513
|
return resolveUserPath(userPath);
|
|
563
514
|
}
|
|
564
515
|
const builtInCandidates = [
|
|
565
|
-
|
|
566
|
-
|
|
516
|
+
path.join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory),
|
|
517
|
+
path.join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory)
|
|
567
518
|
];
|
|
568
519
|
for (const candidate of builtInCandidates) {
|
|
569
|
-
if (
|
|
520
|
+
if (fs.existsSync(candidate)) {
|
|
570
521
|
return candidate;
|
|
571
522
|
}
|
|
572
523
|
}
|
|
573
|
-
return
|
|
524
|
+
return path.join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory);
|
|
574
525
|
}
|
|
575
526
|
function resolveUserPath(relativePath) {
|
|
576
527
|
const candidates = [
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
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)
|
|
583
534
|
];
|
|
584
535
|
for (const candidate of candidates) {
|
|
585
|
-
const full =
|
|
586
|
-
if (
|
|
536
|
+
const full = path.resolve(candidate);
|
|
537
|
+
if (fs.existsSync(full)) return full;
|
|
587
538
|
}
|
|
588
|
-
return
|
|
539
|
+
return path.join(process.cwd(), relativePath);
|
|
589
540
|
}
|
|
590
541
|
async function exists(path2) {
|
|
591
542
|
try {
|
|
592
|
-
await
|
|
543
|
+
await fs.promises.access(path2);
|
|
593
544
|
return true;
|
|
594
545
|
} catch {
|
|
595
546
|
return false;
|
|
@@ -607,12 +558,6 @@ function hasPermission(client, options) {
|
|
|
607
558
|
}
|
|
608
559
|
return false;
|
|
609
560
|
}
|
|
610
|
-
|
|
611
|
-
// src/core/registry/command.registry.ts
|
|
612
|
-
var import_discord = require("discord.js");
|
|
613
|
-
|
|
614
|
-
// src/shared/typings/registry.ts
|
|
615
|
-
var import_url2 = require("url");
|
|
616
561
|
var BaseRegistry = class {
|
|
617
562
|
/**
|
|
618
563
|
* Get all of loaded T
|
|
@@ -633,7 +578,7 @@ var BaseRegistry = class {
|
|
|
633
578
|
*/
|
|
634
579
|
async importFile(filePath) {
|
|
635
580
|
try {
|
|
636
|
-
const { default: file } = await import(
|
|
581
|
+
const { default: file } = await import(url.pathToFileURL(filePath).href);
|
|
637
582
|
const imports = file.default ?? file;
|
|
638
583
|
if (!imports) return null;
|
|
639
584
|
if (typeof imports === "function" && imports.prototype) {
|
|
@@ -662,8 +607,8 @@ var BaseRegistry = class {
|
|
|
662
607
|
async clearCache(filePath) {
|
|
663
608
|
if (process.env.NODE_ENV === "production") return;
|
|
664
609
|
try {
|
|
665
|
-
const resvoled =
|
|
666
|
-
delete
|
|
610
|
+
const resvoled = __require.resolve(filePath);
|
|
611
|
+
delete __require.cache[resvoled];
|
|
667
612
|
} catch {
|
|
668
613
|
}
|
|
669
614
|
}
|
|
@@ -685,12 +630,8 @@ var deconstructCustomId = (customId) => {
|
|
|
685
630
|
tags
|
|
686
631
|
};
|
|
687
632
|
};
|
|
688
|
-
|
|
689
|
-
// src/core/registry/command.registry.ts
|
|
690
|
-
var import_fs2 = require("fs");
|
|
691
|
-
var import_node_path2 = require("path");
|
|
692
633
|
var CommandRegistry = class extends BaseRegistry {
|
|
693
|
-
items = new
|
|
634
|
+
items = new discord_js.Collection();
|
|
694
635
|
/**
|
|
695
636
|
* Load all commands and their subcommands
|
|
696
637
|
*
|
|
@@ -702,12 +643,12 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
702
643
|
if (!await exists(directory)) {
|
|
703
644
|
return this;
|
|
704
645
|
}
|
|
705
|
-
const entries = await
|
|
646
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
706
647
|
for (const entry of entries) {
|
|
707
|
-
const fullPath =
|
|
648
|
+
const fullPath = path.join(directory, entry.name);
|
|
708
649
|
if (!entry.isDirectory()) continue;
|
|
709
|
-
const indexFile =
|
|
710
|
-
const indexJs =
|
|
650
|
+
const indexFile = path.join(fullPath, "index.ts");
|
|
651
|
+
const indexJs = path.join(fullPath, "index.js");
|
|
711
652
|
let commandFile = "";
|
|
712
653
|
if (await exists(indexFile)) commandFile = indexFile;
|
|
713
654
|
else if (await exists(indexJs)) commandFile = indexJs;
|
|
@@ -716,13 +657,13 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
716
657
|
if (!command) continue;
|
|
717
658
|
if (!command.metadata.active) continue;
|
|
718
659
|
if (command.isSlashCommand()) {
|
|
719
|
-
const subcommandFiles = (await
|
|
660
|
+
const subcommandFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
720
661
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
721
662
|
);
|
|
722
663
|
for (const file of subcommandFiles) {
|
|
723
|
-
const subcommand = await this.importFile(
|
|
664
|
+
const subcommand = await this.importFile(path.join(fullPath, file));
|
|
724
665
|
if (!subcommand) continue;
|
|
725
|
-
if (!subcommand.data.name || !(subcommand.data instanceof
|
|
666
|
+
if (!subcommand.data.name || !(subcommand.data instanceof discord_js.SlashCommandSubcommandBuilder))
|
|
726
667
|
continue;
|
|
727
668
|
command.data.addSubcommand(subcommand.data);
|
|
728
669
|
command.metadata.subcommands.set(subcommand.data.name, subcommand);
|
|
@@ -733,13 +674,8 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
733
674
|
return this;
|
|
734
675
|
}
|
|
735
676
|
};
|
|
736
|
-
|
|
737
|
-
// src/core/registry/component.registry.ts
|
|
738
|
-
var import_discord2 = require("discord.js");
|
|
739
|
-
var import_fs3 = require("fs");
|
|
740
|
-
var import_node_path3 = require("path");
|
|
741
677
|
var ComponentRegistry = class extends BaseRegistry {
|
|
742
|
-
items = new
|
|
678
|
+
items = new discord_js.Collection();
|
|
743
679
|
/**
|
|
744
680
|
* Load all components.
|
|
745
681
|
*
|
|
@@ -751,15 +687,15 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
751
687
|
if (!await exists(directory)) {
|
|
752
688
|
return this;
|
|
753
689
|
}
|
|
754
|
-
const entries = await
|
|
690
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
755
691
|
for (const entry of entries) {
|
|
756
|
-
const fullPath =
|
|
692
|
+
const fullPath = path.join(directory, entry.name);
|
|
757
693
|
if (!entry.isDirectory()) continue;
|
|
758
|
-
const componentFiles = (await
|
|
694
|
+
const componentFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
759
695
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
760
696
|
);
|
|
761
697
|
for (const file of componentFiles) {
|
|
762
|
-
const component = await this.importFile(
|
|
698
|
+
const component = await this.importFile(path.join(fullPath, file));
|
|
763
699
|
if (!component) continue;
|
|
764
700
|
const { data } = deconstructCustomId(component.metadata.customId);
|
|
765
701
|
this.items.set(data, component);
|
|
@@ -768,14 +704,6 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
768
704
|
return this;
|
|
769
705
|
}
|
|
770
706
|
};
|
|
771
|
-
|
|
772
|
-
// src/core/registry/event.registry.ts
|
|
773
|
-
var import_discord4 = require("discord.js");
|
|
774
|
-
var import_fs4 = require("fs");
|
|
775
|
-
var import_node_path4 = require("path");
|
|
776
|
-
|
|
777
|
-
// src/core/events/interactionCreate.ts
|
|
778
|
-
var import_discord3 = require("discord.js");
|
|
779
707
|
var interactionCreate_default = {
|
|
780
708
|
name: "interactionCreate",
|
|
781
709
|
execute: async (client, interaction) => {
|
|
@@ -805,9 +733,9 @@ var interactionCreate_default = {
|
|
|
805
733
|
}
|
|
806
734
|
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
807
735
|
const { componentType, tags, data } = deconstructCustomId(interaction.customId);
|
|
808
|
-
if (componentType === "button" /* Button */ && !(interaction instanceof
|
|
736
|
+
if (componentType === "button" /* Button */ && !(interaction instanceof discord_js.ButtonInteraction))
|
|
809
737
|
return;
|
|
810
|
-
if (componentType === "modal" /* Modal */ && !(interaction instanceof
|
|
738
|
+
if (componentType === "modal" /* Modal */ && !(interaction instanceof discord_js.ModalSubmitInteraction))
|
|
811
739
|
return;
|
|
812
740
|
if (tags.includes("awaited")) return;
|
|
813
741
|
const registeredComponents = client.registries.components.get();
|
|
@@ -834,7 +762,7 @@ var interactionCreate_default = {
|
|
|
834
762
|
|
|
835
763
|
// src/core/registry/event.registry.ts
|
|
836
764
|
var EventRegistry = class extends BaseRegistry {
|
|
837
|
-
items = new
|
|
765
|
+
items = new discord_js.Collection();
|
|
838
766
|
/**
|
|
839
767
|
* Load all events.
|
|
840
768
|
*
|
|
@@ -844,9 +772,9 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
844
772
|
*/
|
|
845
773
|
async load(directory = getCorePath({ coreDirectory: "events" })) {
|
|
846
774
|
if (!await exists(directory)) return this;
|
|
847
|
-
const entries = await
|
|
775
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
848
776
|
for (const entry of entries) {
|
|
849
|
-
const fullPath =
|
|
777
|
+
const fullPath = path.join(directory, entry.name);
|
|
850
778
|
if (entry.isDirectory()) {
|
|
851
779
|
await this.load(fullPath);
|
|
852
780
|
continue;
|
|
@@ -857,8 +785,7 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
857
785
|
this.items.set(event.name, event);
|
|
858
786
|
}
|
|
859
787
|
}
|
|
860
|
-
|
|
861
|
-
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
788
|
+
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
862
789
|
return this;
|
|
863
790
|
}
|
|
864
791
|
/**
|
|
@@ -874,13 +801,8 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
874
801
|
}
|
|
875
802
|
}
|
|
876
803
|
};
|
|
877
|
-
|
|
878
|
-
// src/core/registry/module.registry.ts
|
|
879
|
-
var import_discord5 = require("discord.js");
|
|
880
|
-
var import_fs5 = require("fs");
|
|
881
|
-
var import_node_path5 = require("path");
|
|
882
804
|
var ModuleRegistry = class extends BaseRegistry {
|
|
883
|
-
items = new
|
|
805
|
+
items = new discord_js.Collection();
|
|
884
806
|
/**
|
|
885
807
|
* Load all modules.
|
|
886
808
|
*
|
|
@@ -892,15 +814,15 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
892
814
|
if (!await exists(directory)) {
|
|
893
815
|
return this;
|
|
894
816
|
}
|
|
895
|
-
const entries = await
|
|
817
|
+
const entries = await fs.promises.readdir(directory, { withFileTypes: true });
|
|
896
818
|
for (const entry of entries) {
|
|
897
|
-
const fullPath =
|
|
819
|
+
const fullPath = path.join(directory, entry.name);
|
|
898
820
|
if (!entry.isDirectory()) continue;
|
|
899
|
-
const moduleFiles = (await
|
|
821
|
+
const moduleFiles = (await fs.promises.readdir(fullPath)).filter(
|
|
900
822
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
901
823
|
);
|
|
902
824
|
for (const file of moduleFiles) {
|
|
903
|
-
const moduleEvent = await this.importFile(
|
|
825
|
+
const moduleEvent = await this.importFile(path.join(fullPath, file));
|
|
904
826
|
if (!moduleEvent || !moduleEvent.events) continue;
|
|
905
827
|
this.items.set(moduleEvent.name, moduleEvent);
|
|
906
828
|
}
|
|
@@ -924,9 +846,6 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
924
846
|
}
|
|
925
847
|
}
|
|
926
848
|
};
|
|
927
|
-
|
|
928
|
-
// src/core/registry/index.ts
|
|
929
|
-
var import_node_path6 = __toESM(require("path"), 1);
|
|
930
849
|
var registries = () => ({
|
|
931
850
|
commands: new CommandRegistry(),
|
|
932
851
|
components: new ComponentRegistry(),
|
|
@@ -937,16 +856,16 @@ var registries = () => ({
|
|
|
937
856
|
const corePath = options.corePath;
|
|
938
857
|
await Promise.all([
|
|
939
858
|
this.commands.load(
|
|
940
|
-
corePath ? resolveUserPath(
|
|
859
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
|
|
941
860
|
),
|
|
942
861
|
this.components.load(
|
|
943
|
-
corePath ? resolveUserPath(
|
|
862
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
|
|
944
863
|
),
|
|
945
864
|
this.events.load(
|
|
946
|
-
corePath ? resolveUserPath(
|
|
865
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
|
|
947
866
|
),
|
|
948
867
|
this.modules.load(
|
|
949
|
-
corePath ? resolveUserPath(
|
|
868
|
+
corePath ? resolveUserPath(path__default.default.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
|
|
950
869
|
)
|
|
951
870
|
]);
|
|
952
871
|
},
|
|
@@ -957,7 +876,7 @@ var registries = () => ({
|
|
|
957
876
|
});
|
|
958
877
|
|
|
959
878
|
// src/core/client/trivious.client.ts
|
|
960
|
-
var TriviousClient = class extends
|
|
879
|
+
var TriviousClient = class extends discord_js.Client {
|
|
961
880
|
/**
|
|
962
881
|
* Client registries.
|
|
963
882
|
*
|
|
@@ -1022,8 +941,8 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1022
941
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
1023
942
|
const slashCommands = Array.from(this.registries.commands.get().values());
|
|
1024
943
|
const body = [...slashCommands.map((command) => command.toJSON())];
|
|
1025
|
-
const rest = new
|
|
1026
|
-
await rest.put(
|
|
944
|
+
const rest = new discord_js.REST({ version: "10" }).setToken(token);
|
|
945
|
+
await rest.put(discord_js.Routes.applicationCommands(clientId), { body });
|
|
1027
946
|
console.log(`[Trivious] Deployed ${body.length} commands`);
|
|
1028
947
|
}
|
|
1029
948
|
/**
|
|
@@ -1038,100 +957,6 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1038
957
|
return this._options.rolePermissions ?? {};
|
|
1039
958
|
}
|
|
1040
959
|
};
|
|
1041
|
-
|
|
1042
|
-
// src/core/commands/command.base.ts
|
|
1043
|
-
var import_discord8 = require("discord.js");
|
|
1044
|
-
|
|
1045
|
-
// src/core/commands/contextcommand.base.ts
|
|
1046
|
-
var import_discord7 = require("discord.js");
|
|
1047
|
-
var ContextMenuCommand = class extends Command {
|
|
1048
|
-
/**
|
|
1049
|
-
* Base command handler.
|
|
1050
|
-
*
|
|
1051
|
-
* @public
|
|
1052
|
-
* @async
|
|
1053
|
-
* @param {TriviousClient} client
|
|
1054
|
-
* @param {ContextMenuCommandInteraction} interaction
|
|
1055
|
-
* @returns {*}
|
|
1056
|
-
*/
|
|
1057
|
-
async execute(client, interaction) {
|
|
1058
|
-
const { run, metadata } = this;
|
|
1059
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1060
|
-
client,
|
|
1061
|
-
interaction,
|
|
1062
|
-
metadata.permission,
|
|
1063
|
-
false
|
|
1064
|
-
);
|
|
1065
|
-
if (memberHasPermission) await run(client, interaction);
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
1068
|
-
var ContextMenuBuilder = class extends import_discord7.ContextMenuCommandBuilder {
|
|
1069
|
-
_active = true;
|
|
1070
|
-
_ownerOnly = false;
|
|
1071
|
-
_permission = 0 /* USER */;
|
|
1072
|
-
_ephemeralReply = false;
|
|
1073
|
-
/**
|
|
1074
|
-
* Set the command as disabled.
|
|
1075
|
-
*
|
|
1076
|
-
* @public
|
|
1077
|
-
* @returns {this}
|
|
1078
|
-
*/
|
|
1079
|
-
disable() {
|
|
1080
|
-
this._active = false;
|
|
1081
|
-
return this;
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* Set the command as owner only.
|
|
1085
|
-
*
|
|
1086
|
-
* @public
|
|
1087
|
-
* @returns {this}
|
|
1088
|
-
*/
|
|
1089
|
-
setOwnerOnly() {
|
|
1090
|
-
this._permission = 5 /* BOT_OWNER */;
|
|
1091
|
-
this._ownerOnly = true;
|
|
1092
|
-
return this;
|
|
1093
|
-
}
|
|
1094
|
-
/**
|
|
1095
|
-
* Set the permission level required to run the command.
|
|
1096
|
-
*
|
|
1097
|
-
* @public
|
|
1098
|
-
* @param {PermissionLevel} permission
|
|
1099
|
-
* @returns {this}
|
|
1100
|
-
*/
|
|
1101
|
-
setPermission(permission) {
|
|
1102
|
-
this._permission = permission;
|
|
1103
|
-
return this;
|
|
1104
|
-
}
|
|
1105
|
-
/**
|
|
1106
|
-
* Set the interaction as ephemeral.
|
|
1107
|
-
*
|
|
1108
|
-
* @public
|
|
1109
|
-
* @returns {this}
|
|
1110
|
-
*/
|
|
1111
|
-
setEphemeralReply() {
|
|
1112
|
-
this._ephemeralReply = true;
|
|
1113
|
-
return this;
|
|
1114
|
-
}
|
|
1115
|
-
/**
|
|
1116
|
-
* Build the builder
|
|
1117
|
-
*
|
|
1118
|
-
* @public
|
|
1119
|
-
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1120
|
-
*/
|
|
1121
|
-
build() {
|
|
1122
|
-
return {
|
|
1123
|
-
data: this,
|
|
1124
|
-
metadata: {
|
|
1125
|
-
active: this._active,
|
|
1126
|
-
ownerOnly: this._ownerOnly,
|
|
1127
|
-
permission: this._permission,
|
|
1128
|
-
ephemeralReply: this._ephemeralReply
|
|
1129
|
-
}
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
|
-
// src/core/commands/command.base.ts
|
|
1135
960
|
var Command = class {
|
|
1136
961
|
/**
|
|
1137
962
|
* Returns whether the command is a SlashCommand.
|
|
@@ -1141,7 +966,7 @@ var Command = class {
|
|
|
1141
966
|
* @returns {this is SlashCommand}
|
|
1142
967
|
*/
|
|
1143
968
|
isSlashCommand() {
|
|
1144
|
-
return this.data instanceof
|
|
969
|
+
return this.data instanceof discord_js.SlashCommandBuilder;
|
|
1145
970
|
}
|
|
1146
971
|
/**
|
|
1147
972
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -1151,7 +976,7 @@ var Command = class {
|
|
|
1151
976
|
* @returns {this is ContextMenuCommand}
|
|
1152
977
|
*/
|
|
1153
978
|
isContextMenuCommand() {
|
|
1154
|
-
return this.data instanceof
|
|
979
|
+
return this.data instanceof discord_js.ContextMenuCommandBuilder;
|
|
1155
980
|
}
|
|
1156
981
|
/**
|
|
1157
982
|
* Returns JSON of the command builder.
|
|
@@ -1204,54 +1029,12 @@ var Command = class {
|
|
|
1204
1029
|
return memberHasPermission;
|
|
1205
1030
|
}
|
|
1206
1031
|
};
|
|
1207
|
-
var
|
|
1208
|
-
/**
|
|
1209
|
-
* General handler for the command and its subcommand, if applicable.
|
|
1210
|
-
*
|
|
1211
|
-
* @public
|
|
1212
|
-
* @async
|
|
1213
|
-
* @param {TriviousClient} client
|
|
1214
|
-
* @param {ChatInputCommandInteraction} interaction
|
|
1215
|
-
* @returns {*}
|
|
1216
|
-
*/
|
|
1217
|
-
async execute(client, interaction) {
|
|
1218
|
-
const { run, reply, metadata } = this;
|
|
1219
|
-
const { options } = interaction;
|
|
1220
|
-
if (run) {
|
|
1221
|
-
const memberHasPermission2 = await this.validateGuildPermission(
|
|
1222
|
-
client,
|
|
1223
|
-
interaction,
|
|
1224
|
-
metadata.permission,
|
|
1225
|
-
false
|
|
1226
|
-
);
|
|
1227
|
-
if (memberHasPermission2) await run(client, interaction);
|
|
1228
|
-
}
|
|
1229
|
-
const subcommands = metadata.subcommands;
|
|
1230
|
-
if (subcommands.size <= 0) return;
|
|
1231
|
-
const subcommand = metadata.subcommands.find(
|
|
1232
|
-
(subcmd) => subcmd.data.name === options.getSubcommand()
|
|
1233
|
-
);
|
|
1234
|
-
if (!subcommand) {
|
|
1235
|
-
await reply(interaction, {
|
|
1236
|
-
content: "Ran subcommand is outdated or does not have a handler!"
|
|
1237
|
-
});
|
|
1238
|
-
return;
|
|
1239
|
-
}
|
|
1240
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1241
|
-
client,
|
|
1242
|
-
interaction,
|
|
1243
|
-
subcommand.metadata.permission
|
|
1244
|
-
);
|
|
1245
|
-
if (!memberHasPermission) return;
|
|
1246
|
-
await subcommand.execute(client, interaction);
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
1032
|
+
var CommandBuilder = class extends discord_js.SlashCommandBuilder {
|
|
1250
1033
|
_active = true;
|
|
1251
1034
|
_guildOnly = false;
|
|
1252
1035
|
_ownerOnly = false;
|
|
1253
1036
|
_permission = 0 /* USER */;
|
|
1254
|
-
_subcommands = new
|
|
1037
|
+
_subcommands = new discord_js.Collection();
|
|
1255
1038
|
_ephemeralReply = false;
|
|
1256
1039
|
/**
|
|
1257
1040
|
* Set the command as disabled.
|
|
@@ -1272,7 +1055,7 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1272
1055
|
setGuildOnly() {
|
|
1273
1056
|
this._guildOnly = true;
|
|
1274
1057
|
this._permission = 0 /* USER */;
|
|
1275
|
-
this.setContexts(
|
|
1058
|
+
this.setContexts(discord_js.InteractionContextType.Guild);
|
|
1276
1059
|
return this;
|
|
1277
1060
|
}
|
|
1278
1061
|
/**
|
|
@@ -1327,10 +1110,7 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1327
1110
|
};
|
|
1328
1111
|
}
|
|
1329
1112
|
};
|
|
1330
|
-
|
|
1331
|
-
// src/core/commands/subcommand.base.ts
|
|
1332
|
-
var import_discord9 = require("discord.js");
|
|
1333
|
-
var SubcommandBuilder = class extends import_discord9.SlashCommandSubcommandBuilder {
|
|
1113
|
+
var SubcommandBuilder = class extends discord_js.SlashCommandSubcommandBuilder {
|
|
1334
1114
|
_active = true;
|
|
1335
1115
|
_ownerOnly = false;
|
|
1336
1116
|
_permission = 0 /* USER */;
|
|
@@ -1414,6 +1194,92 @@ var Subcommand = class {
|
|
|
1414
1194
|
await interaction.reply(newOptions);
|
|
1415
1195
|
}
|
|
1416
1196
|
};
|
|
1197
|
+
var ContextMenuCommand = class extends Command {
|
|
1198
|
+
/**
|
|
1199
|
+
* Base command handler.
|
|
1200
|
+
*
|
|
1201
|
+
* @public
|
|
1202
|
+
* @async
|
|
1203
|
+
* @param {TriviousClient} client
|
|
1204
|
+
* @param {ContextMenuCommandInteraction} interaction
|
|
1205
|
+
* @returns {*}
|
|
1206
|
+
*/
|
|
1207
|
+
async execute(client, interaction) {
|
|
1208
|
+
const { run, metadata } = this;
|
|
1209
|
+
const memberHasPermission = await this.validateGuildPermission(
|
|
1210
|
+
client,
|
|
1211
|
+
interaction,
|
|
1212
|
+
metadata.permission,
|
|
1213
|
+
false
|
|
1214
|
+
);
|
|
1215
|
+
if (memberHasPermission) await run(client, interaction);
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
|
|
1219
|
+
_active = true;
|
|
1220
|
+
_ownerOnly = false;
|
|
1221
|
+
_permission = 0 /* USER */;
|
|
1222
|
+
_ephemeralReply = false;
|
|
1223
|
+
/**
|
|
1224
|
+
* Set the command as disabled.
|
|
1225
|
+
*
|
|
1226
|
+
* @public
|
|
1227
|
+
* @returns {this}
|
|
1228
|
+
*/
|
|
1229
|
+
disable() {
|
|
1230
|
+
this._active = false;
|
|
1231
|
+
return this;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Set the command as owner only.
|
|
1235
|
+
*
|
|
1236
|
+
* @public
|
|
1237
|
+
* @returns {this}
|
|
1238
|
+
*/
|
|
1239
|
+
setOwnerOnly() {
|
|
1240
|
+
this._permission = 5 /* BOT_OWNER */;
|
|
1241
|
+
this._ownerOnly = true;
|
|
1242
|
+
return this;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Set the permission level required to run the command.
|
|
1246
|
+
*
|
|
1247
|
+
* @public
|
|
1248
|
+
* @param {PermissionLevel} permission
|
|
1249
|
+
* @returns {this}
|
|
1250
|
+
*/
|
|
1251
|
+
setPermission(permission) {
|
|
1252
|
+
this._permission = permission;
|
|
1253
|
+
return this;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Set the interaction as ephemeral.
|
|
1257
|
+
*
|
|
1258
|
+
* @public
|
|
1259
|
+
* @returns {this}
|
|
1260
|
+
*/
|
|
1261
|
+
setEphemeralReply() {
|
|
1262
|
+
this._ephemeralReply = true;
|
|
1263
|
+
return this;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Build the builder
|
|
1267
|
+
*
|
|
1268
|
+
* @public
|
|
1269
|
+
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1270
|
+
*/
|
|
1271
|
+
build() {
|
|
1272
|
+
return {
|
|
1273
|
+
data: this,
|
|
1274
|
+
metadata: {
|
|
1275
|
+
active: this._active,
|
|
1276
|
+
ownerOnly: this._ownerOnly,
|
|
1277
|
+
permission: this._permission,
|
|
1278
|
+
ephemeralReply: this._ephemeralReply
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1417
1283
|
|
|
1418
1284
|
// src/core/components/component.base.ts
|
|
1419
1285
|
var ComponentBuilder = class {
|
|
@@ -1516,28 +1382,29 @@ var Component = class {
|
|
|
1516
1382
|
}
|
|
1517
1383
|
};
|
|
1518
1384
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
Collection
|
|
1526
|
-
Command,
|
|
1527
|
-
CommandBuilder,
|
|
1528
|
-
CommandRegistry,
|
|
1529
|
-
Component,
|
|
1530
|
-
ComponentBuilder,
|
|
1531
|
-
ComponentRegistry,
|
|
1532
|
-
ComponentType,
|
|
1533
|
-
ContextMenuBuilder,
|
|
1534
|
-
ContextMenuCommand,
|
|
1535
|
-
PermissionLevel,
|
|
1536
|
-
SlashCommand,
|
|
1537
|
-
Subcommand,
|
|
1538
|
-
SubcommandBuilder,
|
|
1539
|
-
TriviousClient,
|
|
1540
|
-
deconstructCustomId,
|
|
1541
|
-
getPermissionLevel
|
|
1385
|
+
Object.defineProperty(exports, "ClientEvents", {
|
|
1386
|
+
enumerable: true,
|
|
1387
|
+
get: function () { return discord_js.ClientEvents; }
|
|
1388
|
+
});
|
|
1389
|
+
Object.defineProperty(exports, "Collection", {
|
|
1390
|
+
enumerable: true,
|
|
1391
|
+
get: function () { return discord_js.Collection; }
|
|
1542
1392
|
});
|
|
1393
|
+
exports.BaseRegistry = BaseRegistry;
|
|
1394
|
+
exports.Command = Command;
|
|
1395
|
+
exports.CommandBuilder = CommandBuilder;
|
|
1396
|
+
exports.CommandRegistry = CommandRegistry;
|
|
1397
|
+
exports.Component = Component;
|
|
1398
|
+
exports.ComponentBuilder = ComponentBuilder;
|
|
1399
|
+
exports.ComponentRegistry = ComponentRegistry;
|
|
1400
|
+
exports.ComponentType = ComponentType;
|
|
1401
|
+
exports.ContextMenuBuilder = ContextMenuBuilder;
|
|
1402
|
+
exports.ContextMenuCommand = ContextMenuCommand;
|
|
1403
|
+
exports.PermissionLevel = PermissionLevel;
|
|
1404
|
+
exports.Subcommand = Subcommand;
|
|
1405
|
+
exports.SubcommandBuilder = SubcommandBuilder;
|
|
1406
|
+
exports.TriviousClient = TriviousClient;
|
|
1407
|
+
exports.deconstructCustomId = deconstructCustomId;
|
|
1408
|
+
exports.getPermissionLevel = getPermissionLevel;
|
|
1409
|
+
//# sourceMappingURL=index.cjs.map
|
|
1543
1410
|
//# sourceMappingURL=index.cjs.map
|