trivious 1.3.16 → 1.3.17
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 +104 -88
- 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 +105 -89
- package/dist/index.js.map +1 -1
- package/package.json +75 -75
package/dist/index.cjs
CHANGED
|
@@ -725,6 +725,10 @@ var interactionCreate_default = {
|
|
|
725
725
|
requiredPermission
|
|
726
726
|
);
|
|
727
727
|
if (!hasPermission2) return;
|
|
728
|
+
if (!("execute" in command)) {
|
|
729
|
+
await command.reply(interaction, { content: "Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!" });
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
728
732
|
await command.reply(interaction, { content: "Processing command..." });
|
|
729
733
|
if (interaction.isChatInputCommand() && command.isSlashCommand()) {
|
|
730
734
|
await command.execute(client, interaction);
|
|
@@ -957,6 +961,94 @@ var TriviousClient = class extends discord_js.Client {
|
|
|
957
961
|
return this._options.rolePermissions ?? {};
|
|
958
962
|
}
|
|
959
963
|
};
|
|
964
|
+
var ContextMenuCommand = class extends Command {
|
|
965
|
+
/**
|
|
966
|
+
* Base command handler.
|
|
967
|
+
*
|
|
968
|
+
* @public
|
|
969
|
+
* @async
|
|
970
|
+
* @param {TriviousClient} client
|
|
971
|
+
* @param {ContextMenuCommandInteraction} interaction
|
|
972
|
+
* @returns {*}
|
|
973
|
+
*/
|
|
974
|
+
async execute(client, interaction) {
|
|
975
|
+
const { run, metadata } = this;
|
|
976
|
+
const memberHasPermission = await this.validateGuildPermission(
|
|
977
|
+
client,
|
|
978
|
+
interaction,
|
|
979
|
+
metadata.permission,
|
|
980
|
+
false
|
|
981
|
+
);
|
|
982
|
+
if (memberHasPermission) await run(client, interaction);
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
|
|
986
|
+
_active = true;
|
|
987
|
+
_ownerOnly = false;
|
|
988
|
+
_permission = 0 /* USER */;
|
|
989
|
+
_ephemeralReply = false;
|
|
990
|
+
/**
|
|
991
|
+
* Set the command as disabled.
|
|
992
|
+
*
|
|
993
|
+
* @public
|
|
994
|
+
* @returns {this}
|
|
995
|
+
*/
|
|
996
|
+
disable() {
|
|
997
|
+
this._active = false;
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Set the command as owner only.
|
|
1002
|
+
*
|
|
1003
|
+
* @public
|
|
1004
|
+
* @returns {this}
|
|
1005
|
+
*/
|
|
1006
|
+
setOwnerOnly() {
|
|
1007
|
+
this._permission = 5 /* BOT_OWNER */;
|
|
1008
|
+
this._ownerOnly = true;
|
|
1009
|
+
return this;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Set the permission level required to run the command.
|
|
1013
|
+
*
|
|
1014
|
+
* @public
|
|
1015
|
+
* @param {PermissionLevel} permission
|
|
1016
|
+
* @returns {this}
|
|
1017
|
+
*/
|
|
1018
|
+
setPermission(permission) {
|
|
1019
|
+
this._permission = permission;
|
|
1020
|
+
return this;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Set the interaction as ephemeral.
|
|
1024
|
+
*
|
|
1025
|
+
* @public
|
|
1026
|
+
* @returns {this}
|
|
1027
|
+
*/
|
|
1028
|
+
setEphemeralReply() {
|
|
1029
|
+
this._ephemeralReply = true;
|
|
1030
|
+
return this;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Build the builder
|
|
1034
|
+
*
|
|
1035
|
+
* @public
|
|
1036
|
+
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1037
|
+
*/
|
|
1038
|
+
build() {
|
|
1039
|
+
return {
|
|
1040
|
+
data: this,
|
|
1041
|
+
metadata: {
|
|
1042
|
+
active: this._active,
|
|
1043
|
+
ownerOnly: this._ownerOnly,
|
|
1044
|
+
permission: this._permission,
|
|
1045
|
+
ephemeralReply: this._ephemeralReply
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
// src/core/commands/command.base.ts
|
|
960
1052
|
var Command = class {
|
|
961
1053
|
/**
|
|
962
1054
|
* Returns whether the command is a SlashCommand.
|
|
@@ -966,7 +1058,7 @@ var Command = class {
|
|
|
966
1058
|
* @returns {this is SlashCommand}
|
|
967
1059
|
*/
|
|
968
1060
|
isSlashCommand() {
|
|
969
|
-
return this.data instanceof discord_js.SlashCommandBuilder;
|
|
1061
|
+
return this.data instanceof discord_js.SlashCommandBuilder && this instanceof SlashCommand;
|
|
970
1062
|
}
|
|
971
1063
|
/**
|
|
972
1064
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -976,7 +1068,7 @@ var Command = class {
|
|
|
976
1068
|
* @returns {this is ContextMenuCommand}
|
|
977
1069
|
*/
|
|
978
1070
|
isContextMenuCommand() {
|
|
979
|
-
return this.data instanceof discord_js.ContextMenuCommandBuilder;
|
|
1071
|
+
return this.data instanceof discord_js.ContextMenuCommandBuilder && this instanceof ContextMenuCommand;
|
|
980
1072
|
}
|
|
981
1073
|
/**
|
|
982
1074
|
* Returns JSON of the command builder.
|
|
@@ -1030,6 +1122,16 @@ var Command = class {
|
|
|
1030
1122
|
}
|
|
1031
1123
|
};
|
|
1032
1124
|
var SlashCommand = class extends Command {
|
|
1125
|
+
/**
|
|
1126
|
+
* Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
|
|
1127
|
+
*
|
|
1128
|
+
* @abstract
|
|
1129
|
+
* @type {?(
|
|
1130
|
+
* client: TriviousClient,
|
|
1131
|
+
* interaction: ChatInputCommandInteraction
|
|
1132
|
+
* ) => Promise<void>}
|
|
1133
|
+
*/
|
|
1134
|
+
run;
|
|
1033
1135
|
/**
|
|
1034
1136
|
* General handler for the command and its subcommand, if applicable.
|
|
1035
1137
|
*
|
|
@@ -1236,92 +1338,6 @@ var Subcommand = class {
|
|
|
1236
1338
|
await interaction.reply(newOptions);
|
|
1237
1339
|
}
|
|
1238
1340
|
};
|
|
1239
|
-
var ContextMenuCommand = class extends Command {
|
|
1240
|
-
/**
|
|
1241
|
-
* Base command handler.
|
|
1242
|
-
*
|
|
1243
|
-
* @public
|
|
1244
|
-
* @async
|
|
1245
|
-
* @param {TriviousClient} client
|
|
1246
|
-
* @param {ContextMenuCommandInteraction} interaction
|
|
1247
|
-
* @returns {*}
|
|
1248
|
-
*/
|
|
1249
|
-
async execute(client, interaction) {
|
|
1250
|
-
const { run, metadata } = this;
|
|
1251
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1252
|
-
client,
|
|
1253
|
-
interaction,
|
|
1254
|
-
metadata.permission,
|
|
1255
|
-
false
|
|
1256
|
-
);
|
|
1257
|
-
if (memberHasPermission) await run(client, interaction);
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
|
|
1261
|
-
_active = true;
|
|
1262
|
-
_ownerOnly = false;
|
|
1263
|
-
_permission = 0 /* USER */;
|
|
1264
|
-
_ephemeralReply = false;
|
|
1265
|
-
/**
|
|
1266
|
-
* Set the command as disabled.
|
|
1267
|
-
*
|
|
1268
|
-
* @public
|
|
1269
|
-
* @returns {this}
|
|
1270
|
-
*/
|
|
1271
|
-
disable() {
|
|
1272
|
-
this._active = false;
|
|
1273
|
-
return this;
|
|
1274
|
-
}
|
|
1275
|
-
/**
|
|
1276
|
-
* Set the command as owner only.
|
|
1277
|
-
*
|
|
1278
|
-
* @public
|
|
1279
|
-
* @returns {this}
|
|
1280
|
-
*/
|
|
1281
|
-
setOwnerOnly() {
|
|
1282
|
-
this._permission = 5 /* BOT_OWNER */;
|
|
1283
|
-
this._ownerOnly = true;
|
|
1284
|
-
return this;
|
|
1285
|
-
}
|
|
1286
|
-
/**
|
|
1287
|
-
* Set the permission level required to run the command.
|
|
1288
|
-
*
|
|
1289
|
-
* @public
|
|
1290
|
-
* @param {PermissionLevel} permission
|
|
1291
|
-
* @returns {this}
|
|
1292
|
-
*/
|
|
1293
|
-
setPermission(permission) {
|
|
1294
|
-
this._permission = permission;
|
|
1295
|
-
return this;
|
|
1296
|
-
}
|
|
1297
|
-
/**
|
|
1298
|
-
* Set the interaction as ephemeral.
|
|
1299
|
-
*
|
|
1300
|
-
* @public
|
|
1301
|
-
* @returns {this}
|
|
1302
|
-
*/
|
|
1303
|
-
setEphemeralReply() {
|
|
1304
|
-
this._ephemeralReply = true;
|
|
1305
|
-
return this;
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* Build the builder
|
|
1309
|
-
*
|
|
1310
|
-
* @public
|
|
1311
|
-
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1312
|
-
*/
|
|
1313
|
-
build() {
|
|
1314
|
-
return {
|
|
1315
|
-
data: this,
|
|
1316
|
-
metadata: {
|
|
1317
|
-
active: this._active,
|
|
1318
|
-
ownerOnly: this._ownerOnly,
|
|
1319
|
-
permission: this._permission,
|
|
1320
|
-
ephemeralReply: this._ephemeralReply
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
|
-
};
|
|
1325
1341
|
|
|
1326
1342
|
// src/core/components/component.base.ts
|
|
1327
1343
|
var ComponentBuilder = class {
|