//Boring boring initialization stuff const fs = require('node:fs'); const path = require('node:path'); const { Op } = require('sequelize'); const { Users, ItemShop } = require('./dbObjects.js'); const helpers = require('./helpers.js'); const { Client, codeBlock, Collection, GatewayIntentBits } = require('discord.js'); const { token } = require('./config.json'); const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] }); //Handle commands client.commands = new Collection(); client.cooldowns = new Collection(); //Command Loading const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for(const folder of commandFolders) { const commandPath = path.join(foldersPath, folder); const commandFiles = fs.readdirSync(commandPath).filter(file => file.endsWith('.js')); for (const file of commandFiles) { const filePath = path.join(commandPath, file); const command = require(filePath); if ('data' in command && 'execute' in command) { client.commands.set(command.data.name, command); } else { console.log(`WARN: Command at ${filePath} is missing 'data' and/or 'execute' properties.`); } } } //Event Loading const eventsPath = path.join(__dirname, 'events'); const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js')); for (const file of eventFiles) { const filePath = path.join(eventsPath, file); const event = require(filePath); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); } else { client.on(event.name, (...args) => event.execute(...args)); } } client.login(token);