Files
commands
data
events
utils
.gitignore
config.json
deploy-commands.js
index.js
package.json
README.md
SETUP.md
Code
51 8,559
index.js
const { Client, GatewayIntentBits, Collection, Partials } = require('discord.js');
const { readdirSync } = require('fs');
const { join } = require('path');
const config = require('./config.json');
const Database = require('./utils/database');
require('dotenv').config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildPresences
],
partials: [
Partials.Channel,
Partials.Message,
Partials.User,
Partials.GuildMember
]
});
client.commands = new Collection();
client.config = config;
client.db = new Database();
const loadCommands = () => {
const commandFolders = readdirSync(join(__dirname, 'commands'));
for (const folder of commandFolders) {
const commandFiles = readdirSync(join(__dirname, 'commands', folder)).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(join(__dirname, 'commands', folder, file));
if (command.data && command.execute) {
client.commands.set(command.data.name, command);
console.log(`✅ Loaded command: ${command.data.name}`);
}
}
}
};
const loadEvents = () => {
const eventFiles = readdirSync(join(__dirname, 'events')).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(join(__dirname, 'events', file));
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
console.log(`✅ Loaded event: ${event.name}`);
}
};
console.log('🚀 Starting Bape Bot...');
loadCommands();
loadEvents();
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
client.login(process.env.DISCORD_TOKEN);