trivious 1.3.7 → 1.3.9
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/index.cjs +135 -92
- 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 +136 -94
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -549,14 +549,12 @@ async function exists(path2) {
|
|
|
549
549
|
function hasPermission(client, options) {
|
|
550
550
|
const { permission, user, member } = options;
|
|
551
551
|
if (user) {
|
|
552
|
-
if (permission === 5 /* BOT_OWNER */)
|
|
553
|
-
return !(user.id === "424764032667484171");
|
|
554
|
-
}
|
|
552
|
+
if (permission === 5 /* BOT_OWNER */) return user.id === "424764032667484171";
|
|
555
553
|
return true;
|
|
556
554
|
}
|
|
557
555
|
if (member) {
|
|
558
556
|
const memberPermission = getPermissionLevel(client, member);
|
|
559
|
-
return
|
|
557
|
+
return memberPermission >= permission;
|
|
560
558
|
}
|
|
561
559
|
return false;
|
|
562
560
|
}
|
|
@@ -959,6 +957,94 @@ var TriviousClient = class extends discord_js.Client {
|
|
|
959
957
|
return this._options.rolePermissions ?? {};
|
|
960
958
|
}
|
|
961
959
|
};
|
|
960
|
+
var ContextMenuCommand = class extends Command {
|
|
961
|
+
/**
|
|
962
|
+
* Base command handler.
|
|
963
|
+
*
|
|
964
|
+
* @public
|
|
965
|
+
* @async
|
|
966
|
+
* @param {TriviousClient} client
|
|
967
|
+
* @param {ContextMenuCommandInteraction} interaction
|
|
968
|
+
* @returns {*}
|
|
969
|
+
*/
|
|
970
|
+
async execute(client, interaction) {
|
|
971
|
+
const { run, metadata } = this;
|
|
972
|
+
const memberHasPermission = await this.validateGuildPermission(
|
|
973
|
+
client,
|
|
974
|
+
interaction,
|
|
975
|
+
metadata.permission,
|
|
976
|
+
false
|
|
977
|
+
);
|
|
978
|
+
if (memberHasPermission) await run(client, interaction);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
|
|
982
|
+
_active = true;
|
|
983
|
+
_ownerOnly = false;
|
|
984
|
+
_permission = 0 /* USER */;
|
|
985
|
+
_ephemeralReply = false;
|
|
986
|
+
/**
|
|
987
|
+
* Set the command as disabled.
|
|
988
|
+
*
|
|
989
|
+
* @public
|
|
990
|
+
* @returns {this}
|
|
991
|
+
*/
|
|
992
|
+
disable() {
|
|
993
|
+
this._active = false;
|
|
994
|
+
return this;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Set the command as owner only.
|
|
998
|
+
*
|
|
999
|
+
* @public
|
|
1000
|
+
* @returns {this}
|
|
1001
|
+
*/
|
|
1002
|
+
setOwnerOnly() {
|
|
1003
|
+
this._permission = 5 /* BOT_OWNER */;
|
|
1004
|
+
this._ownerOnly = true;
|
|
1005
|
+
return this;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Set the permission level required to run the command.
|
|
1009
|
+
*
|
|
1010
|
+
* @public
|
|
1011
|
+
* @param {PermissionLevel} permission
|
|
1012
|
+
* @returns {this}
|
|
1013
|
+
*/
|
|
1014
|
+
setPermission(permission) {
|
|
1015
|
+
this._permission = permission;
|
|
1016
|
+
return this;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Set the interaction as ephemeral.
|
|
1020
|
+
*
|
|
1021
|
+
* @public
|
|
1022
|
+
* @returns {this}
|
|
1023
|
+
*/
|
|
1024
|
+
setEphemeralReply() {
|
|
1025
|
+
this._ephemeralReply = true;
|
|
1026
|
+
return this;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Build the builder
|
|
1030
|
+
*
|
|
1031
|
+
* @public
|
|
1032
|
+
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1033
|
+
*/
|
|
1034
|
+
build() {
|
|
1035
|
+
return {
|
|
1036
|
+
data: this,
|
|
1037
|
+
metadata: {
|
|
1038
|
+
active: this._active,
|
|
1039
|
+
ownerOnly: this._ownerOnly,
|
|
1040
|
+
permission: this._permission,
|
|
1041
|
+
ephemeralReply: this._ephemeralReply
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
// src/core/commands/command.base.ts
|
|
962
1048
|
var Command = class {
|
|
963
1049
|
/**
|
|
964
1050
|
* Returns whether the command is a SlashCommand.
|
|
@@ -968,7 +1054,7 @@ var Command = class {
|
|
|
968
1054
|
* @returns {this is SlashCommand}
|
|
969
1055
|
*/
|
|
970
1056
|
isSlashCommand() {
|
|
971
|
-
return this.data instanceof discord_js.SlashCommandBuilder;
|
|
1057
|
+
return this.data instanceof discord_js.SlashCommandBuilder && this instanceof SlashCommand;
|
|
972
1058
|
}
|
|
973
1059
|
/**
|
|
974
1060
|
* Returns whether the command is a ContextMenuCommand.
|
|
@@ -978,7 +1064,7 @@ var Command = class {
|
|
|
978
1064
|
* @returns {this is ContextMenuCommand}
|
|
979
1065
|
*/
|
|
980
1066
|
isContextMenuCommand() {
|
|
981
|
-
return this.data instanceof discord_js.ContextMenuCommandBuilder;
|
|
1067
|
+
return this.data instanceof discord_js.ContextMenuCommandBuilder && this instanceof ContextMenuCommand;
|
|
982
1068
|
}
|
|
983
1069
|
/**
|
|
984
1070
|
* Returns JSON of the command builder.
|
|
@@ -1031,6 +1117,48 @@ var Command = class {
|
|
|
1031
1117
|
return memberHasPermission;
|
|
1032
1118
|
}
|
|
1033
1119
|
};
|
|
1120
|
+
var SlashCommand = class extends Command {
|
|
1121
|
+
/**
|
|
1122
|
+
* General handler for the command and its subcommand, if applicable.
|
|
1123
|
+
*
|
|
1124
|
+
* @public
|
|
1125
|
+
* @async
|
|
1126
|
+
* @param {TriviousClient} client
|
|
1127
|
+
* @param {ChatInputCommandInteraction} interaction
|
|
1128
|
+
* @returns {*}
|
|
1129
|
+
*/
|
|
1130
|
+
async execute(client, interaction) {
|
|
1131
|
+
const { run, reply, metadata } = this;
|
|
1132
|
+
const { options } = interaction;
|
|
1133
|
+
if (run) {
|
|
1134
|
+
const memberHasPermission2 = await this.validateGuildPermission(
|
|
1135
|
+
client,
|
|
1136
|
+
interaction,
|
|
1137
|
+
metadata.permission,
|
|
1138
|
+
false
|
|
1139
|
+
);
|
|
1140
|
+
if (memberHasPermission2) await run(client, interaction);
|
|
1141
|
+
}
|
|
1142
|
+
const subcommands = metadata.subcommands;
|
|
1143
|
+
if (subcommands.size <= 0) return;
|
|
1144
|
+
const subcommand = metadata.subcommands.find(
|
|
1145
|
+
(subcmd) => subcmd.data.name === options.getSubcommand()
|
|
1146
|
+
);
|
|
1147
|
+
if (!subcommand) {
|
|
1148
|
+
await reply(interaction, {
|
|
1149
|
+
content: "Ran subcommand is outdated or does not have a handler!"
|
|
1150
|
+
});
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
const memberHasPermission = await this.validateGuildPermission(
|
|
1154
|
+
client,
|
|
1155
|
+
interaction,
|
|
1156
|
+
subcommand.metadata.permission
|
|
1157
|
+
);
|
|
1158
|
+
if (!memberHasPermission) return;
|
|
1159
|
+
await subcommand.execute(client, interaction);
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1034
1162
|
var CommandBuilder = class extends discord_js.SlashCommandBuilder {
|
|
1035
1163
|
_active = true;
|
|
1036
1164
|
_guildOnly = false;
|
|
@@ -1196,92 +1324,6 @@ var Subcommand = class {
|
|
|
1196
1324
|
await interaction.reply(newOptions);
|
|
1197
1325
|
}
|
|
1198
1326
|
};
|
|
1199
|
-
var ContextMenuCommand = class extends Command {
|
|
1200
|
-
/**
|
|
1201
|
-
* Base command handler.
|
|
1202
|
-
*
|
|
1203
|
-
* @public
|
|
1204
|
-
* @async
|
|
1205
|
-
* @param {TriviousClient} client
|
|
1206
|
-
* @param {ContextMenuCommandInteraction} interaction
|
|
1207
|
-
* @returns {*}
|
|
1208
|
-
*/
|
|
1209
|
-
async execute(client, interaction) {
|
|
1210
|
-
const { run, metadata } = this;
|
|
1211
|
-
const memberHasPermission = await this.validateGuildPermission(
|
|
1212
|
-
client,
|
|
1213
|
-
interaction,
|
|
1214
|
-
metadata.permission,
|
|
1215
|
-
false
|
|
1216
|
-
);
|
|
1217
|
-
if (memberHasPermission) await run(client, interaction);
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
1220
|
-
var ContextMenuBuilder = class extends discord_js.ContextMenuCommandBuilder {
|
|
1221
|
-
_active = true;
|
|
1222
|
-
_ownerOnly = false;
|
|
1223
|
-
_permission = 0 /* USER */;
|
|
1224
|
-
_ephemeralReply = false;
|
|
1225
|
-
/**
|
|
1226
|
-
* Set the command as disabled.
|
|
1227
|
-
*
|
|
1228
|
-
* @public
|
|
1229
|
-
* @returns {this}
|
|
1230
|
-
*/
|
|
1231
|
-
disable() {
|
|
1232
|
-
this._active = false;
|
|
1233
|
-
return this;
|
|
1234
|
-
}
|
|
1235
|
-
/**
|
|
1236
|
-
* Set the command as owner only.
|
|
1237
|
-
*
|
|
1238
|
-
* @public
|
|
1239
|
-
* @returns {this}
|
|
1240
|
-
*/
|
|
1241
|
-
setOwnerOnly() {
|
|
1242
|
-
this._permission = 5 /* BOT_OWNER */;
|
|
1243
|
-
this._ownerOnly = true;
|
|
1244
|
-
return this;
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
* Set the permission level required to run the command.
|
|
1248
|
-
*
|
|
1249
|
-
* @public
|
|
1250
|
-
* @param {PermissionLevel} permission
|
|
1251
|
-
* @returns {this}
|
|
1252
|
-
*/
|
|
1253
|
-
setPermission(permission) {
|
|
1254
|
-
this._permission = permission;
|
|
1255
|
-
return this;
|
|
1256
|
-
}
|
|
1257
|
-
/**
|
|
1258
|
-
* Set the interaction as ephemeral.
|
|
1259
|
-
*
|
|
1260
|
-
* @public
|
|
1261
|
-
* @returns {this}
|
|
1262
|
-
*/
|
|
1263
|
-
setEphemeralReply() {
|
|
1264
|
-
this._ephemeralReply = true;
|
|
1265
|
-
return this;
|
|
1266
|
-
}
|
|
1267
|
-
/**
|
|
1268
|
-
* Build the builder
|
|
1269
|
-
*
|
|
1270
|
-
* @public
|
|
1271
|
-
* @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
|
|
1272
|
-
*/
|
|
1273
|
-
build() {
|
|
1274
|
-
return {
|
|
1275
|
-
data: this,
|
|
1276
|
-
metadata: {
|
|
1277
|
-
active: this._active,
|
|
1278
|
-
ownerOnly: this._ownerOnly,
|
|
1279
|
-
permission: this._permission,
|
|
1280
|
-
ephemeralReply: this._ephemeralReply
|
|
1281
|
-
}
|
|
1282
|
-
};
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
1327
|
|
|
1286
1328
|
// src/core/components/component.base.ts
|
|
1287
1329
|
var ComponentBuilder = class {
|
|
@@ -1403,6 +1445,7 @@ exports.ComponentType = ComponentType;
|
|
|
1403
1445
|
exports.ContextMenuBuilder = ContextMenuBuilder;
|
|
1404
1446
|
exports.ContextMenuCommand = ContextMenuCommand;
|
|
1405
1447
|
exports.PermissionLevel = PermissionLevel;
|
|
1448
|
+
exports.SlashCommand = SlashCommand;
|
|
1406
1449
|
exports.Subcommand = Subcommand;
|
|
1407
1450
|
exports.SubcommandBuilder = SubcommandBuilder;
|
|
1408
1451
|
exports.TriviousClient = TriviousClient;
|