const { EmbedBuilder, InteractionType } = require("discord.js"); const { readdirSync } = require("fs"); module.exports = { name: 'interactionCreate', execute: async(interaction) => { let client = interaction.client; if(interaction.isButton()) { const button = client.buttons.get(interaction.customId); if(!button) return try { await button.execute(client,interaction); } catch (error) { console.error(error); if(interaction.deferred) { interaction.editReply({embeds: [new MessageEmbed().setDescription('There was an error executing this button!').setColor('2f3136').setFooter({text: `Button executed by ${interaction.user.tag}`}).setTimestamp()]}) } else { await interaction.reply({embeds: [new MessageEmbed().setDescription('There was an error executing this button!').setColor('2f3136').setFooter({text: `Button executed by ${interaction.user.tag}`}).setTimestamp()], ephemeral: true}); } } } if (!interaction.type == InteractionType.ApplicationCommand) return; if(interaction.user.bot) return; readdirSync('./src/commands').forEach(file => { const command = require(`../../src/commands/${file}`); if(interaction.commandName.toLowerCase() === command.data.name.toLowerCase()) { command.run(client, interaction) } }) }}