trivious 1.3.12 → 1.3.14
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/{esm/index.js → index.cjs} +166 -122
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +124 -162
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
9
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
10
|
};
|
|
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
11
|
|
|
33
12
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
|
|
34
13
|
var require_package = __commonJS({
|
|
35
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(
|
|
36
|
-
|
|
14
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(exports, module) {
|
|
15
|
+
module.exports = {
|
|
37
16
|
name: "dotenv",
|
|
38
17
|
version: "17.2.3",
|
|
39
18
|
description: "Loads environment variables from .env file",
|
|
@@ -100,12 +79,12 @@ var require_package = __commonJS({
|
|
|
100
79
|
|
|
101
80
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
|
|
102
81
|
var require_main = __commonJS({
|
|
103
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(
|
|
82
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
104
83
|
"use strict";
|
|
105
|
-
var fs6 =
|
|
106
|
-
var path2 =
|
|
107
|
-
var os =
|
|
108
|
-
var crypto =
|
|
84
|
+
var fs6 = __require("fs");
|
|
85
|
+
var path2 = __require("path");
|
|
86
|
+
var os = __require("os");
|
|
87
|
+
var crypto = __require("crypto");
|
|
109
88
|
var packageJson = require_package();
|
|
110
89
|
var version = packageJson.version;
|
|
111
90
|
var TIPS = [
|
|
@@ -417,20 +396,20 @@ var require_main = __commonJS({
|
|
|
417
396
|
parse,
|
|
418
397
|
populate
|
|
419
398
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
399
|
+
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
400
|
+
module.exports._configVault = DotenvModule._configVault;
|
|
401
|
+
module.exports._parseVault = DotenvModule._parseVault;
|
|
402
|
+
module.exports.config = DotenvModule.config;
|
|
403
|
+
module.exports.decrypt = DotenvModule.decrypt;
|
|
404
|
+
module.exports.parse = DotenvModule.parse;
|
|
405
|
+
module.exports.populate = DotenvModule.populate;
|
|
406
|
+
module.exports = DotenvModule;
|
|
428
407
|
}
|
|
429
408
|
});
|
|
430
409
|
|
|
431
410
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js
|
|
432
411
|
var require_env_options = __commonJS({
|
|
433
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js"(
|
|
412
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js"(exports, module) {
|
|
434
413
|
"use strict";
|
|
435
414
|
var options = {};
|
|
436
415
|
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
@@ -451,16 +430,16 @@ var require_env_options = __commonJS({
|
|
|
451
430
|
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
452
431
|
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
453
432
|
}
|
|
454
|
-
|
|
433
|
+
module.exports = options;
|
|
455
434
|
}
|
|
456
435
|
});
|
|
457
436
|
|
|
458
437
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js
|
|
459
438
|
var require_cli_options = __commonJS({
|
|
460
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js"(
|
|
439
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js"(exports, module) {
|
|
461
440
|
"use strict";
|
|
462
441
|
var re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
463
|
-
|
|
442
|
+
module.exports = function optionMatcher(args) {
|
|
464
443
|
const options = args.reduce(function(acc, cur) {
|
|
465
444
|
const matches = cur.match(re);
|
|
466
445
|
if (matches) {
|
|
@@ -476,31 +455,6 @@ var require_cli_options = __commonJS({
|
|
|
476
455
|
}
|
|
477
456
|
});
|
|
478
457
|
|
|
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
458
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/config.js
|
|
505
459
|
(function() {
|
|
506
460
|
require_main().config(
|
|
@@ -513,16 +467,15 @@ module.exports = __toCommonJS(index_exports);
|
|
|
513
467
|
})();
|
|
514
468
|
|
|
515
469
|
// src/index.ts
|
|
516
|
-
|
|
470
|
+
import "util";
|
|
517
471
|
|
|
518
472
|
// src/core/client/trivious.client.ts
|
|
519
|
-
|
|
473
|
+
import { Client, REST, Routes } from "discord.js";
|
|
520
474
|
|
|
521
475
|
// src/shared/utility/functions.ts
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
var import_path = require("path");
|
|
476
|
+
import { promises as fs, existsSync } from "fs";
|
|
477
|
+
import { join, resolve } from "path";
|
|
478
|
+
import { dirname as dirname2 } from "path";
|
|
526
479
|
|
|
527
480
|
// src/shared/typings/permissions.ts
|
|
528
481
|
var PermissionLevel = /* @__PURE__ */ ((PermissionLevel2) => {
|
|
@@ -541,17 +494,20 @@ var getPermissionLevel = (client, member) => {
|
|
|
541
494
|
return rolePermissions[highestRole.name] ?? 0 /* USER */;
|
|
542
495
|
};
|
|
543
496
|
|
|
497
|
+
// src/shared/utility/paths.ts
|
|
498
|
+
import { fileURLToPath } from "url";
|
|
499
|
+
import { dirname } from "path";
|
|
500
|
+
var __filename = typeof _filename === "string" ? _filename : fileURLToPath(import.meta.url);
|
|
501
|
+
var __dirname = typeof _dirname === "string" ? _dirname : dirname(__filename);
|
|
502
|
+
|
|
544
503
|
// src/shared/utility/functions.ts
|
|
545
|
-
var import_meta = {};
|
|
546
|
-
var __filename = (0, import_url.fileURLToPath)(import_meta.url);
|
|
547
|
-
var __dirname = (0, import_path.dirname)(__filename);
|
|
548
504
|
var getPackageRoot = () => {
|
|
549
505
|
let dir = __dirname;
|
|
550
|
-
while (dir !== (
|
|
551
|
-
if (
|
|
506
|
+
while (dir !== dirname2(dir)) {
|
|
507
|
+
if (existsSync(join(dir, "package.json")) || existsSync(join(dir, "node_modules"))) {
|
|
552
508
|
return dir;
|
|
553
509
|
}
|
|
554
|
-
dir = (
|
|
510
|
+
dir = dirname2(dir);
|
|
555
511
|
}
|
|
556
512
|
return __dirname;
|
|
557
513
|
};
|
|
@@ -562,34 +518,34 @@ function getCorePath(options) {
|
|
|
562
518
|
return resolveUserPath(userPath);
|
|
563
519
|
}
|
|
564
520
|
const builtInCandidates = [
|
|
565
|
-
|
|
566
|
-
|
|
521
|
+
join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory),
|
|
522
|
+
join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory)
|
|
567
523
|
];
|
|
568
524
|
for (const candidate of builtInCandidates) {
|
|
569
|
-
if (
|
|
525
|
+
if (existsSync(candidate)) {
|
|
570
526
|
return candidate;
|
|
571
527
|
}
|
|
572
528
|
}
|
|
573
|
-
return
|
|
529
|
+
return join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory);
|
|
574
530
|
}
|
|
575
531
|
function resolveUserPath(relativePath) {
|
|
576
532
|
const candidates = [
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
533
|
+
join(process.cwd(), relativePath),
|
|
534
|
+
join(process.cwd(), "lib", relativePath),
|
|
535
|
+
join(process.cwd(), "dist", relativePath),
|
|
536
|
+
join(FRAMEWORK_PACKAGE_ROOT, relativePath),
|
|
537
|
+
join(FRAMEWORK_PACKAGE_ROOT, "lib", relativePath),
|
|
538
|
+
join(FRAMEWORK_PACKAGE_ROOT, "dist", relativePath)
|
|
583
539
|
];
|
|
584
540
|
for (const candidate of candidates) {
|
|
585
|
-
const full =
|
|
586
|
-
if (
|
|
541
|
+
const full = resolve(candidate);
|
|
542
|
+
if (existsSync(full)) return full;
|
|
587
543
|
}
|
|
588
|
-
return
|
|
544
|
+
return join(process.cwd(), relativePath);
|
|
589
545
|
}
|
|
590
546
|
async function exists(path2) {
|
|
591
547
|
try {
|
|
592
|
-
await
|
|
548
|
+
await fs.access(path2);
|
|
593
549
|
return true;
|
|
594
550
|
} catch {
|
|
595
551
|
return false;
|
|
@@ -609,10 +565,10 @@ function hasPermission(client, options) {
|
|
|
609
565
|
}
|
|
610
566
|
|
|
611
567
|
// src/core/registry/command.registry.ts
|
|
612
|
-
|
|
568
|
+
import { Collection, SlashCommandSubcommandBuilder } from "discord.js";
|
|
613
569
|
|
|
614
570
|
// src/shared/typings/registry.ts
|
|
615
|
-
|
|
571
|
+
import { pathToFileURL } from "url";
|
|
616
572
|
var BaseRegistry = class {
|
|
617
573
|
/**
|
|
618
574
|
* Get all of loaded T
|
|
@@ -633,7 +589,7 @@ var BaseRegistry = class {
|
|
|
633
589
|
*/
|
|
634
590
|
async importFile(filePath) {
|
|
635
591
|
try {
|
|
636
|
-
const { default: file } = await import(
|
|
592
|
+
const { default: file } = await import(pathToFileURL(filePath).href);
|
|
637
593
|
const imports = file.default ?? file;
|
|
638
594
|
if (!imports) return null;
|
|
639
595
|
if (typeof imports === "function" && imports.prototype) {
|
|
@@ -662,8 +618,8 @@ var BaseRegistry = class {
|
|
|
662
618
|
async clearCache(filePath) {
|
|
663
619
|
if (process.env.NODE_ENV === "production") return;
|
|
664
620
|
try {
|
|
665
|
-
const resvoled =
|
|
666
|
-
delete
|
|
621
|
+
const resvoled = __require.resolve(filePath);
|
|
622
|
+
delete __require.cache[resvoled];
|
|
667
623
|
} catch {
|
|
668
624
|
}
|
|
669
625
|
}
|
|
@@ -687,10 +643,10 @@ var deconstructCustomId = (customId) => {
|
|
|
687
643
|
};
|
|
688
644
|
|
|
689
645
|
// src/core/registry/command.registry.ts
|
|
690
|
-
|
|
691
|
-
|
|
646
|
+
import { promises as fs2 } from "fs";
|
|
647
|
+
import { join as join2 } from "path";
|
|
692
648
|
var CommandRegistry = class extends BaseRegistry {
|
|
693
|
-
items = new
|
|
649
|
+
items = new Collection();
|
|
694
650
|
/**
|
|
695
651
|
* Load all commands and their subcommands
|
|
696
652
|
*
|
|
@@ -702,12 +658,12 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
702
658
|
if (!await exists(directory)) {
|
|
703
659
|
return this;
|
|
704
660
|
}
|
|
705
|
-
const entries = await
|
|
661
|
+
const entries = await fs2.readdir(directory, { withFileTypes: true });
|
|
706
662
|
for (const entry of entries) {
|
|
707
|
-
const fullPath = (
|
|
663
|
+
const fullPath = join2(directory, entry.name);
|
|
708
664
|
if (!entry.isDirectory()) continue;
|
|
709
|
-
const indexFile = (
|
|
710
|
-
const indexJs = (
|
|
665
|
+
const indexFile = join2(fullPath, "index.ts");
|
|
666
|
+
const indexJs = join2(fullPath, "index.js");
|
|
711
667
|
let commandFile = "";
|
|
712
668
|
if (await exists(indexFile)) commandFile = indexFile;
|
|
713
669
|
else if (await exists(indexJs)) commandFile = indexJs;
|
|
@@ -716,13 +672,13 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
716
672
|
if (!command) continue;
|
|
717
673
|
if (!command.metadata.active) continue;
|
|
718
674
|
if (command.isSlashCommand()) {
|
|
719
|
-
const subcommandFiles = (await
|
|
675
|
+
const subcommandFiles = (await fs2.readdir(fullPath)).filter(
|
|
720
676
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
721
677
|
);
|
|
722
678
|
for (const file of subcommandFiles) {
|
|
723
|
-
const subcommand = await this.importFile((
|
|
679
|
+
const subcommand = await this.importFile(join2(fullPath, file));
|
|
724
680
|
if (!subcommand) continue;
|
|
725
|
-
if (!subcommand.data.name || !(subcommand.data instanceof
|
|
681
|
+
if (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))
|
|
726
682
|
continue;
|
|
727
683
|
command.data.addSubcommand(subcommand.data);
|
|
728
684
|
command.metadata.subcommands.set(subcommand.data.name, subcommand);
|
|
@@ -735,11 +691,11 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
735
691
|
};
|
|
736
692
|
|
|
737
693
|
// src/core/registry/component.registry.ts
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
694
|
+
import { Collection as Collection2 } from "discord.js";
|
|
695
|
+
import { promises as fs3 } from "fs";
|
|
696
|
+
import { join as join3 } from "path";
|
|
741
697
|
var ComponentRegistry = class extends BaseRegistry {
|
|
742
|
-
items = new
|
|
698
|
+
items = new Collection2();
|
|
743
699
|
/**
|
|
744
700
|
* Load all components.
|
|
745
701
|
*
|
|
@@ -751,15 +707,15 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
751
707
|
if (!await exists(directory)) {
|
|
752
708
|
return this;
|
|
753
709
|
}
|
|
754
|
-
const entries = await
|
|
710
|
+
const entries = await fs3.readdir(directory, { withFileTypes: true });
|
|
755
711
|
for (const entry of entries) {
|
|
756
|
-
const fullPath = (
|
|
712
|
+
const fullPath = join3(directory, entry.name);
|
|
757
713
|
if (!entry.isDirectory()) continue;
|
|
758
|
-
const componentFiles = (await
|
|
714
|
+
const componentFiles = (await fs3.readdir(fullPath)).filter(
|
|
759
715
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
760
716
|
);
|
|
761
717
|
for (const file of componentFiles) {
|
|
762
|
-
const component = await this.importFile((
|
|
718
|
+
const component = await this.importFile(join3(fullPath, file));
|
|
763
719
|
if (!component) continue;
|
|
764
720
|
const { data } = deconstructCustomId(component.metadata.customId);
|
|
765
721
|
this.items.set(data, component);
|
|
@@ -770,12 +726,12 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
770
726
|
};
|
|
771
727
|
|
|
772
728
|
// src/core/registry/event.registry.ts
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
729
|
+
import { Collection as Collection3 } from "discord.js";
|
|
730
|
+
import { promises as fs4 } from "fs";
|
|
731
|
+
import { join as join4 } from "path";
|
|
776
732
|
|
|
777
733
|
// src/core/events/interactionCreate.ts
|
|
778
|
-
|
|
734
|
+
import { ButtonInteraction, ModalSubmitInteraction } from "discord.js";
|
|
779
735
|
var interactionCreate_default = {
|
|
780
736
|
name: "interactionCreate",
|
|
781
737
|
execute: async (client, interaction) => {
|
|
@@ -805,9 +761,9 @@ var interactionCreate_default = {
|
|
|
805
761
|
}
|
|
806
762
|
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
807
763
|
const { componentType, tags, data } = deconstructCustomId(interaction.customId);
|
|
808
|
-
if (componentType === "button" /* Button */ && !(interaction instanceof
|
|
764
|
+
if (componentType === "button" /* Button */ && !(interaction instanceof ButtonInteraction))
|
|
809
765
|
return;
|
|
810
|
-
if (componentType === "modal" /* Modal */ && !(interaction instanceof
|
|
766
|
+
if (componentType === "modal" /* Modal */ && !(interaction instanceof ModalSubmitInteraction))
|
|
811
767
|
return;
|
|
812
768
|
if (tags.includes("awaited")) return;
|
|
813
769
|
const registeredComponents = client.registries.components.get();
|
|
@@ -834,7 +790,7 @@ var interactionCreate_default = {
|
|
|
834
790
|
|
|
835
791
|
// src/core/registry/event.registry.ts
|
|
836
792
|
var EventRegistry = class extends BaseRegistry {
|
|
837
|
-
items = new
|
|
793
|
+
items = new Collection3();
|
|
838
794
|
/**
|
|
839
795
|
* Load all events.
|
|
840
796
|
*
|
|
@@ -844,9 +800,9 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
844
800
|
*/
|
|
845
801
|
async load(directory = getCorePath({ coreDirectory: "events" })) {
|
|
846
802
|
if (!await exists(directory)) return this;
|
|
847
|
-
const entries = await
|
|
803
|
+
const entries = await fs4.readdir(directory, { withFileTypes: true });
|
|
848
804
|
for (const entry of entries) {
|
|
849
|
-
const fullPath = (
|
|
805
|
+
const fullPath = join4(directory, entry.name);
|
|
850
806
|
if (entry.isDirectory()) {
|
|
851
807
|
await this.load(fullPath);
|
|
852
808
|
continue;
|
|
@@ -876,11 +832,11 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
876
832
|
};
|
|
877
833
|
|
|
878
834
|
// src/core/registry/module.registry.ts
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
835
|
+
import { Collection as Collection4 } from "discord.js";
|
|
836
|
+
import { promises as fs5 } from "fs";
|
|
837
|
+
import { join as join5 } from "path";
|
|
882
838
|
var ModuleRegistry = class extends BaseRegistry {
|
|
883
|
-
items = new
|
|
839
|
+
items = new Collection4();
|
|
884
840
|
/**
|
|
885
841
|
* Load all modules.
|
|
886
842
|
*
|
|
@@ -892,15 +848,15 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
892
848
|
if (!await exists(directory)) {
|
|
893
849
|
return this;
|
|
894
850
|
}
|
|
895
|
-
const entries = await
|
|
851
|
+
const entries = await fs5.readdir(directory, { withFileTypes: true });
|
|
896
852
|
for (const entry of entries) {
|
|
897
|
-
const fullPath = (
|
|
853
|
+
const fullPath = join5(directory, entry.name);
|
|
898
854
|
if (!entry.isDirectory()) continue;
|
|
899
|
-
const moduleFiles = (await
|
|
855
|
+
const moduleFiles = (await fs5.readdir(fullPath)).filter(
|
|
900
856
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
901
857
|
);
|
|
902
858
|
for (const file of moduleFiles) {
|
|
903
|
-
const moduleEvent = await this.importFile((
|
|
859
|
+
const moduleEvent = await this.importFile(join5(fullPath, file));
|
|
904
860
|
if (!moduleEvent || !moduleEvent.events) continue;
|
|
905
861
|
this.items.set(moduleEvent.name, moduleEvent);
|
|
906
862
|
}
|
|
@@ -926,7 +882,7 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
926
882
|
};
|
|
927
883
|
|
|
928
884
|
// src/core/registry/index.ts
|
|
929
|
-
|
|
885
|
+
import path from "path";
|
|
930
886
|
var registries = () => ({
|
|
931
887
|
commands: new CommandRegistry(),
|
|
932
888
|
components: new ComponentRegistry(),
|
|
@@ -937,16 +893,16 @@ var registries = () => ({
|
|
|
937
893
|
const corePath = options.corePath;
|
|
938
894
|
await Promise.all([
|
|
939
895
|
this.commands.load(
|
|
940
|
-
corePath ? resolveUserPath(
|
|
896
|
+
corePath ? resolveUserPath(path.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
|
|
941
897
|
),
|
|
942
898
|
this.components.load(
|
|
943
|
-
corePath ? resolveUserPath(
|
|
899
|
+
corePath ? resolveUserPath(path.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
|
|
944
900
|
),
|
|
945
901
|
this.events.load(
|
|
946
|
-
corePath ? resolveUserPath(
|
|
902
|
+
corePath ? resolveUserPath(path.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
|
|
947
903
|
),
|
|
948
904
|
this.modules.load(
|
|
949
|
-
corePath ? resolveUserPath(
|
|
905
|
+
corePath ? resolveUserPath(path.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
|
|
950
906
|
)
|
|
951
907
|
]);
|
|
952
908
|
},
|
|
@@ -957,7 +913,7 @@ var registries = () => ({
|
|
|
957
913
|
});
|
|
958
914
|
|
|
959
915
|
// src/core/client/trivious.client.ts
|
|
960
|
-
var TriviousClient = class extends
|
|
916
|
+
var TriviousClient = class extends Client {
|
|
961
917
|
/**
|
|
962
918
|
* Client registries.
|
|
963
919
|
*
|
|
@@ -1022,8 +978,8 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1022
978
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
1023
979
|
const slashCommands = Array.from(this.registries.commands.get().values());
|
|
1024
980
|
const body = [...slashCommands.map((command) => command.toJSON())];
|
|
1025
|
-
const rest = new
|
|
1026
|
-
await rest.put(
|
|
981
|
+
const rest = new REST({ version: "10" }).setToken(token);
|
|
982
|
+
await rest.put(Routes.applicationCommands(clientId), { body });
|
|
1027
983
|
console.log(`[Trivious] Deployed ${body.length} commands`);
|
|
1028
984
|
}
|
|
1029
985
|
/**
|
|
@@ -1040,10 +996,15 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1040
996
|
};
|
|
1041
997
|
|
|
1042
998
|
// src/core/commands/command.base.ts
|
|
1043
|
-
|
|
999
|
+
import {
|
|
1000
|
+
Collection as Collection5,
|
|
1001
|
+
ContextMenuCommandBuilder as ContextMenuCommandBuilder2,
|
|
1002
|
+
InteractionContextType,
|
|
1003
|
+
SlashCommandBuilder
|
|
1004
|
+
} from "discord.js";
|
|
1044
1005
|
|
|
1045
1006
|
// src/core/commands/contextcommand.base.ts
|
|
1046
|
-
|
|
1007
|
+
import { ContextMenuCommandBuilder } from "discord.js";
|
|
1047
1008
|
var ContextMenuCommand = class extends Command {
|
|
1048
1009
|
/**
|
|
1049
1010
|
* Base command handler.
|
|
@@ -1065,7 +1026,7 @@ var ContextMenuCommand = class extends Command {
|
|
|
1065
1026
|
if (memberHasPermission) await run(client, interaction);
|
|
1066
1027
|
}
|
|
1067
1028
|
};
|
|
1068
|
-
var ContextMenuBuilder = class extends
|
|
1029
|
+
var ContextMenuBuilder = class extends ContextMenuCommandBuilder {
|
|
1069
1030
|
_active = true;
|
|
1070
1031
|
_ownerOnly = false;
|
|
1071
1032
|
_permission = 0 /* USER */;
|
|
@@ -1141,7 +1102,7 @@ var Command = class {
|
|
|
1141
1102
|
* @returns {this is SlashCommand}
|
|
1142
1103
|
*/
|
|
1143
1104
|
isSlashCommand() {
|
|
1144
|
-
return this.data instanceof
|
|
1105
|
+
return this.data instanceof SlashCommandBuilder && this instanceof SlashCommand;
|
|
1145
1106
|
}
|
|
1146
1107
|
/**
|
|
1147
1108
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -1151,7 +1112,7 @@ var Command = class {
|
|
|
1151
1112
|
* @returns {this is ContextMenuCommand}
|
|
1152
1113
|
*/
|
|
1153
1114
|
isContextMenuCommand() {
|
|
1154
|
-
return this.data instanceof
|
|
1115
|
+
return this.data instanceof ContextMenuCommandBuilder2 && this instanceof ContextMenuCommand;
|
|
1155
1116
|
}
|
|
1156
1117
|
/**
|
|
1157
1118
|
* Returns JSON of the command builder.
|
|
@@ -1246,12 +1207,12 @@ var SlashCommand = class extends Command {
|
|
|
1246
1207
|
await subcommand.execute(client, interaction);
|
|
1247
1208
|
}
|
|
1248
1209
|
};
|
|
1249
|
-
var CommandBuilder = class extends
|
|
1210
|
+
var CommandBuilder = class extends SlashCommandBuilder {
|
|
1250
1211
|
_active = true;
|
|
1251
1212
|
_guildOnly = false;
|
|
1252
1213
|
_ownerOnly = false;
|
|
1253
1214
|
_permission = 0 /* USER */;
|
|
1254
|
-
_subcommands = new
|
|
1215
|
+
_subcommands = new Collection5();
|
|
1255
1216
|
_ephemeralReply = false;
|
|
1256
1217
|
/**
|
|
1257
1218
|
* Set the command as disabled.
|
|
@@ -1272,7 +1233,7 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1272
1233
|
setGuildOnly() {
|
|
1273
1234
|
this._guildOnly = true;
|
|
1274
1235
|
this._permission = 0 /* USER */;
|
|
1275
|
-
this.setContexts(
|
|
1236
|
+
this.setContexts(InteractionContextType.Guild);
|
|
1276
1237
|
return this;
|
|
1277
1238
|
}
|
|
1278
1239
|
/**
|
|
@@ -1329,8 +1290,10 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1329
1290
|
};
|
|
1330
1291
|
|
|
1331
1292
|
// src/core/commands/subcommand.base.ts
|
|
1332
|
-
|
|
1333
|
-
|
|
1293
|
+
import {
|
|
1294
|
+
SlashCommandSubcommandBuilder as SlashCommandSubcommandBuilder2
|
|
1295
|
+
} from "discord.js";
|
|
1296
|
+
var SubcommandBuilder = class extends SlashCommandSubcommandBuilder2 {
|
|
1334
1297
|
_active = true;
|
|
1335
1298
|
_ownerOnly = false;
|
|
1336
1299
|
_permission = 0 /* USER */;
|
|
@@ -1517,12 +1480,11 @@ var Component = class {
|
|
|
1517
1480
|
};
|
|
1518
1481
|
|
|
1519
1482
|
// src/index.ts
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
0 && (module.exports = {
|
|
1483
|
+
import { Collection as Collection6, ClientEvents as ClientEvents2 } from "discord.js";
|
|
1484
|
+
export {
|
|
1523
1485
|
BaseRegistry,
|
|
1524
|
-
ClientEvents,
|
|
1525
|
-
Collection,
|
|
1486
|
+
ClientEvents2 as ClientEvents,
|
|
1487
|
+
Collection6 as Collection,
|
|
1526
1488
|
Command,
|
|
1527
1489
|
CommandBuilder,
|
|
1528
1490
|
CommandRegistry,
|
|
@@ -1539,5 +1501,5 @@ var import_discord10 = require("discord.js");
|
|
|
1539
1501
|
TriviousClient,
|
|
1540
1502
|
deconstructCustomId,
|
|
1541
1503
|
getPermissionLevel
|
|
1542
|
-
}
|
|
1504
|
+
};
|
|
1543
1505
|
//# sourceMappingURL=index.js.map
|