-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (45 loc) · 1.47 KB
/
index.js
File metadata and controls
52 lines (45 loc) · 1.47 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
require('dotenv').config();
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const logger = require('./Utils/Logger');
const commandHandler = require('./Handlers/CommandHandler');
const eventHandler = require('./Handlers/EventHandler');
const componentHandler = require('./Handlers/ComponentHandler');
const databaseHandler = require('./Handlers/Database');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
client.commands = new Collection();
client.cooldowns = new Collection();
client.buttons = new Collection();
client.selectMenus = new Collection();
client.modals = new Collection();
// Error Handling
process.on('unhandledRejection', (reason) => {
logger.error('Unhandled Rejection:', reason);
});
process.on('uncaughtException', (err) => {
logger.error('Uncaught Exception:', err);
});
// Load Handlers then Login
(async () => {
logger.info('Starting Discord Bot Initialization...');
try {
await databaseHandler();
eventHandler(client);
componentHandler(client);
await commandHandler(client);
// Login AFTER all handlers are registered
await client.login(process.env.DISCORD_TOKEN);
} catch (error) {
logger.error('Initialization Error:', error);
}
})();
/**
* Credits: Arpan | Discord: @arpandevv
* Please do star the repo
*/