const { Client, CommandInteraction, InteractionType } = require("discord.js"); const { ApplicationCommand } = InteractionType; const Reply = require("../../Systems/Reply"); const { owners } = require("../../Storage/owners.json"); module.exports = { name: "interactionCreate", /** * @param {CommandInteraction} interaction * @param {Client} client */ async execute(interaction, client) { const { user, guild, commandName, member, type } = interaction; if (!guild || user.bot) return; if (type !== ApplicationCommand) return; const command = client.commands.get(commandName); //If command doesn't exist if (!command) return ( Reply( interaction, "❌", `An error ocurred while running the command!`, true ) && client, command.delete(commandName) ); //Check User Permissions (UserPerms) if (command.UserPerms && command.UserPerms.length !== 0) if (!member.permissions.has(command.UserPerms)) return Reply( interaction, "❌", `You need \`${command.UserPerms.join( ", " )}\` permission(s) to execute this command!`, true ); //Checking Bot Permissions (BotPerms) if (command.BotPerms && command.BotPerms.length !== 0) if (!guild.members.me.permissions.has(command.BotPerms)) return Reply( interaction, "❌", `I need \`${command.BotPerms.join( ", " )}\` permission(s) to execute this command!`, true ); // Under Maintenance Commands (maintenance) if (command.maintenance) { if (!owners.includes(interaction.user.id)) { return Reply( interaction, "❌", "This command is on maintenance please try later, Thank you!", true ); } } //Owner Only Command (ownerOnly) if (command.ownerOnly) { if (!owners.includes(interaction.user.id)) { return Reply( interaction, "❌", "Only the Bot Developers are allowed to run this command!", true ); } } command.execute(interaction, client); }, };