const { Client, GatewayIntentBits } = require('discord.js') const config = require('./config.json') const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions ] }) client.on('ready', () => { console.log('Ready!') }) client.login(config.TOKEN) const { readdirSync } = require('fs') client.commands = new Map() const commandsFiles = readdirSync('./commands').filter(file => file.endsWith('.js')) for (const file of commandsFiles) { const command = require(`./commands/${file}`) let data = command.data.toJSON() client.commands.set(data.name, command) } const handlersFiles = readdirSync('./Handlers').filter(file => file.endsWith('.js')) for (const file of handlersFiles) { require(`./Handlers/${file}`)(client) } client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return const command = client.commands.get(interaction.commandName) if (!command) return try { await command.execute(interaction) } catch (error) { console.error(error) await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }) } }) client.on('interactionCreate', async interaction => { if (!interaction.isButton()) return const button = client.buttons.get(interaction.customId) if (!button) return try { await button.execute(interaction) } catch (error) { console.error(error) await interaction.reply({ content: 'There was an error while executing this button!', ephemeral: true }) } }) client.on('interactionCreate', async interaction => { if (!interaction.isStringSelectMenu()) return const select = client.Selects.get(interaction.customId) if (!select) return try { await select.execute(interaction) } catch (error) { console.error(error) await interaction.reply({ content: 'There was an error while executing this select menu!', ephemeral: true }) } })