Files
src
index.js
package.json
Code
52 2,826
src/bot.js
const {
Client,
GatewayIntentBits,
Partials,
Collection,
ActivityType,
} = require('discord.js');
const { initDatabase } = require('./database/schema');
const { loadCommands } = require('./handlers/commandHandler');
const { loadSlashCommands } = require('./handlers/slashHandler');
const { loadEvents } = require('./handlers/eventHandler');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildWebhooks,
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.GuildMember,
Partials.User,
],
});
client.prefixCommands = new Collection();
client.slashCommands = new Collection();
client.cooldowns = new Collection();
client.config = {
prefix: ',',
ownerIds: process.env.OWNER_IDS?.split(',').map(id => id.trim()).filter(Boolean) || [],
website: 'https://plop-bot.xyz',
color: {
primary: 0x5865F2,
success: 0x57F287,
error: 0xED4245,
warning: 0xFEE75C,
premium: 0xF1C40F,
neutral: 0x2B2D31,
},
};
client.on('error', err => console.error('[Client] Error:', err));
client.on('warn', msg => console.warn('[Client] Warn:', msg));
async function startBot() {
console.log('[Bot] Initializing...');
await initDatabase();
await loadCommands(client);
await loadSlashCommands(client);
await loadEvents(client);
await client.login(process.env.BOT_TOKEN);
}
module.exports = { client, startBot };