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