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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'util';
2
- import { Collection, SlashCommandSubcommandBuilder, Client, REST, Routes, SlashCommandBuilder, ContextMenuCommandBuilder, InteractionContextType, ButtonInteraction, ModalSubmitInteraction } from 'discord.js';
2
+ import { Collection, SlashCommandSubcommandBuilder, Client, REST, Routes, ContextMenuCommandBuilder, SlashCommandBuilder, InteractionContextType, ButtonInteraction, ModalSubmitInteraction } from 'discord.js';
3
3
  export { ClientEvents, Collection } from 'discord.js';
4
4
  import { existsSync, promises } from 'fs';
5
5
  import path, { dirname, join, resolve } from 'path';
@@ -719,6 +719,10 @@ var interactionCreate_default = {
719
719
  requiredPermission
720
720
  );
721
721
  if (!hasPermission2) return;
722
+ if (!("execute" in command)) {
723
+ await command.reply(interaction, { content: "Command does not have a way to execute! Ensure the command is a SlashCommand or ContextMenuCommand!" });
724
+ return;
725
+ }
722
726
  await command.reply(interaction, { content: "Processing command..." });
723
727
  if (interaction.isChatInputCommand() && command.isSlashCommand()) {
724
728
  await command.execute(client, interaction);
@@ -951,6 +955,94 @@ var TriviousClient = class extends Client {
951
955
  return this._options.rolePermissions ?? {};
952
956
  }
953
957
  };
