forked from krushna06/Fusion-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
58 lines (51 loc) · 1.68 KB
/
index.js
File metadata and controls
58 lines (51 loc) · 1.68 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
import { Client, GatewayIntentBits, Partials } from 'discord.js';
import config from './config/config.json' with { type: 'json' };
import { loadCommands } from './handlers/commandHandler.js';
import { loadEvents } from './handlers/eventHandler.js';
import { initDatabase } from './database/connect.js';
import { info, error, success } from './utils/logger.js';
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
],
partials: [Partials.Message, Partials.Channel, Partials.GuildMember, Partials.User]
});
async function init() {
try {
info('Starting bot initialization...');
await initDatabase();
try {
info('Loading commands...');
const commands = await loadCommands(client);
success(`Commands loaded successfully`);
} catch (cmdErr) {
error('Error loading commands', cmdErr);
throw cmdErr;
}
try {
info('Loading events...');
await loadEvents(client);
success('Events loaded successfully');
} catch (evtErr) {
error('Error loading events', evtErr);
throw evtErr;
}
try {
info('Logging in to Discord...');
// debug('Using token: ' + (config.TOKEN ? 'Token exists' : 'Token is missing'));
await client.login(config.TOKEN);
success(`Logged in successfully as ${client.user.tag}`);
} catch (loginErr) {
error('Error logging in to Discord', loginErr);
throw loginErr;
}
success('Bot initialization completed successfully');
} catch (err) {
error('Error during bot initialization', err);
process.exit(1);
}
}
init();