Files
JogyoGaori/index.js
2025-08-07 01:18:49 +09:00

41 lines
1.3 KiB
JavaScript

require('dotenv').config();
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const fs = require('fs');
const path = require('path');
const logger = require('./modules/colorfulLogger');
const { loadData } = require('./src/data/dataManager');
const { setupProcessHandlers } = require('./src/handlers/processHandlers');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
],
partials: [Partials.Channel],
});
// Load data and setup process handlers
loadData();
setupProcessHandlers(client);
// Load event handlers
const eventsPath = path.join(__dirname, 'src', '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));
}
}
logger.info('Attempting to log in with token...');
client.login(process.env.DISCORD_TOKEN).catch(e => {
logger.error(`Failed to login: ${e.message}`);
process.exit(1);
});