const Timeout = new Set() const Discord = require('discord.js'); const humanizeDuration = require("humanize-duration"); const config = require('../../config.json'); const db = require("quick.db"); module.exports = async(client, interaction) => { if (interaction.isCommand() || interaction.isContextMenu()) { if (!client.slash.has(interaction.commandName)) return; if (!interaction.guild) return; const command = client.slash.get(interaction.commandName) await interaction.deferReply(); try { if (command.timeout) { if (Timeout.has(`${interaction.user.id}${command.name}`)) { const embed = new Discord.MessageEmbed() .setTitle('You are in timeout!') .setDescription(`<:icons_Wrong:904673964490620969> | You need to wait **${humanizeDuration(command.timeout, { round: true })}** to use command again.`) .setColor("BLURPLE") return interaction.reply({ embeds: [embed], ephemeral: true }) } } if (command.permissions) { if (!interaction.member.permissions.has(command.permissions)) { const embed = new Discord.MessageEmbed() .setTitle('Missing Permission') .setDescription(`<:icons_Wrong:904673964490620969> | You need \`${command.permissions}\` to use this command.`) .setColor("BLURPLE") .setTimestamp() return interaction.reply({ embeds: [embed], ephemeral: true }) } } if (command.devs) { if (!config.ownersID.includes(interaction.user.id)) { const embed = new Discord.MessageEmbed() .setTitle('Developer Only') .setDescription(`<:icons_Wrong:904673964490620969> | Only developers can use this command.`) .setColor("BLURPLE") .setTimestamp() return interaction.reply({ embeds: [embed], ephemeral: true }) } } if (command.ownerOnly) { if (interaction.user.id !== interaction.guild.ownerId) { const embed = new Discord.MessageEmbed() .setTitle('Server Owner Only') .setDescription(`<:icons_Wrong:904673964490620969> | Only server owner can use this command.`) .setColor("BLURPLE") .setTimestamp() return interaction.reply({ embeds: [embed], ephemeral: true }) } } command.run(interaction, client); /*client.statcord.postCommand(command.name, interaction.user.id);*/ const embedlog = new Discord.MessageEmbed() .setTitle('Command Used') .setThumbnail(client.user.displayAvatarURL()) .addField("• User", `${interaction.user}\n(${interaction.user.tag})`, true) .addField("• Server", `${interaction.guild.name}\n(${interaction.guild.id})`,true) .addField("• Command", `/${command.name}`,true) .setColor("BLURPLE") .setFooter({ text: "Status Bot" }) .setTimestamp() let gu = client.guilds.cache.get("924995925598937118") let ch = gu.channels.cache.get("924995926244884480") ch.send({ embeds: [embedlog] }) Timeout.add(`${interaction.user.id}${command.name}`) setTimeout(() => { Timeout.delete(`${interaction.user.id}${command.name}`) }, command.timeout); } catch (error) { console.error(error); const embed = new Discord.MessageEmbed() .setTitle('Command Error') .setDescription(`<:icons_Wrong:904673964490620969> | There was an error while loading command.`) .setColor("BLURPLE") .setTimestamp() return interaction.reply({ embeds: [embed], ephemeral: true }) } } }