trivious 1.3.12 → 1.3.13
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} +163 -122
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +121 -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,16 @@ 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
|
-
|
|
476
|
+
import { promises as fs, existsSync } from "fs";
|
|
477
|
+
import { join, resolve } from "path";
|
|
478
|
+
import { fileURLToPath } from "url";
|
|
479
|
+
import { dirname } from "path";
|
|
526
480
|
|
|
527
481
|
// src/shared/typings/permissions.ts
|
|
528
482
|
var PermissionLevel = /* @__PURE__ */ ((PermissionLevel2) => {
|
|
@@ -542,16 +496,15 @@ var getPermissionLevel = (client, member) => {
|
|
|
542
496
|
};
|
|
543
497
|
|
|
544
498
|
// src/shared/utility/functions.ts
|
|
545
|
-
var
|
|
546
|
-
var
|
|
547
|
-
var __dirname = (0, import_path.dirname)(__filename);
|
|
499
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
500
|
+
var __dirname = dirname(__filename);
|
|
548
501
|
var getPackageRoot = () => {
|
|
549
502
|
let dir = __dirname;
|
|
550
|
-
while (dir !==
|
|
551
|
-
if (
|
|
503
|
+
while (dir !== dirname(dir)) {
|
|
504
|
+
if (existsSync(join(dir, "package.json")) || existsSync(join(dir, "node_modules"))) {
|
|
552
505
|
return dir;
|
|
553
506
|
}
|
|
554
|
-
dir =
|
|
507
|
+
dir = dirname(dir);
|
|
555
508
|
}
|
|
556
509
|
return __dirname;
|
|
557
510
|
};
|
|
@@ -562,34 +515,34 @@ function getCorePath(options) {
|
|
|
562
515
|
return resolveUserPath(userPath);
|
|
563
516
|
}
|
|
564
517
|
const builtInCandidates = [
|
|
565
|
-
|
|
566
|
-
|
|
518
|
+
join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory),
|
|
519
|
+
join(FRAMEWORK_PACKAGE_ROOT, "dist", coreDirectory)
|
|
567
520
|
];
|
|
568
521
|
for (const candidate of builtInCandidates) {
|
|
569
|
-
if (
|
|
522
|
+
if (existsSync(candidate)) {
|
|
570
523
|
return candidate;
|
|
571
524
|
}
|
|
572
525
|
}
|
|
573
|
-
return
|
|
526
|
+
return join(FRAMEWORK_PACKAGE_ROOT, "lib", coreDirectory);
|
|
574
527
|
}
|
|
575
528
|
function resolveUserPath(relativePath) {
|
|
576
529
|
const candidates = [
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
530
|
+
join(process.cwd(), relativePath),
|
|
531
|
+
join(process.cwd(), "lib", relativePath),
|
|
532
|
+
join(process.cwd(), "dist", relativePath),
|
|
533
|
+
join(FRAMEWORK_PACKAGE_ROOT, relativePath),
|
|
534
|
+
join(FRAMEWORK_PACKAGE_ROOT, "lib", relativePath),
|
|
535
|
+
join(FRAMEWORK_PACKAGE_ROOT, "dist", relativePath)
|
|
583
536
|
];
|
|
584
537
|
for (const candidate of candidates) {
|
|
585
|
-
const full =
|
|
586
|
-
if (
|
|
538
|
+
const full = resolve(candidate);
|
|
539
|
+
if (existsSync(full)) return full;
|
|
587
540
|
}
|
|
588
|
-
return
|
|
541
|
+
return join(process.cwd(), relativePath);
|
|
589
542
|
}
|
|
590
543
|
async function exists(path2) {
|
|
591
544
|
try {
|
|
592
|
-
await
|
|
545
|
+
await fs.access(path2);
|
|
593
546
|
return true;
|
|
594
547
|
} catch {
|
|
595
548
|
return false;
|
|
@@ -609,10 +562,10 @@ function hasPermission(client, options) {
|
|
|
609
562
|
}
|
|
610
563
|
|
|
611
564
|
// src/core/registry/command.registry.ts
|
|
612
|
-
|
|
565
|
+
import { Collection, SlashCommandSubcommandBuilder } from "discord.js";
|
|
613
566
|
|
|
614
567
|
// src/shared/typings/registry.ts
|
|
615
|
-
|
|
568
|
+
import { pathToFileURL } from "url";
|
|
616
569
|
var BaseRegistry = class {
|
|
617
570
|
/**
|
|
618
571
|
* Get all of loaded T
|
|
@@ -633,7 +586,7 @@ var BaseRegistry = class {
|
|
|
633
586
|
*/
|
|
634
587
|
async importFile(filePath) {
|
|
635
588
|
try {
|
|
636
|
-
const { default: file } = await import(
|
|
589
|
+
const { default: file } = await import(pathToFileURL(filePath).href);
|
|
637
590
|
const imports = file.default ?? file;
|
|
638
591
|
if (!imports) return null;
|
|
639
592
|
if (typeof imports === "function" && imports.prototype) {
|
|
@@ -662,8 +615,8 @@ var BaseRegistry = class {
|
|
|
662
615
|
async clearCache(filePath) {
|
|
663
616
|
if (process.env.NODE_ENV === "production") return;
|
|
664
617
|
try {
|
|
665
|
-
const resvoled =
|
|
666
|
-
delete
|
|
618
|
+
const resvoled = __require.resolve(filePath);
|
|
619
|
+
delete __require.cache[resvoled];
|
|
667
620
|
} catch {
|
|
668
621
|
}
|
|
669
622
|
}
|
|
@@ -687,10 +640,10 @@ var deconstructCustomId = (customId) => {
|
|
|
687
640
|
};
|
|
688
641
|
|
|
689
642
|
// src/core/registry/command.registry.ts
|
|
690
|
-
|
|
691
|
-
|
|
643
|
+
import { promises as fs2 } from "fs";
|
|
644
|
+
import { join as join2 } from "path";
|
|
692
645
|
var CommandRegistry = class extends BaseRegistry {
|
|
693
|
-
items = new
|
|
646
|
+
items = new Collection();
|
|
694
647
|
/**
|
|
695
648
|
* Load all commands and their subcommands
|
|
696
649
|
*
|
|
@@ -702,12 +655,12 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
702
655
|
if (!await exists(directory)) {
|
|
703
656
|
return this;
|
|
704
657
|
}
|
|
705
|
-
const entries = await
|
|
658
|
+
const entries = await fs2.readdir(directory, { withFileTypes: true });
|
|
706
659
|
for (const entry of entries) {
|
|
707
|
-
const fullPath = (
|
|
660
|
+
const fullPath = join2(directory, entry.name);
|
|
708
661
|
if (!entry.isDirectory()) continue;
|
|
709
|
-
const indexFile = (
|
|
710
|
-
const indexJs = (
|
|
662
|
+
const indexFile = join2(fullPath, "index.ts");
|
|
663
|
+
const indexJs = join2(fullPath, "index.js");
|
|
711
664
|
let commandFile = "";
|
|
712
665
|
if (await exists(indexFile)) commandFile = indexFile;
|
|
713
666
|
else if (await exists(indexJs)) commandFile = indexJs;
|
|
@@ -716,13 +669,13 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
716
669
|
if (!command) continue;
|
|
717
670
|
if (!command.metadata.active) continue;
|
|
718
671
|
if (command.isSlashCommand()) {
|
|
719
|
-
const subcommandFiles = (await
|
|
672
|
+
const subcommandFiles = (await fs2.readdir(fullPath)).filter(
|
|
720
673
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
721
674
|
);
|
|
722
675
|
for (const file of subcommandFiles) {
|
|
723
|
-
const subcommand = await this.importFile((
|
|
676
|
+
const subcommand = await this.importFile(join2(fullPath, file));
|
|
724
677
|
if (!subcommand) continue;
|
|
725
|
-
if (!subcommand.data.name || !(subcommand.data instanceof
|
|
678
|
+
if (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))
|
|
726
679
|
continue;
|
|
727
680
|
command.data.addSubcommand(subcommand.data);
|
|
728
681
|
command.metadata.subcommands.set(subcommand.data.name, subcommand);
|
|
@@ -735,11 +688,11 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
735
688
|
};
|
|
736
689
|
|
|
737
690
|
// src/core/registry/component.registry.ts
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
691
|
+
import { Collection as Collection2 } from "discord.js";
|
|
692
|
+
import { promises as fs3 } from "fs";
|
|
693
|
+
import { join as join3 } from "path";
|
|
741
694
|
var ComponentRegistry = class extends BaseRegistry {
|
|
742
|
-
items = new
|
|
695
|
+
items = new Collection2();
|
|
743
696
|
/**
|
|
744
697
|
* Load all components.
|
|
745
698
|
*
|
|
@@ -751,15 +704,15 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
751
704
|
if (!await exists(directory)) {
|
|
752
705
|
return this;
|
|
753
706
|
}
|
|
754
|
-
const entries = await
|
|
707
|
+
const entries = await fs3.readdir(directory, { withFileTypes: true });
|
|
755
708
|
for (const entry of entries) {
|
|
756
|
-
const fullPath = (
|
|
709
|
+
const fullPath = join3(directory, entry.name);
|
|
757
710
|
if (!entry.isDirectory()) continue;
|
|
758
|
-
const componentFiles = (await
|
|
711
|
+
const componentFiles = (await fs3.readdir(fullPath)).filter(
|
|
759
712
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
760
713
|
);
|
|
761
714
|
for (const file of componentFiles) {
|
|
762
|
-
const component = await this.importFile((
|
|
715
|
+
const component = await this.importFile(join3(fullPath, file));
|
|
763
716
|
if (!component) continue;
|
|
764
717
|
const { data } = deconstructCustomId(component.metadata.customId);
|
|
765
718
|
this.items.set(data, component);
|
|
@@ -770,12 +723,12 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
770
723
|
};
|
|
771
724
|
|
|
772
725
|
// src/core/registry/event.registry.ts
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
726
|
+
import { Collection as Collection3 } from "discord.js";
|
|
727
|
+
import { promises as fs4 } from "fs";
|
|
728
|
+
import { join as join4 } from "path";
|
|
776
729
|
|
|
777
730
|
// src/core/events/interactionCreate.ts
|
|
778
|
-
|
|
731
|
+
import { ButtonInteraction, ModalSubmitInteraction } from "discord.js";
|
|
779
732
|
var interactionCreate_default = {
|
|
780
733
|
name: "interactionCreate",
|
|
781
734
|
execute: async (client, interaction) => {
|
|
@@ -805,9 +758,9 @@ var interactionCreate_default = {
|
|
|
805
758
|
}
|
|
806
759
|
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
807
760
|
const { componentType, tags, data } = deconstructCustomId(interaction.customId);
|
|
808
|
-
if (componentType === "button" /* Button */ && !(interaction instanceof
|
|
761
|
+
if (componentType === "button" /* Button */ && !(interaction instanceof ButtonInteraction))
|
|
809
762
|
return;
|
|
810
|
-
if (componentType === "modal" /* Modal */ && !(interaction instanceof
|
|
763
|
+
if (componentType === "modal" /* Modal */ && !(interaction instanceof ModalSubmitInteraction))
|
|
811
764
|
return;
|
|
812
765
|
if (tags.includes("awaited")) return;
|
|
813
766
|
const registeredComponents = client.registries.components.get();
|
|
@@ -834,7 +787,7 @@ var interactionCreate_default = {
|
|
|
834
787
|
|
|
835
788
|
// src/core/registry/event.registry.ts
|
|
836
789
|
var EventRegistry = class extends BaseRegistry {
|
|
837
|
-
items = new
|
|
790
|
+
items = new Collection3();
|
|
838
791
|
/**
|
|
839
792
|
* Load all events.
|
|
840
793
|
*
|
|
@@ -844,9 +797,9 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
844
797
|
*/
|
|
845
798
|
async load(directory = getCorePath({ coreDirectory: "events" })) {
|
|
846
799
|
if (!await exists(directory)) return this;
|
|
847
|
-
const entries = await
|
|
800
|
+
const entries = await fs4.readdir(directory, { withFileTypes: true });
|
|
848
801
|
for (const entry of entries) {
|
|
849
|
-
const fullPath = (
|
|
802
|
+
const fullPath = join4(directory, entry.name);
|
|
850
803
|
if (entry.isDirectory()) {
|
|
851
804
|
await this.load(fullPath);
|
|
852
805
|
continue;
|
|
@@ -876,11 +829,11 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
876
829
|
};
|
|
877
830
|
|
|
878
831
|
// src/core/registry/module.registry.ts
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
832
|
+
import { Collection as Collection4 } from "discord.js";
|
|
833
|
+
import { promises as fs5 } from "fs";
|
|
834
|
+
import { join as join5 } from "path";
|
|
882
835
|
var ModuleRegistry = class extends BaseRegistry {
|
|
883
|
-
items = new
|
|
836
|
+
items = new Collection4();
|
|
884
837
|
/**
|
|
885
838
|
* Load all modules.
|
|
886
839
|
*
|
|
@@ -892,15 +845,15 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
892
845
|
if (!await exists(directory)) {
|
|
893
846
|
return this;
|
|
894
847
|
}
|
|
895
|
-
const entries = await
|
|
848
|
+
const entries = await fs5.readdir(directory, { withFileTypes: true });
|
|
896
849
|
for (const entry of entries) {
|
|
897
|
-
const fullPath = (
|
|
850
|
+
const fullPath = join5(directory, entry.name);
|
|
898
851
|
if (!entry.isDirectory()) continue;
|
|
899
|
-
const moduleFiles = (await
|
|
852
|
+
const moduleFiles = (await fs5.readdir(fullPath)).filter(
|
|
900
853
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
901
854
|
);
|
|
902
855
|
for (const file of moduleFiles) {
|
|
903
|
-
const moduleEvent = await this.importFile((
|
|
856
|
+
const moduleEvent = await this.importFile(join5(fullPath, file));
|
|
904
857
|
if (!moduleEvent || !moduleEvent.events) continue;
|
|
905
858
|
this.items.set(moduleEvent.name, moduleEvent);
|
|
906
859
|
}
|
|
@@ -926,7 +879,7 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
926
879
|
};
|
|
927
880
|
|
|
928
881
|
// src/core/registry/index.ts
|
|
929
|
-
|
|
882
|
+
import path from "path";
|
|
930
883
|
var registries = () => ({
|
|
931
884
|
commands: new CommandRegistry(),
|
|
932
885
|
components: new ComponentRegistry(),
|
|
@@ -937,16 +890,16 @@ var registries = () => ({
|
|
|
937
890
|
const corePath = options.corePath;
|
|
938
891
|
await Promise.all([
|
|
939
892
|
this.commands.load(
|
|
940
|
-
corePath ? resolveUserPath(
|
|
893
|
+
corePath ? resolveUserPath(path.join(corePath, "commands")) : corePaths?.commandsPath ? resolveUserPath(corePaths.commandsPath) : void 0
|
|
941
894
|
),
|
|
942
895
|
this.components.load(
|
|
943
|
-
corePath ? resolveUserPath(
|
|
896
|
+
corePath ? resolveUserPath(path.join(corePath, "components")) : corePaths?.componentsPath ? resolveUserPath(corePaths.componentsPath) : void 0
|
|
944
897
|
),
|
|
945
898
|
this.events.load(
|
|
946
|
-
corePath ? resolveUserPath(
|
|
899
|
+
corePath ? resolveUserPath(path.join(corePath, "events")) : corePaths?.eventsPath ? resolveUserPath(corePaths.eventsPath) : void 0
|
|
947
900
|
),
|
|
948
901
|
this.modules.load(
|
|
949
|
-
corePath ? resolveUserPath(
|
|
902
|
+
corePath ? resolveUserPath(path.join(corePath, "modules")) : corePaths?.modulesPath ? resolveUserPath(corePaths.modulesPath) : void 0
|
|
950
903
|
)
|
|
951
904
|
]);
|
|
952
905
|
},
|
|
@@ -957,7 +910,7 @@ var registries = () => ({
|
|
|
957
910
|
});
|
|
958
911
|
|
|
959
912
|
// src/core/client/trivious.client.ts
|
|
960
|
-
var TriviousClient = class extends
|
|
913
|
+
var TriviousClient = class extends Client {
|
|
961
914
|
/**
|
|
962
915
|
* Client registries.
|
|
963
916
|
*
|
|
@@ -1022,8 +975,8 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1022
975
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
1023
976
|
const slashCommands = Array.from(this.registries.commands.get().values());
|
|
1024
977
|
const body = [...slashCommands.map((command) => command.toJSON())];
|
|
1025
|
-
const rest = new
|
|
1026
|
-
await rest.put(
|
|
978
|
+
const rest = new REST({ version: "10" }).setToken(token);
|
|
979
|
+
await rest.put(Routes.applicationCommands(clientId), { body });
|
|
1027
980
|
console.log(`[Trivious] Deployed ${body.length} commands`);
|
|
1028
981
|
}
|
|
1029
982
|
/**
|
|
@@ -1040,10 +993,15 @@ var TriviousClient = class extends import_discord6.Client {
|
|
|
1040
993
|
};
|
|
1041
994
|
|
|
1042
995
|
// src/core/commands/command.base.ts
|
|
1043
|
-
|
|
996
|
+
import {
|
|
997
|
+
Collection as Collection5,
|
|
998
|
+
ContextMenuCommandBuilder as ContextMenuCommandBuilder2,
|
|
999
|
+
InteractionContextType,
|
|
1000
|
+
SlashCommandBuilder
|
|
1001
|
+
} from "discord.js";
|
|
1044
1002
|
|
|
1045
1003
|
// src/core/commands/contextcommand.base.ts
|
|
1046
|
-
|
|
1004
|
+
import { ContextMenuCommandBuilder } from "discord.js";
|
|
1047
1005
|
var ContextMenuCommand = class extends Command {
|
|
1048
1006
|
/**
|
|
1049
1007
|
* Base command handler.
|
|
@@ -1065,7 +1023,7 @@ var ContextMenuCommand = class extends Command {
|
|
|
1065
1023
|
if (memberHasPermission) await run(client, interaction);
|
|
1066
1024
|
}
|
|
1067
1025
|
};
|
|
1068
|
-
var ContextMenuBuilder = class extends
|
|
1026
|
+
var ContextMenuBuilder = class extends ContextMenuCommandBuilder {
|
|
1069
1027
|
_active = true;
|
|
1070
1028
|
_ownerOnly = false;
|
|
1071
1029
|
_permission = 0 /* USER */;
|
|
@@ -1141,7 +1099,7 @@ var Command = class {
|
|
|
1141
1099
|
* @returns {this is SlashCommand}
|
|
1142
1100
|
*/
|
|
1143
1101
|
isSlashCommand() {
|
|
1144
|
-
return this.data instanceof
|
|
1102
|
+
return this.data instanceof SlashCommandBuilder && this instanceof SlashCommand;
|
|
1145
1103
|
}
|
|
1146
1104
|
/**
|
|
1147
1105
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -1151,7 +1109,7 @@ var Command = class {
|
|
|
1151
1109
|
* @returns {this is ContextMenuCommand}
|
|
1152
1110
|
*/
|
|
1153
1111
|
isContextMenuCommand() {
|
|
1154
|
-
return this.data instanceof
|
|
1112
|
+
return this.data instanceof ContextMenuCommandBuilder2 && this instanceof ContextMenuCommand;
|
|
1155
1113
|
}
|
|
1156
1114
|
/**
|
|
1157
1115
|
* Returns JSON of the command builder.
|
|
@@ -1246,12 +1204,12 @@ var SlashCommand = class extends Command {
|
|
|
1246
1204
|
await subcommand.execute(client, interaction);
|
|
1247
1205
|
}
|
|
1248
1206
|
};
|
|
1249
|
-
var CommandBuilder = class extends
|
|
1207
|
+
var CommandBuilder = class extends SlashCommandBuilder {
|
|
1250
1208
|
_active = true;
|
|
1251
1209
|
_guildOnly = false;
|
|
1252
1210
|
_ownerOnly = false;
|
|
1253
1211
|
_permission = 0 /* USER */;
|
|
1254
|
-
_subcommands = new
|
|
1212
|
+
_subcommands = new Collection5();
|
|
1255
1213
|
_ephemeralReply = false;
|
|
1256
1214
|
/**
|
|
1257
1215
|
* Set the command as disabled.
|
|
@@ -1272,7 +1230,7 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1272
1230
|
setGuildOnly() {
|
|
1273
1231
|
this._guildOnly = true;
|
|
1274
1232
|
this._permission = 0 /* USER */;
|
|
1275
|
-
this.setContexts(
|
|
1233
|
+
this.setContexts(InteractionContextType.Guild);
|
|
1276
1234
|
return this;
|
|
1277
1235
|
}
|
|
1278
1236
|
/**
|
|
@@ -1329,8 +1287,10 @@ var CommandBuilder = class extends import_discord8.SlashCommandBuilder {
|
|
|
1329
1287
|
};
|
|
1330
1288
|
|
|
1331
1289
|
// src/core/commands/subcommand.base.ts
|
|
1332
|
-
|
|
1333
|
-
|
|
1290
|
+
import {
|
|
1291
|
+
SlashCommandSubcommandBuilder as SlashCommandSubcommandBuilder2
|
|
1292
|
+
} from "discord.js";
|
|
1293
|
+
var SubcommandBuilder = class extends SlashCommandSubcommandBuilder2 {
|
|
1334
1294
|
_active = true;
|
|
1335
1295
|
_ownerOnly = false;
|
|
1336
1296
|
_permission = 0 /* USER */;
|
|
@@ -1517,12 +1477,11 @@ var Component = class {
|
|
|
1517
1477
|
};
|
|
1518
1478
|
|
|
1519
1479
|
// src/index.ts
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
0 && (module.exports = {
|
|
1480
|
+
import { Collection as Collection6, ClientEvents as ClientEvents2 } from "discord.js";
|
|
1481
|
+
export {
|
|
1523
1482
|
BaseRegistry,
|
|
1524
|
-
ClientEvents,
|
|
1525
|
-
Collection,
|
|
1483
|
+
ClientEvents2 as ClientEvents,
|
|
1484
|
+
Collection6 as Collection,
|
|
1526
1485
|
Command,
|
|
1527
1486
|
CommandBuilder,
|
|
1528
1487
|
CommandRegistry,
|
|
@@ -1539,5 +1498,5 @@ var import_discord10 = require("discord.js");
|
|
|
1539
1498
|
TriviousClient,
|
|
1540
1499
|
deconstructCustomId,
|
|
1541
1500
|
getPermissionLevel
|
|
1542
|
-
}
|
|
1501
|
+
};
|
|
1543
1502
|
//# sourceMappingURL=index.js.map
|