const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); module.exports = { category: 'dev', data: new SlashCommandBuilder() .setName('reload') .setDescription('Reloads a command.') .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .addStringOption(option => option.setName('command') .setDescription('The command to reload.') .setRequired(true)), async execute(interaction) { if (!interaction.member.permissions.has(PermissionFlagsBits.Administrator)) { return interaction.reply({ content: '❌ Only administrators can use this command.', embeds: [embed] }); } const commandName = interaction.options.getString('command', true).toLowerCase(); const command = interaction.client.commands.get(commandName); if (!command) { return interaction.reply({ content: `There is no command with name \`${commandName}\`!`, embeds: [embed] }); } delete require.cache[require.resolve(`../${command.category}/${command.data.name}.js`)]; try { const newCommand = require(`../${command.category}/${command.data.name}.js`); interaction.client.commands.set(newCommand.data.name, newCommand); await interaction.reply({ content: `✅ Command \`${newCommand.data.name}\` was reloaded!`, }); } catch (error) { console.error(error); await interaction.reply({ content: `❌ Error while reloading \`${command.data.name}\`:\n\`${error.message}\``, embeds: [embed] }); } }, };