-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (49 loc) · 1.99 KB
/
Copy pathindex.js
File metadata and controls
59 lines (49 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require('dotenv').config();
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
const mongoose = require('mongoose');
const fs = require('fs');
const path = require('path');
const connectDB = require('./db/connect');
console.log(`
╔══════════════════════════════════════════╗
║ ✨ CELESTIA Discord Bot ║
║ v2.0.0 ║
║ Pokémon · Gacha · Cross-Platform ║
╚══════════════════════════════════════════╝
`);
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction]
});
global.bot = client;
async function start() {
// 1. Connect to MongoDB (same DB as WhatsApp bot)
await connectDB();
// 2. Load command and event handlers
require('./handlers/commandHandler')(client);
require('./handlers/eventHandler')(client);
// 3. Initialize stores that need DB access
const tosStore = require('./store/tosStore');
await tosStore.loadAll();
const giveawayStore = require('./store/giveawayStore');
// 4. Login
client.login(process.env.TOKEN).catch(err => {
if (err.message.includes('disallowed intents')) {
console.error('\u001b[31m[ERROR] Disallowed Intents!\u001b[0m');
console.error('Please enable the following intents in the Discord Developer Portal:');
console.error('1. Message Content Intent');
} else {
console.error('Login Error:', err);
}
});
// 5. Resume active giveaways once the client is ready
client.once('ready', async () => {
await giveawayStore.init(client);
});
}
start();