trivious 1.3.14 → 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 -346
- 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 +130 -254
- 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,17 +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 { dirname as dirname2 } from "path";
|
|
479
|
-
|
|
480
473
|
// src/shared/typings/permissions.ts
|
|
481
474
|
var PermissionLevel = /* @__PURE__ */ ((PermissionLevel2) => {
|
|
482
475
|
PermissionLevel2[PermissionLevel2["USER"] = 0] = "USER";
|
|
@@ -494,22 +487,18 @@ var getPermissionLevel = (client, member) => {
|
|
|
494
487
|
return rolePermissions[highestRole.name] ?? 0 /* USER */;
|
|
495
488
|
};
|
|
496
489
|
|
|
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
|
-
|
|
503
490
|
// src/shared/utility/functions.ts
|
|
491
|
+
var __filename$1 = fileURLToPath(import.meta.url);
|
|
492
|
+
var __dirname$1 = dirname(__filename$1);
|
|
504
493
|
var getPackageRoot = () => {
|
|
505
|
-
let dir = __dirname;
|
|
506
|
-
while (dir !==
|
|
494
|
+
let dir = __dirname$1;
|
|
495
|
+
while (dir !== dirname(dir)) {
|
|
507
496
|
if (existsSync(join(dir, "package.json")) || existsSync(join(dir, "node_modules"))) {
|
|
508
497
|
return dir;
|
|
509
498
|
}
|
|
510
|
-
dir =
|
|
499
|
+
dir = dirname(dir);
|
|
511
500
|
}
|
|
512
|
-
return __dirname;
|
|
501
|
+
return __dirname$1;
|
|
513
502
|
};
|
|
514
503
|
var FRAMEWORK_PACKAGE_ROOT = getPackageRoot();
|
|
515
504
|
function getCorePath(options) {
|
|
@@ -545,7 +534,7 @@ function resolveUserPath(relativePath) {
|
|
|
545
534
|
}
|
|
546
535
|
async function exists(path2) {
|
|
547
536
|
try {
|
|
548
|
-
await
|
|
537
|
+
await promises.access(path2);
|
|
549
538
|
return true;
|
|
550
539
|
} catch {
|
|
551
540
|
return false;
|
|
@@ -563,12 +552,6 @@ function hasPermission(client, options) {
|
|
|
563
552
|
}
|
|
564
553
|
return false;
|
|
565
554
|
}
|
|
566
|
-
|
|
567
|
-
// src/core/registry/command.registry.ts
|
|
568
|
-
import { Collection, SlashCommandSubcommandBuilder } from "discord.js";
|
|
569
|
-
|
|
570
|
-
// src/shared/typings/registry.ts
|
|
571
|
-
import { pathToFileURL } from "url";
|
|
572
555
|
var BaseRegistry = class {
|
|
573
556
|
/**
|
|
574
557
|
* Get all of loaded T
|
|
@@ -641,10 +624,6 @@ var deconstructCustomId = (customId) => {
|
|
|
641
624
|
tags
|
|
642
625
|
};
|
|
643
626
|
};
|
|
644
|
-
|
|
645
|
-
// src/core/registry/command.registry.ts
|
|
646
|
-
import { promises as fs2 } from "fs";
|
|
647
|
-
import { join as join2 } from "path";
|
|
648
627
|
var CommandRegistry = class extends BaseRegistry {
|
|
649
628
|
items = new Collection();
|
|
650
629
|
/**
|
|
@@ -658,12 +637,12 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
658
637
|
if (!await exists(directory)) {
|
|
659
638
|
return this;
|
|
660
639
|
}
|
|
661
|
-
const entries = await
|
|
640
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
662
641
|
for (const entry of entries) {
|
|
663
|
-
const fullPath =
|
|
642
|
+
const fullPath = join(directory, entry.name);
|
|
664
643
|
if (!entry.isDirectory()) continue;
|
|
665
|
-
const indexFile =
|
|
666
|
-
const indexJs =
|
|
644
|
+
const indexFile = join(fullPath, "index.ts");
|
|
645
|
+
const indexJs = join(fullPath, "index.js");
|
|
667
646
|
let commandFile = "";
|
|
668
647
|
if (await exists(indexFile)) commandFile = indexFile;
|
|
669
648
|
else if (await exists(indexJs)) commandFile = indexJs;
|
|
@@ -672,11 +651,11 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
672
651
|
if (!command) continue;
|
|
673
652
|
if (!command.metadata.active) continue;
|
|
674
653
|
if (command.isSlashCommand()) {
|
|
675
|
-
const subcommandFiles = (await
|
|
654
|
+
const subcommandFiles = (await promises.readdir(fullPath)).filter(
|
|
676
655
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
677
656
|
);
|
|
678
657
|
for (const file of subcommandFiles) {
|
|
679
|
-
const subcommand = await this.importFile(
|
|
658
|
+
const subcommand = await this.importFile(join(fullPath, file));
|
|
680
659
|
if (!subcommand) continue;
|
|
681
660
|
if (!subcommand.data.name || !(subcommand.data instanceof SlashCommandSubcommandBuilder))
|
|
682
661
|
continue;
|
|
@@ -689,13 +668,8 @@ var CommandRegistry = class extends BaseRegistry {
|
|
|
689
668
|
return this;
|
|
690
669
|
}
|
|
691
670
|
};
|
|
692
|
-
|
|
693
|
-
// src/core/registry/component.registry.ts
|
|
694
|
-
import { Collection as Collection2 } from "discord.js";
|
|
695
|
-
import { promises as fs3 } from "fs";
|
|
696
|
-
import { join as join3 } from "path";
|
|
697
671
|
var ComponentRegistry = class extends BaseRegistry {
|
|
698
|
-
items = new
|
|
672
|
+
items = new Collection();
|
|
699
673
|
/**
|
|
700
674
|
* Load all components.
|
|
701
675
|
*
|
|
@@ -707,15 +681,15 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
707
681
|
if (!await exists(directory)) {
|
|
708
682
|
return this;
|
|
709
683
|
}
|
|
710
|
-
const entries = await
|
|
684
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
711
685
|
for (const entry of entries) {
|
|
712
|
-
const fullPath =
|
|
686
|
+
const fullPath = join(directory, entry.name);
|
|
713
687
|
if (!entry.isDirectory()) continue;
|
|
714
|
-
const componentFiles = (await
|
|
688
|
+
const componentFiles = (await promises.readdir(fullPath)).filter(
|
|
715
689
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
716
690
|
);
|
|
717
691
|
for (const file of componentFiles) {
|
|
718
|
-
const component = await this.importFile(
|
|
692
|
+
const component = await this.importFile(join(fullPath, file));
|
|
719
693
|
if (!component) continue;
|
|
720
694
|
const { data } = deconstructCustomId(component.metadata.customId);
|
|
721
695
|
this.items.set(data, component);
|
|
@@ -724,14 +698,6 @@ var ComponentRegistry = class extends BaseRegistry {
|
|
|
724
698
|
return this;
|
|
725
699
|
}
|
|
726
700
|
};
|
|
727
|
-
|
|
728
|
-
// src/core/registry/event.registry.ts
|
|
729
|
-
import { Collection as Collection3 } from "discord.js";
|
|
730
|
-
import { promises as fs4 } from "fs";
|
|
731
|
-
import { join as join4 } from "path";
|
|
732
|
-
|
|
733
|
-
// src/core/events/interactionCreate.ts
|
|
734
|
-
import { ButtonInteraction, ModalSubmitInteraction } from "discord.js";
|
|
735
701
|
var interactionCreate_default = {
|
|
736
702
|
name: "interactionCreate",
|
|
737
703
|
execute: async (client, interaction) => {
|
|
@@ -790,7 +756,7 @@ var interactionCreate_default = {
|
|
|
790
756
|
|
|
791
757
|
// src/core/registry/event.registry.ts
|
|
792
758
|
var EventRegistry = class extends BaseRegistry {
|
|
793
|
-
items = new
|
|
759
|
+
items = new Collection();
|
|
794
760
|
/**
|
|
795
761
|
* Load all events.
|
|
796
762
|
*
|
|
@@ -800,9 +766,9 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
800
766
|
*/
|
|
801
767
|
async load(directory = getCorePath({ coreDirectory: "events" })) {
|
|
802
768
|
if (!await exists(directory)) return this;
|
|
803
|
-
const entries = await
|
|
769
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
804
770
|
for (const entry of entries) {
|
|
805
|
-
const fullPath =
|
|
771
|
+
const fullPath = join(directory, entry.name);
|
|
806
772
|
if (entry.isDirectory()) {
|
|
807
773
|
await this.load(fullPath);
|
|
808
774
|
continue;
|
|
@@ -813,8 +779,7 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
813
779
|
this.items.set(event.name, event);
|
|
814
780
|
}
|
|
815
781
|
}
|
|
816
|
-
|
|
817
|
-
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
782
|
+
this.items.set(interactionCreate_default.name, interactionCreate_default);
|
|
818
783
|
return this;
|
|
819
784
|
}
|
|
820
785
|
/**
|
|
@@ -830,13 +795,8 @@ var EventRegistry = class extends BaseRegistry {
|
|
|
830
795
|
}
|
|
831
796
|
}
|
|
832
797
|
};
|
|
833
|
-
|
|
834
|
-
// src/core/registry/module.registry.ts
|
|
835
|
-
import { Collection as Collection4 } from "discord.js";
|
|
836
|
-
import { promises as fs5 } from "fs";
|
|
837
|
-
import { join as join5 } from "path";
|
|
838
798
|
var ModuleRegistry = class extends BaseRegistry {
|
|
839
|
-
items = new
|
|
799
|
+
items = new Collection();
|
|
840
800
|
/**
|
|
841
801
|
* Load all modules.
|
|
842
802
|
*
|
|
@@ -848,15 +808,15 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
848
808
|
if (!await exists(directory)) {
|
|
849
809
|
return this;
|
|
850
810
|
}
|
|
851
|
-
const entries = await
|
|
811
|
+
const entries = await promises.readdir(directory, { withFileTypes: true });
|
|
852
812
|
for (const entry of entries) {
|
|
853
|
-
const fullPath =
|
|
813
|
+
const fullPath = join(directory, entry.name);
|
|
854
814
|
if (!entry.isDirectory()) continue;
|
|
855
|
-
const moduleFiles = (await
|
|
815
|
+
const moduleFiles = (await promises.readdir(fullPath)).filter(
|
|
856
816
|
(file) => (file.endsWith(".ts") || file.endsWith(".js")) && !file.startsWith("index.") && !file.endsWith(".d.ts")
|
|
857
817
|
);
|
|
858
818
|
for (const file of moduleFiles) {
|
|
859
|
-
const moduleEvent = await this.importFile(
|
|
819
|
+
const moduleEvent = await this.importFile(join(fullPath, file));
|
|
860
820
|
if (!moduleEvent || !moduleEvent.events) continue;
|
|
861
821
|
this.items.set(moduleEvent.name, moduleEvent);
|
|
862
822
|
}
|
|
@@ -880,9 +840,6 @@ var ModuleRegistry = class extends BaseRegistry {
|
|
|
880
840
|
}
|
|
881
841
|
}
|
|
882
842
|
};
|
|
883
|
-
|
|
884
|
-
// src/core/registry/index.ts
|
|
885
|
-
import path from "path";
|
|
886
843
|
var registries = () => ({
|
|
887
844
|
commands: new CommandRegistry(),
|
|
888
845
|
components: new ComponentRegistry(),
|
|
@@ -994,105 +951,6 @@ var TriviousClient = class extends Client {
|
|
|
994
951
|
return this._options.rolePermissions ?? {};
|
|
995
952
|
}
|
|
996
953
|
};
|
|
997
|
-
|
|
998
|
-
// src/core/commands/command.base.ts
|
|
999
|
-
import {
|
|
1000
|
-
Collection as Collection5,
|
|
1001
|
-
ContextMenuCommandBuilder as ContextMenuCommandBuilder2,
|
|
1002
|
-
InteractionContextType,
|
|
1003
|
-
SlashCommandBuilder
|
|
1004
|
-
} from "discord.js";
|
|
1005
|
-
|
|
1006
|
-
// src/core/commands/contextcommand.base.ts
|
|
1007
|
-
import { ContextMenuCommandBuilder } from "discord.js";
|
|
1008
|
-
var ContextMenuCommand = class extends Command {
|
|
1009
|
-
/**
|
|
1010
|
-
* Base command handler.
|
|
1011
|
-
*
|
|
1012
|
-
* @public
|
|
1013
|
-
* @async
|
|
1014
|
-
* @param {TriviousClient} client
|
|
1015
|
-
* @param {ContextMenuCommandInteraction} interaction
|
|
1016
|
-
* @returns {*}
|
|
1017
|
-
*/
|
|
1018
|
-
async execute(client, interaction) {
|
|
1019
|
-
const { run, metadata } = this;
|
|
1020
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1021
|
-
client,
|
|
1022
|
-
interaction,
|
|
1023
|
-
metadata.permission,
|
|
1024
|
-
false
|
|
1025
|
-
);
|
|
1026
|
-
if (memberHasPermission) await run(client, interaction);
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
var ContextMenuBuilder = class extends ContextMenuCommandBuilder {
|
|
1030
|
-
_active = true;
|
|
1031
|
-
_ownerOnly = false;
|
|
1032
|
-
_permission = 0 /* USER */;
|
|
1033
|
-
_ephemeralReply = false;
|
|
1034
|
-
/**
|
|
1035
|
-
* Set the command as disabled.
|
|
1036
|
-
*
|
|
1037
|
-
* @public
|
|
1038
|
-
* @returns {this}
|
|
1039
|
-
*/
|
|
1040
|
-
disable() {
|
|
1041
|
-
this._active = false;
|
|
1042
|
-
return this;
|
|
1043
|
-
}
|
|
1044
|
-
/**
|
|
1045
|
-
* Set the command as owner only.
|
|
1046
|
-
*
|
|
1047
|
-
* @public
|
|
1048
|
-
* @returns {this}
|
|
1049
|
-
*/
|
|
1050
|
-
setOwnerOnly() {
|
|
1051
|
-
this._permission = 5 /* BOT_OWNER */;
|
|
1052
|
-
this._ownerOnly = true;
|
|
1053
|
-
return this;
|
|
1054
|
-
}
|
|
1055
|
-
/**
|
|
1056
|
-
* Set the permission level required to run the command.
|
|
1057
|
-
*
|
|
1058
|
-
* @public
|
|
1059
|
-
* @param {PermissionLevel} permission
|
|
1060
|
-
* @returns {this}
|
|
1061
|
-
*/
|
|
1062
|
-
setPermission(permission) {
|
|
1063
|
-
this._permission = permission;
|
|
1064
|
-
return this;
|
|
1065
|
-
}
|
|
1066
|
-
/**
|
|
1067
|
-
* Set the interaction as ephemeral.
|
|
1068
|
-
*
|
|
1069
|
-
* @public
|
|
1070
|
-
* @returns {this}
|
|
1071
|
-
*/
|
|
1072
|
-
setEphemeralReply() {
|
|
1073
|
-
this._ephemeralReply = true;
|
|
1074
|
-
return this;
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Build the builder
|
|
1078
|
-
*
|
|
1079
|
-
* @public
|
|
1080
|
-
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1081
|
-
*/
|
|
1082
|
-
build() {
|
|
1083
|
-
return {
|
|
1084
|
-
data: this,
|
|
1085
|
-
metadata: {
|
|
1086
|
-
active: this._active,
|
|
1087
|
-
ownerOnly: this._ownerOnly,
|
|
1088
|
-
permission: this._permission,
|
|
1089
|
-
ephemeralReply: this._ephemeralReply
|
|
1090
|
-
}
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1094
|
-
|
|
1095
|
-
// src/core/commands/command.base.ts
|
|
1096
954
|
var Command = class {
|
|
1097
955
|
/**
|
|
1098
956
|
* Returns whether the command is a SlashCommand.
|
|
@@ -1102,7 +960,7 @@ var Command = class {
|
|
|
1102
960
|
* @returns {this is SlashCommand}
|
|
1103
961
|
*/
|
|
1104
962
|
isSlashCommand() {
|
|
1105
|
-
return this.data instanceof SlashCommandBuilder
|
|
963
|
+
return this.data instanceof SlashCommandBuilder;
|
|
1106
964
|
}
|
|
1107
965
|
/**
|
|
1108
966
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -1112,7 +970,7 @@ var Command = class {
|
|
|
1112
970
|
* @returns {this is ContextMenuCommand}
|
|
1113
971
|
*/
|
|
1114
972
|
isContextMenuCommand() {
|
|
1115
|
-
return this.data instanceof
|
|
973
|
+
return this.data instanceof ContextMenuCommandBuilder;
|
|
1116
974
|
}
|
|
1117
975
|
/**
|
|
1118
976
|
* Returns JSON of the command builder.
|
|
@@ -1165,54 +1023,12 @@ var Command = class {
|
|
|
1165
1023
|
return memberHasPermission;
|
|
1166
1024
|
}
|
|
1167
1025
|
};
|
|
1168
|
-
var SlashCommand = class extends Command {
|
|
1169
|
-
/**
|
|
1170
|
-
* General handler for the command and its subcommand, if applicable.
|
|
1171
|
-
*
|
|
1172
|
-
* @public
|
|
1173
|
-
* @async
|
|
1174
|
-
* @param {TriviousClient} client
|
|
1175
|
-
* @param {ChatInputCommandInteraction} interaction
|
|
1176
|
-
* @returns {*}
|
|
1177
|
-
*/
|
|
1178
|
-
async execute(client, interaction) {
|
|
1179
|
-
const { run, reply, metadata } = this;
|
|
1180
|
-
const { options } = interaction;
|
|
1181
|
-
if (run) {
|
|
1182
|
-
const memberHasPermission2 = await this.validateGuildPermission(
|
|
1183
|
-
client,
|
|
1184
|
-
interaction,
|
|
1185
|
-
metadata.permission,
|
|
1186
|
-
false
|
|
1187
|
-
);
|
|
1188
|
-
if (memberHasPermission2) await run(client, interaction);
|
|
1189
|
-
}
|
|
1190
|
-
const subcommands = metadata.subcommands;
|
|
1191
|
-
if (subcommands.size <= 0) return;
|
|
1192
|
-
const subcommand = metadata.subcommands.find(
|
|
1193
|
-
(subcmd) => subcmd.data.name === options.getSubcommand()
|
|
1194
|
-
);
|
|
1195
|
-
if (!subcommand) {
|
|
1196
|
-
await reply(interaction, {
|
|
1197
|
-
content: "Ran subcommand is outdated or does not have a handler!"
|
|
1198
|
-
});
|
|
1199
|
-
return;
|
|
1200
|
-
}
|
|
1201
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1202
|
-
client,
|
|
1203
|
-
interaction,
|
|
1204
|
-
subcommand.metadata.permission
|
|
1205
|
-
);
|
|
1206
|
-
if (!memberHasPermission) return;
|
|
1207
|
-
await subcommand.execute(client, interaction);
|
|
1208
|
-
}
|
|
1209
|
-
};
|
|
1210
1026
|
var CommandBuilder = class extends SlashCommandBuilder {
|
|
1211
1027
|
_active = true;
|
|
1212
1028
|
_guildOnly = false;
|
|
1213
1029
|
_ownerOnly = false;
|
|
1214
1030
|
_permission = 0 /* USER */;
|
|
1215
|
-
_subcommands = new
|
|
1031
|
+
_subcommands = new Collection();
|
|
1216
1032
|
_ephemeralReply = false;
|
|
1217
1033
|
/**
|
|
1218
1034
|
* Set the command as disabled.
|
|
@@ -1288,12 +1104,7 @@ var CommandBuilder = class extends SlashCommandBuilder {
|
|
|
1288
1104
|
};
|
|
1289
1105
|
}
|
|
1290
1106
|
};
|
|
1291
|
-
|
|
1292
|
-
// src/core/commands/subcommand.base.ts
|
|
1293
|
-
import {
|
|
1294
|
-
SlashCommandSubcommandBuilder as SlashCommandSubcommandBuilder2
|
|
1295
|
-
} from "discord.js";
|
|
1296
|
-
var SubcommandBuilder = class extends SlashCommandSubcommandBuilder2 {
|
|
1107
|
+
var SubcommandBuilder = class extends SlashCommandSubcommandBuilder {
|
|
1297
1108
|
_active = true;
|
|
1298
1109
|
_ownerOnly = false;
|
|
1299
1110
|
_permission = 0 /* USER */;
|
|
@@ -1377,6 +1188,92 @@ var Subcommand = class {
|
|
|
1377
1188
|
await interaction.reply(newOptions);
|
|
1378
1189
|
}
|
|
1379
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
|
+
};
|
|
1380
1277
|
|
|
1381
1278
|
// src/core/components/component.base.ts
|
|
1382
1279
|
var ComponentBuilder = class {
|
|
@@ -1479,27 +1376,6 @@ var Component = class {
|
|
|
1479
1376
|
}
|
|
1480
1377
|
};
|
|
1481
1378
|
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
export {
|
|
1485
|
-
BaseRegistry,
|
|
1486
|
-
ClientEvents2 as ClientEvents,
|
|
1487
|
-
Collection6 as Collection,
|
|
1488
|
-
Command,
|
|
1489
|
-
CommandBuilder,
|
|
1490
|
-
CommandRegistry,
|
|
1491
|
-
Component,
|
|
1492
|
-
ComponentBuilder,
|
|
1493
|
-
ComponentRegistry,
|
|
1494
|
-
ComponentType,
|
|
1495
|
-
ContextMenuBuilder,
|
|
1496
|
-
ContextMenuCommand,
|
|
1497
|
-
PermissionLevel,
|
|
1498
|
-
SlashCommand,
|
|
1499
|
-
Subcommand,
|
|
1500
|
-
SubcommandBuilder,
|
|
1501
|
-
TriviousClient,
|
|
1502
|
-
deconstructCustomId,
|
|
1503
|
-
getPermissionLevel
|
|
1504
|
-
};
|
|
1379
|
+
export { BaseRegistry, Command, CommandBuilder, CommandRegistry, Component, ComponentBuilder, ComponentRegistry, ComponentType, ContextMenuBuilder, ContextMenuCommand, PermissionLevel, Subcommand, SubcommandBuilder, TriviousClient, deconstructCustomId, getPermissionLevel };
|
|
1380
|
+
//# sourceMappingURL=index.js.map
|
|
1505
1381
|
//# sourceMappingURL=index.js.map
|