const { Client, GatewayIntentBits, Collection } = require('discord.js'); const fs = require('fs'); const path = require('path'); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.commands = new Collection(); const commandHandler = require('./handlers/command-handler'); const eventHandler = require('./handlers/event-handler'); commandHandler(client); eventHandler(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 }); } }); const login = () => { client.login(process.env.DISCORD_BOT_TOKEN); } module.exports = { login, client };