Files
src
.gitignore
package.json
README.md
Code
113 6,190
src/bot.js
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
const chalk = require('chalk');
const path = require('path');
const config = require('./config');
const CommandHandler = require('./handlers/CommandHandler');
const EventHandler = require('./handlers/EventHandler');
const ComponentHandler = require('./handlers/ComponentHandler');
const Database = require('./database/Database');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildScheduledEvents,
GatewayIntentBits.AutoModerationConfiguration,
GatewayIntentBits.AutoModerationExecution,
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.User,
Partials.GuildMember,
],
allowedMentions: {
parse: ['users', 'roles'],
repliedUser: false,
},
});
client.commands = new Collection();
client.cooldowns = new Collection();
client.musicQueues = new Collection();
client.giveaways = new Collection();
client.tickets = new Collection();
client.automodData = new Collection();
client.config = config;
async function init() {
try {
console.log(chalk.blue('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
console.log(chalk.cyan(' 🤖 AllInOne Discord Bot — Starting...'));
console.log(chalk.blue('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
client.db = new Database(config.dbPath);
await client.db.init();
console.log(chalk.green(' ✅ Database initialized'));
const commandHandler = new CommandHandler(client);
await commandHandler.load();
console.log(chalk.green(` ✅ Commands loaded: ${client.commands.size}`));
const eventHandler = new EventHandler(client);
await eventHandler.load();
console.log(chalk.green(' ✅ Events loaded'));
const componentHandler = new ComponentHandler(client);
componentHandler.init();
console.log(chalk.green(' ✅ Component handler initialized'));
await client.login(config.token);
} catch (err) {
console.error(chalk.red('[FATAL] Initialization failed:'), err);
process.exit(1);
}
}
process.on('unhandledRejection', (err) => {
console.error(chalk.red('[ERROR] Unhandled rejection:'), err);
});
process.on('uncaughtException', (err) => {
console.error(chalk.red('[ERROR] Uncaught exception:'), err);
});
init();
module.exports = client;