if (message.author.id == "431099770212319232") { if (!args[0]) { const embed = new MessageEmbed() .setDescription("You forgot to give a `command name` to reload") .setColor('RANDOM') .setTimestamp() message.channel.send({ embeds: [embed] }) console.log(message.client.commands) } else { const name = args[0].toLowerCase(); const command = message.client.commands.get(name); if (!command) { return message.channel.send(`There is no command with name or alias ${name}`) } else if (command || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(name))) { const fs = require('fs'); const commandFolders = fs.readdirSync('./commands'); for (const folder of commandFolders) { const CommandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('.js')); for (const file of CommandFiles) { delete require.cache[require.resolve(`../${folder}/${file}`)]; try { const newCommand = require(`../${folder}/${file}`); const del = client.commands.delete(name, newCommand); console.log(del) const timerInterval = setInterval(() => { const result = client.commands.set(name, newCommand); console.log(result) }, 1500) setTimeout(() => { clearInterval(timerInterval) }, 1600) return message.reply(`Command \`${name}\` was reloaded.`); } catch (error) { const embed = new MessageEmbed() .setDescription(`Something went wrong with command \`${name}\``) .addField("Error:", `${error.message}`) .setTimestamp() .setColor('RANDOM') message.channel.send({ embeds: [embed] }) } } } } }