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.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import 'util';
|
|
2
|
+
import { Collection, SlashCommandSubcommandBuilder, Client, REST, Routes, SlashCommandBuilder, ContextMenuCommandBuilder, InteractionContextType, ButtonInteraction, ModalSubmitInteraction } from 'discord.js';
|
|
3
|
+
export { ClientEvents, Collection } from 'discord.js';
|
|
4
|
+
import { existsSync, promises } from 'fs';
|
|
5
|
+
import path, { dirname, join, resolve } from 'path';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
7
|
+
|
|
1
8
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
9
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
10
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -11,7 +18,7 @@ var __commonJS = (cb, mod) => function __require2() {
|
|
|
11
18
|
|
|
12
19
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
|
|
13
20
|
var require_package = __commonJS({
|
|
14
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(exports, module) {
|
|
21
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json"(exports$1, module) {
|
|
15
22
|
module.exports = {
|
|
16
23
|
name: "dotenv",
|
|
17
24
|
version: "17.2.3",
|
|
@@ -79,8 +86,7 @@ var require_package = __commonJS({
|
|
|
79
86
|
|
|
80
87
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
|
|
81
88
|
var require_main = __commonJS({
|
|
82
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
83
|
-
"use strict";
|
|
89
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(exports$1, module) {
|
|
84
90
|
var fs6 = __require("fs");
|
|
85
91
|
var path2 = __require("path");
|
|
86
92
|
var os = __require("os");
|
|
@@ -409,8 +415,7 @@ var require_main = __commonJS({
|
|
|
409
415
|
|
|
410
416
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js
|
|
411
417
|
var require_env_options = __commonJS({
|
|
412
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js"(exports, module) {
|
|
413
|
-
"use strict";
|
|
418
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/env-options.js"(exports$1, module) {
|
|
414
419
|
var options = {};
|
|
415
420
|
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
416
421
|
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
@@ -436,8 +441,7 @@ var require_env_options = __commonJS({
|
|
|
436
441
|
|
|
437
442
|
// node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js
|
|
438
443
|
var require_cli_options = __commonJS({
|
|
439
|
-
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js"(exports, module) {
|
|
440
|
-
"use strict";
|
|
444
|
+
"node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/cli-options.js"(exports$1, module) {
|
|
441
445
|
var re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
442
446
|
module.exports = function optionMatcher(args) {
|
|
443
447
|
const options = args.reduce(function(acc, cur) {
|
|
@@ -466,18 +470,6 @@ var require_cli_options = __commonJS({
|
|
|
466
470
|
);
|
|
467
471
|
})();
|
|
468
472
|
|
|
469
|
-
// src/index.ts
|
|
470
|
-
import "util";
|
|
471
|
-
|
|
472
|
-
// src/core/client/trivious.client.ts
|
|
473
|
-
import { Client, REST, Routes } from "discord.js";
|
|
474
|
-
|
|
475
|
-
// src/shared/utility/functions.ts
|
|
476
|
-
import { promises as fs, existsSync } from "fs";
|
|
477
|
-
import { join, resolve } from "path";
|
|
478
|
-
import { fileURLToPath } from "url";
|
|
479
|
-
import { dirname } from "path";
|
|
480
|
-
|
|
481
473
|
// src/shared/typings/permissions.ts
|
|
482
474
|
var PermissionLevel = /* @__PURE__ */ ((PermissionLevel2) => {
|
|
483
475
|
PermissionLevel2[PermissionLevel2["USER"] = 0] = "USER";
|
|
@@ -496,17 +488,17 @@ var getPermissionLevel = (client, member) => {
|
|
|
496
488
|
};
|
|
497
489
|
|
|
498
490
|
// src/shared/utility/functions.ts
|
|
499
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
500
|
-
var __dirname = dirname(__filename);
|
|
491
|
+
var __filename$1 = fileURLToPath(import.meta.url);
|
|
492
|
+
var __dirname$1 = dirname(__filename$1);
|
|
501
493
|
var getPackageRoot = () => {
|
|
502
|
-
let dir = __dirname;
|
|
494
|
+
let dir = __dirname$1;
|
|
503
495
|
while (dir !== dirname(dir)) {
|
|
504
496
|
if (existsSync(join(dir, "package.json")) || existsSync(join(dir, "node_modules"))) {
|
|
505
497
|
return dir;
|
|
506
498
|
}
|
|
507
499
|
dir = dirname(dir);
|
|
508
500
|
}
|
|
509
|
-
return __dirname;
|
|
501
|
+
return __dirname$1;
|
|
510
502
|
};
|
|
511
503
|
var FRAMEWORK_PACKAGE_ROOT = getPackageRoot();
|
|
512
504
|
function getCorePath(options) {
|
|
@@ -542,7 +534,7 @@ function resolveUserPath(relativePath) {
|
|
|
542
534
|
}
|
|
543
535
|
async function exists(path2) {
|
|
544
536
|
try {
|
|
545
|
-
await
|
|
537
|
+
await promises.access(path2);
|
|
546
538
|
return true;
|
|
547
539
|
} catch {
|
|
548
540
|
return false;
|
|
@@ -560,12 +552,6 @@ function hasPermission(client, options) {
|
|
|
560
552
|
}
|
|
561
553
|
return false;
|
|
562
554
|
}
|
|
563
|
-
|
|
564
|
-
// src/core/registry/command.registry.ts
|
|
565
|
-
import { Collection, SlashCommandSubcommandBuilder } from "discord.js";
|
|
566
|
-
|
|
567
|
-
// src/shared/typings/registry.ts
|
|
568
|
-
import { pathToFileURL } from "url";
|
|
569
555
|
var BaseRegistry = class {
|
|
570
556
|
/**
|
|
571
557
|
* Get all of loaded T
|
|
@@ -638,10 +624,6 @@ var deconstructCustomId = (customId) => {
|
|
|
638
624
|
tags
|
|
639
625
|
};
|
|
640
626
|
};
|
|
641
|
-
|
|
642
|
-
// src/core/registry/command.registry.ts
|
|
643
|
-
import { promises as fs2 } from "fs";
|
|
644
|
-
import { join as join2 } from "path";
|
|
645
627
|
var CommandRegistry = class extends BaseRegistry {
|
|
646
628
|
items = new Collection();
|
|
647
629
|
/**
|
|
@@ -655,12 +637,12 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
655
637
|
if (!await exists(directory)) {
|
|
656
638
|
return this;
|
|
657
639
|
}
|
|
658
|
-
const entries = await
|
|
640
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
659
641
|
for (const entry of entries) {
|
|
660
|
-
const fullPath =
|
|
642
|
+
const fullPath = join(directory, entry.name);
|
|
661
643
|
if (!entry.isDirectory()) continue;
|
|
662
|
-
const indexFile =
|
|
663
|
-
const indexJs =
|
|
644
|
+
const indexFile = join(fullPath, "index.ts");
|
|
645
|
+
const indexJs = join(fullPath, "index.js");
|
|
664
646
|
let commandFile = "";
|
|
665
647
|
if (await exists(indexFile)) commandFile = indexFile;
|
|
666
648
|
else if (await exists(indexJs)) commandFile = indexJs;
|
|
@@ -669,11 +651,11 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
669
651
|
if (!command) continue;
|
|
670
652
|
if (!command.metadata.active) continue;
|
|
671
653
|
if (command.isSlashCommand()) {
|
|
672
|
-
const subcommandFiles = (await
|
|
654
|
+
const subcommandFiles = (await promises.readdir(fullPath)).filter(
|
|
673
655
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
674
656
|
);
|
|
675
657
|
for (const file of subcommandFiles) {
|
|
676
|
-
const subcommand = await this.importFile(
|
|
658
|
+
const subcommand = await this.importFile(join(fullPath, file));
|
|
677
659
|
if (!subcommand) continue;
|
|
678
660
|
if (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))
|
|
679
661
|
continue;
|
|
@@ -686,13 +668,8 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
686
668
|
return this;
|
|
687
669
|
}
|
|
688
670
|
};
|
|
689
|
-
|
|
690
|
-
// src/core/registry/component.registry.ts
|
|
691
|
-
import { Collection as Collection2 } from "discord.js";
|
|
692
|
-
import { promises as fs3 } from "fs";
|
|
693
|
-
import { join as join3 } from "path";
|
|
694
671
|
var ComponentRegistry = class extends BaseRegistry {
|
|
695
|
-
items = new
|
|
672
|
+
items = new Collection();
|
|
696
673
|
/**
|
|
697
674
|
* Load all components.
|
|
698
675
|
*
|
|
@@ -704,15 +681,15 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
704
681
|
if (!await exists(directory)) {
|
|
705
682
|
return this;
|
|
706
683
|
}
|
|
707
|
-
const entries = await
|
|
684
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
708
685
|
for (const entry of entries) {
|
|
709
|
-
const fullPath =
|
|
686
|
+
const fullPath = join(directory, entry.name);
|
|
710
687
|
if (!entry.isDirectory()) continue;
|
|
711
|
-
const componentFiles = (await
|
|
688
|
+
const componentFiles = (await promises.readdir(fullPath)).filter(
|
|
712
689
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
713
690
|
);
|
|
714
691
|
for (const file of componentFiles) {
|
|
715
|
-
const component = await this.importFile(
|
|
692
|
+
const component = await this.importFile(join(fullPath, file));
|
|
716
693
|
if (!component) continue;
|
|
717
694
|
const { data } = deconstructCustomId(component.metadata.customId);
|
|
718
695
|
this.items.set(data, component);
|
|
@@ -721,14 +698,6 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
721
698
|
return this;
|
|
722
699
|
}
|
|
723
700
|
};
|
|
724
|
-
|
|
725
|
-
// src/core/registry/event.registry.ts
|
|
726
|
-
import { Collection as Collection3 } from "discord.js";
|
|
727
|
-
import { promises as fs4 } from "fs";
|
|
728
|
-
import { join as join4 } from "path";
|
|
729
|
-
|
|
730
|
-
// src/core/events/interactionCreate.ts
|
|
731
|
-
import { ButtonInteraction, ModalSubmitInteraction } from "discord.js";
|
|
732
701
|
var interactionCreate_default = {
|
|
733
702
|
name: "interactionCreate",
|
|
734
703
|
execute: async (client, interaction) => {
|
|
@@ -787,7 +756,7 @@ var interactionCreate_default = {
|
|
|
787
756
|
|
|
788
757
|
// src/core/registry/event.registry.ts
|
|
789
758
|
var EventRegistry = class extends BaseRegistry {
|
|
790
|
-
items = new
|
|
759
|
+
items = new Collection();
|
|
791
760
|
/**
|
|
792
761
|
* Load all events.
|
|
793
762
|
*
|
|
@@ -797,9 +766,9 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
797
766
|
*/
|
|
798
767
|
async load(directory = getCorePath({ coreDirectory: "events" })) {
|
|
799
768
|
if (!await exists(directory)) return this;
|
|
800
|
-
const entries = await
|
|
769
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
801
770
|
for (const entry of entries) {
|
|
802
|
-
const fullPath =
|
|
771
|
+
const fullPath = join(directory, entry.name);
|
|
803
772
|
if (entry.isDirectory()) {
|
|
804
773
|
await this.load(fullPath);
|
|
805
774
|
continue;
|
|
@@ -810,8 +779,7 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
810
779
|
this.items.set(event.name, event);
|
|
811
780
|
}
|
|
812
781
|
}
|
|
813
|
-
|
|
814
|
-
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
782
|
+
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
815
783
|
return this;
|
|
816
784
|
}
|
|
817
785
|
/**
|
|
@@ -827,13 +795,8 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
827
795
|
}
|
|
828
796
|
}
|
|
829
797
|
};
|
|
830
|
-
|
|
831
|
-
// src/core/registry/module.registry.ts
|
|
832
|
-
import { Collection as Collection4 } from "discord.js";
|
|
833
|
-
import { promises as fs5 } from "fs";
|
|
834
|
-
import { join as join5 } from "path";
|
|
835
798
|
var ModuleRegistry = class extends BaseRegistry {
|
|
836
|
-
items = new
|
|
799
|
+
items = new Collection();
|
|
837
800
|
/**
|
|
838
801
|
* Load all modules.
|
|
839
802
|
*
|
|
@@ -845,15 +808,15 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
845
808
|
if (!await exists(directory)) {
|
|
846
809
|
return this;
|
|
847
810
|
}
|
|
848
|
-
const entries = await
|
|
811
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
849
812
|
for (const entry of entries) {
|
|
850
|
-
const fullPath =
|
|
813
|
+
const fullPath = join(directory, entry.name);
|
|
851
814
|
if (!entry.isDirectory()) continue;
|
|
852
|
-
const moduleFiles = (await
|
|
815
|
+
const moduleFiles = (await promises.readdir(fullPath)).filter(
|
|
853
816
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
854
817
|
);
|
|
855
818
|
for (const file of moduleFiles) {
|
|
856
|
-
const moduleEvent = await this.importFile(
|
|
819
|
+
const moduleEvent = await this.importFile(join(fullPath, file));
|
|
857
820
|
if (!moduleEvent || !moduleEvent.events) continue;
|
|
858
821
|
this.items.set(moduleEvent.name, moduleEvent);
|
|
859
822
|
}
|
|
@@ -877,9 +840,6 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
877
840
|
}
|
|
878
841
|
}
|
|
879
842
|
};
|
|
880
|
-
|
|
881
|
-
// src/core/registry/index.ts
|
|
882
|
-
import path from "path";
|
|
883
843
|
var registries = () => ({
|
|
884
844
|
commands: new CommandRegistry(),
|
|
885
845
|
components: new ComponentRegistry(),
|
|
@@ -991,105 +951,6 @@ var TriviousClient = class extends Client {
|
|
|
991
951
|
return this._options.rolePermissions ?? {};
|
|
992
952
|
}
|
|
993
953
|
};
|
|
994
|
-
|
|
995
|
-
// src/core/commands/command.base.ts
|
|
996
|
-
import {
|
|
997
|
-
Collection as Collection5,
|
|
998
|
-
ContextMenuCommandBuilder as ContextMenuCommandBuilder2,
|
|
999
|
-
InteractionContextType,
|
|
1000
|
-
SlashCommandBuilder
|
|
1001
|
-
} from "discord.js";
|
|
1002
|
-
|
|
1003
|
-
// src/core/commands/contextcommand.base.ts
|
|
1004
|
-
import { ContextMenuCommandBuilder } from "discord.js";
|
|
1005
|
-
var ContextMenuCommand = class extends Command {
|
|
1006
|
-
/**
|
|
1007
|
-
* Base command handler.
|
|
1008
|
-
*
|
|
1009
|
-
* @public
|
|
1010
|
-
* @async
|
|
1011
|
-
* @param {TriviousClient} client
|
|
1012
|
-
* @param {ContextMenuCommandInteraction} interaction
|
|
1013
|
-
* @returns {*}
|
|
1014
|
-
*/
|
|
1015
|
-
async execute(client, interaction) {
|
|
1016
|
-
const { run, metadata } = this;
|
|
1017
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1018
|
-
client,
|
|
1019
|
-
interaction,
|
|
1020
|
-
metadata.permission,
|
|
1021
|
-
false
|
|
1022
|
-
);
|
|
1023
|
-
if (memberHasPermission) await run(client, interaction);
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
var ContextMenuBuilder = class extends ContextMenuCommandBuilder {
|
|
1027
|
-
_active = true;
|
|
1028
|
-
_ownerOnly = false;
|
|
1029
|
-
_permission = 0 /* USER */;
|
|
1030
|
-
_ephemeralReply = false;
|
|
1031
|
-
/**
|
|
1032
|
-
* Set the command as disabled.
|
|
1033
|
-
*
|
|
1034
|
-
* @public
|
|
1035
|
-
* @returns {this}
|
|
1036
|
-
*/
|
|
1037
|
-
disable() {
|
|
1038
|
-
this._active = false;
|
|
1039
|
-
return this;
|
|
1040
|
-
}
|
|
1041
|
-
/**
|
|
1042
|
-
* Set the command as owner only.
|
|
1043
|
-
*
|
|
1044
|
-
* @public
|
|
1045
|
-
* @returns {this}
|
|
1046
|
-
*/
|
|
1047
|
-
setOwnerOnly() {
|
|
1048
|
-
this._permission = 5 /* BOT_OWNER */;
|
|
1049
|
-
this._ownerOnly = true;
|
|
1050
|
-
return this;
|
|
1051
|
-
}
|
|
1052
|
-
/**
|
|
1053
|
-
* Set the permission level required to run the command.
|
|
1054
|
-
*
|
|
1055
|
-
* @public
|
|
1056
|
-
* @param {PermissionLevel} permission
|
|
1057
|
-
* @returns {this}
|
|
1058
|
-
*/
|
|
1059
|
-
setPermission(permission) {
|
|
1060
|
-
this._permission = permission;
|
|
1061
|
-
return this;
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Set the interaction as ephemeral.
|
|
1065
|
-
*
|
|
1066
|
-
* @public
|
|
1067
|
-
* @returns {this}
|
|
1068
|
-
*/
|
|
1069
|
-
setEphemeralReply() {
|
|
1070
|
-
this._ephemeralReply = true;
|
|
1071
|
-
return this;
|
|
1072
|
-
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Build the builder
|
|
1075
|
-
*
|
|
1076
|
-
* @public
|
|
1077
|
-
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1078
|
-
*/
|
|
1079
|
-
build() {
|
|
1080
|
-
return {
|
|
1081
|
-
data: this,
|
|
1082
|
-
metadata: {
|
|
1083
|
-
active: this._active,
|
|
1084
|
-
ownerOnly: this._ownerOnly,
|
|
1085
|
-
permission: this._permission,
|
|
1086
|
-
ephemeralReply: this._ephemeralReply
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
|
-
// src/core/commands/command.base.ts
|
|
1093
954
|
var Command = class {
|
|
1094
955
|
/**
|
|
1095
956
|
* Returns whether the command is a SlashCommand.
|
|
@@ -1099,7 +960,7 @@ var Command = class {
|
|
|
1099
960
|
* @returns {this is SlashCommand}
|
|
1100
961
|
*/
|
|
1101
962
|
isSlashCommand() {
|
|
1102
|
-
return this.data instanceof SlashCommandBuilder
|
|
963
|
+
return this.data instanceof SlashCommandBuilder;
|
|
1103
964
|
}
|
|
1104
965
|
/**
|
|
1105
966
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -1109,7 +970,7 @@ var Command = class {
|
|
|
1109
970
|
* @returns {this is ContextMenuCommand}
|
|
1110
971
|
*/
|
|
1111
972
|
isContextMenuCommand() {
|
|
1112
|
-
return this.data instanceof
|
|
973
|
+
return this.data instanceof ContextMenuCommandBuilder;
|
|
1113
974
|
}
|
|
1114
975
|
/**
|
|
1115
976
|
* Returns JSON of the command builder.
|
|
@@ -1162,54 +1023,12 @@ var Command = class {
|
|
|
1162
1023
|
return memberHasPermission;
|
|
1163
1024
|
}
|
|
1164
1025
|
};
|
|
1165
|
-
var SlashCommand = class extends Command {
|
|
1166
|
-
/**
|
|
1167
|
-
* General handler for the command and its subcommand, if applicable.
|
|
1168
|
-
*
|
|
1169
|
-
* @public
|
|
1170
|
-
* @async
|
|
1171
|
-
* @param {TriviousClient} client
|
|
1172
|
-
* @param {ChatInputCommandInteraction} interaction
|
|
1173
|
-
* @returns {*}
|
|
1174
|
-
*/
|
|
1175
|
-
async execute(client, interaction) {
|
|
1176
|
-
const { run, reply, metadata } = this;
|
|
1177
|
-
const { options } = interaction;
|
|
1178
|
-
if (run) {
|
|
1179
|
-
const memberHasPermission2 = await this.validateGuildPermission(
|
|
1180
|
-
client,
|
|
1181
|
-
interaction,
|
|
1182
|
-
metadata.permission,
|
|
1183
|
-
false
|
|
1184
|
-
);
|
|
1185
|
-
if (memberHasPermission2) await run(client, interaction);
|
|
1186
|
-
}
|
|
1187
|
-
const subcommands = metadata.subcommands;
|
|
1188
|
-
if (subcommands.size <= 0) return;
|
|
1189
|
-
const subcommand = metadata.subcommands.find(
|
|
1190
|
-
(subcmd) => subcmd.data.name === options.getSubcommand()
|
|
1191
|
-
);
|
|
1192
|
-
if (!subcommand) {
|
|
1193
|
-
await reply(interaction, {
|
|
1194
|
-
content: "Ran subcommand is outdated or does not have a handler!"
|
|
1195
|
-
});
|
|
1196
|
-
return;
|
|
1197
|
-
}
|
|
1198
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1199
|
-
client,
|
|
1200
|
-
interaction,
|
|
1201
|
-
subcommand.metadata.permission
|
|
1202
|
-
);
|
|
1203
|
-
if (!memberHasPermission) return;
|
|
1204
|
-
await subcommand.execute(client, interaction);
|
|
1205
|
-
}
|
|
1206
|
-
};
|
|
1207
1026
|
var CommandBuilder = class extends SlashCommandBuilder {
|
|
1208
1027
|
_active = true;
|
|
1209
1028
|
_guildOnly = false;
|
|
1210
1029
|
_ownerOnly = false;
|
|
1211
1030
|
_permission = 0 /* USER */;
|
|
1212
|
-
_subcommands = new
|
|
1031
|
+
_subcommands = new Collection();
|
|
1213
1032
|
_ephemeralReply = false;
|
|
1214
1033
|
/**
|
|
1215
1034
|
* Set the command as disabled.
|
|
@@ -1285,12 +1104,7 @@ var CommandBuilder = class extends SlashCommandBuilder {
|
|
|
1285
1104
|
};
|
|
1286
1105
|
}
|
|
1287
1106
|
};
|
|
1288
|
-
|
|
1289
|
-
// src/core/commands/subcommand.base.ts
|
|
1290
|
-
import {
|
|
1291
|
-
SlashCommandSubcommandBuilder as SlashCommandSubcommandBuilder2
|
|
1292
|
-
} from "discord.js";
|
|
1293
|
-
var SubcommandBuilder = class extends SlashCommandSubcommandBuilder2 {
|
|
1107
|
+
var SubcommandBuilder = class extends SlashCommandSubcommandBuilder {
|
|
1294
1108
|
_active = true;
|
|
1295
1109
|
_ownerOnly = false;
|
|
1296
1110
|
_permission = 0 /* USER */;
|
|
@@ -1374,6 +1188,92 @@ var Subcommand = class {
|
|
|
1374
1188
|
await interaction.reply(newOptions);
|
|
1375
1189
|
}
|
|
1376
1190
|
};
|
|
1191
|
+
var ContextMenuCommand = class extends Command {
|
|
1192
|
+
/**
|
|
1193
|
+
* Base command handler.
|
|
1194
|
+
*
|
|
1195
|
+
* @public
|
|
1196
|
+
* @async
|
|
1197
|
+
* @param {TriviousClient} client
|
|
1198
|
+
* @param {ContextMenuCommandInteraction} interaction
|
|
1199
|
+
* @returns {*}
|
|
1200
|
+
*/
|
|
1201
|
+
async execute(client, interaction) {
|
|
1202
|
+
const { run, metadata } = this;
|
|
1203
|
+
const memberHasPermission = await this.validateGuildPermission(
|
|
1204
|
+
client,
|
|
1205
|
+
interaction,
|
|
1206
|
+
metadata.permission,
|
|
1207
|
+
false
|
|
1208
|
+
);
|
|
1209
|
+
if (memberHasPermission) await run(client, interaction);
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
var ContextMenuBuilder = class extends ContextMenuCommandBuilder {
|
|
1213
|
+
_active = true;
|
|
1214
|
+
_ownerOnly = false;
|
|
1215
|
+
_permission = 0 /* USER */;
|
|
1216
|
+
_ephemeralReply = false;
|
|
1217
|
+
/**
|
|
1218
|
+
* Set the command as disabled.
|
|
1219
|
+
*
|
|
1220
|
+
* @public
|
|
1221
|
+
* @returns {this}
|
|
1222
|
+
*/
|
|
1223
|
+
disable() {
|
|
1224
|
+
this._active = false;
|
|
1225
|
+
return this;
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Set the command as owner only.
|
|
1229
|
+
*
|
|
1230
|
+
* @public
|
|
1231
|
+
* @returns {this}
|
|
1232
|
+
*/
|
|
1233
|
+
setOwnerOnly() {
|
|
1234
|
+
this._permission = 5 /* BOT_OWNER */;
|
|
1235
|
+
this._ownerOnly = true;
|
|
1236
|
+
return this;
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Set the permission level required to run the command.
|
|
1240
|
+
*
|
|
1241
|
+
* @public
|
|
1242
|
+
* @param {PermissionLevel} permission
|
|
1243
|
+
* @returns {this}
|
|
1244
|
+
*/
|
|
1245
|
+
setPermission(permission) {
|
|
1246
|
+
this._permission = permission;
|
|
1247
|
+
return this;
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Set the interaction as ephemeral.
|
|
1251
|
+
*
|
|
1252
|
+
* @public
|
|
1253
|
+
* @returns {this}
|
|
1254
|
+
*/
|
|
1255
|
+
setEphemeralReply() {
|
|
1256
|
+
this._ephemeralReply = true;
|
|
1257
|
+
return this;
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Build the builder
|
|
1261
|
+
*
|
|
1262
|
+
* @public
|
|
1263
|
+
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1264
|
+
*/
|
|
1265
|
+
build() {
|
|
1266
|
+
return {
|
|
1267
|
+
data: this,
|
|
1268
|
+
metadata: {
|
|
1269
|
+
active: this._active,
|
|
1270
|
+
ownerOnly: this._ownerOnly,
|
|
1271
|
+
permission: this._permission,
|
|
1272
|
+
ephemeralReply: this._ephemeralReply
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1377
1277
|
|
|
1378
1278
|
// src/core/components/component.base.ts
|
|
1379
1279
|
var ComponentBuilder = class {
|
|
@@ -1476,27 +1376,6 @@ var Component = class {
|
|
|
1476
1376
|
}
|
|
1477
1377
|
};
|
|
1478
1378
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
export {
|
|
1482
|
-
BaseRegistry,
|
|
1483
|
-
ClientEvents2 as ClientEvents,
|
|
1484
|
-
Collection6 as Collection,
|
|
1485
|
-
Command,
|
|
1486
|
-
CommandBuilder,
|
|
1487
|
-
CommandRegistry,
|
|
1488
|
-
Component,
|
|
1489
|
-
ComponentBuilder,
|
|
1490
|
-
ComponentRegistry,
|
|
1491
|
-
ComponentType,
|
|
1492
|
-
ContextMenuBuilder,
|
|
1493
|
-
ContextMenuCommand,
|
|
1494
|
-
PermissionLevel,
|
|
1495
|
-
SlashCommand,
|
|
1496
|
-
Subcommand,
|
|
1497
|
-
SubcommandBuilder,
|
|
1498
|
-
TriviousClient,
|
|
1499
|
-
deconstructCustomId,
|
|
1500
|
-
getPermissionLevel
|
|
1501
|
-
};
|
|
1379
|
+
export { BaseRegistry, Command, CommandBuilder, CommandRegistry, Component, ComponentBuilder, ComponentRegistry, ComponentType, ContextMenuBuilder, ContextMenuCommand, PermissionLevel, Subcommand, SubcommandBuilder, TriviousClient, deconstructCustomId, getPermissionLevel };
|
|
1380
|
+
//# sourceMappingURL=index.js.map
|
|
1502
1381
|
//# sourceMappingURL=index.js.map
|