958
+ var ContextMenuCommand = class extends Command {
959
+ /**
960
+ * Base command handler.
961
+ *
962
+ * @public
963
+ * @async
964
+ * @param {TriviousClient} client
965
+ * @param {ContextMenuCommandInteraction} interaction
966
+ * @returns {*}
967
+ */
968
+ async execute(client, interaction) {
969
+ const { run, metadata } = this;
970
+ const memberHasPermission = await this.validateGuildPermission(
971
+ client,
972
+ interaction,
973
+ metadata.permission,
974
+ false
975
+ );
976
+ if (memberHasPermission) await run(client, interaction);
977
+ }
978
+ };
979
+ var ContextMenuBuilder = class extends ContextMenuCommandBuilder {
980
+ _active = true;
981
+ _ownerOnly = false;
982
+ _permission = 0 /* USER */;
983
+ _ephemeralReply = false;
984
+ /**
985
+ * Set the command as disabled.
986
+ *
987
+ * @public
988
+ * @returns {this}
989
+ */
990
+ disable() {
991
+ this._active = false;
992
+ return this;
993
+ }
994
+ /**
995
+ * Set the command as owner only.
996
+ *
997
+ * @public
998
+ * @returns {this}
999
+ */
1000
+ setOwnerOnly() {
1001
+ this._permission = 5 /* BOT_OWNER */;
1002
+ this._ownerOnly = true;
1003
+ return this;
1004
+ }
1005
+ /**
1006
+ * Set the permission level required to run the command.
1007
+ *
1008
+ * @public
1009
+ * @param {PermissionLevel} permission
1010
+ * @returns {this}
1011
+ */
1012
+ setPermission(permission) {
1013
+ this._permission = permission;
1014
+ return this;
1015
+ }
1016
+ /**
1017
+ * Set the interaction as ephemeral.
1018
+ *
1019
+ * @public
1020
+ * @returns {this}
1021
+ */
1022
+ setEphemeralReply() {
1023
+ this._ephemeralReply = true;
1024
+ return this;
1025
+ }
1026
+ /**
1027
+ * Build the builder
1028
+ *
1029
+ * @public
1030
+ * @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
1031
+ */
1032
+ build() {
1033
+ return {
1034
+ data: this,
1035
+ metadata: {
1036
+ active: this._active,
1037
+ ownerOnly: this._ownerOnly,
1038
+ permission: this._permission,
1039
+ ephemeralReply: this._ephemeralReply
1040
+ }
1041
+ };
1042
+ }
1043
+ };
1044
+
1045
+ // src/core/commands/command.base.ts
954
1046
  var Command = class {
955
1047
  /**
956
1048
  * Returns whether the command is a SlashCommand.
@@ -960,7 +1052,7 @@ var Command = class {
960
1052
  * @returns {this is SlashCommand}
961
1053
  */
962
1054
  isSlashCommand() {
963
- return this.data instanceof SlashCommandBuilder;
1055
+ return this.data instanceof SlashCommandBuilder && this instanceof SlashCommand;
964
1056
  }
965
1057
  /**
966
1058
  * Returns whether the command is a ContextMenuCommand.
@@ -970,7 +1062,7 @@ var Command = class {
970
1062
  * @returns {this is ContextMenuCommand}
971
1063
  */
972
1064
  isContextMenuCommand() {
973
- return this.data instanceof ContextMenuCommandBuilder;
1065
+ return this.data instanceof ContextMenuCommandBuilder && this instanceof ContextMenuCommand;
974
1066
  }
975
1067
  /**
976
1068
  * Returns JSON of the command builder.
@@ -1024,6 +1116,16 @@ var Command = class {
1024
1116
  }
1025
1117
  };
1026
1118
  var SlashCommand = class extends Command {
1119
+ /**
1120
+ * Optional function to run if the SlashCommand has no subcommands or for extra fuctionality.
1121
+ *
1122
+ * @abstract
1123
+ * @type {?(
1124
+ * client: TriviousClient,
1125
+ * interaction: ChatInputCommandInteraction
1126
+ * ) => Promise<void>}
1127
+ */
1128
+ run;
1027
1129
  /**
1028
1130
  * General handler for the command and its subcommand, if applicable.
1029
1131
  *
@@ -1230,92 +1332,6 @@ var Subcommand = class {
1230
1332
  await interaction.reply(newOptions);
1231
1333
  }
1232
1334
  };
1233
- var ContextMenuCommand = class extends Command {
1234
- /**
1235
- * Base command handler.
1236
- *
1237
- * @public
1238
- * @async
1239
- * @param {TriviousClient} client
1240
- * @param {ContextMenuCommandInteraction} interaction
1241
- * @returns {*}
1242
- */
1243
- async execute(client, interaction) {
1244
- const { run, metadata } = this;
1245
- const memberHasPermission = await this.validateGuildPermission(
1246
- client,
1247
- interaction,
1248
- metadata.permission,
1249
- false
1250
- );
1251
- if (memberHasPermission) await run(client, interaction);
1252
- }
1253
- };
1254
- var ContextMenuBuilder = class extends ContextMenuCommandBuilder {
1255
- _active = true;
1256
- _ownerOnly = false;
1257
- _permission = 0 /* USER */;
1258
- _ephemeralReply = false;
1259
- /**
1260
- * Set the command as disabled.
1261
- *
1262
- * @public
1263
- * @returns {this}
1264
- */
1265
- disable() {
1266
- this._active = false;
1267
- return this;
1268
- }
1269
- /**
1270
- * Set the command as owner only.
1271
- *
1272
- * @public
1273
- * @returns {this}
1274
- */
1275
- setOwnerOnly() {
1276
- this._permission = 5 /* BOT_OWNER */;
1277
- this._ownerOnly = true;
1278
- return this;
1279
- }
1280
- /**
1281
- * Set the permission level required to run the command.
1282
- *
1283
- * @public
1284
- * @param {PermissionLevel} permission
1285
- * @returns {this}
1286
- */
1287
- setPermission(permission) {
1288
- this._permission = permission;
1289
- return this;
1290
- }
1291
- /**
1292
- * Set the interaction as ephemeral.
1293
- *
1294
- * @public
1295
- * @returns {this}
1296
- */
1297
- setEphemeralReply() {
1298
- this._ephemeralReply = true;
1299
- return this;
1300
- }
1301
- /**
1302
- * Build the builder
1303
- *
1304
- * @public
1305
- * @returns {{ data: ContextMenuBuilder; metadata: ContextMenuMetadata; }}
1306
- */
1307
- build() {
1308
- return {
1309
- data: this,
1310
- metadata: {
1311
- active: this._active,
1312
- ownerOnly: this._ownerOnly,
1313
- permission: this._permission,
1314
- ephemeralReply: this._ephemeralReply
1315
- }
1316
- };
1317
- }
1318
- };
1319
1335
 
1320
1336
  // src/core/components/component.base.ts
1321
1337
  var ComponentBuilder = class {