-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (31 loc) · 1.3 KB
/
index.js
File metadata and controls
39 lines (31 loc) · 1.3 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
// Require necessary modules
const fs = require('fs');
const path = require('path');
const { Client, Collection } = require('discord.js');
const color = require('colors');
require('dotenv').config();
// Function to load commands and events
const {loadCommands} = require('./Src/Handlers/Loaders/loadCommands');
const {loadEvents} = require('./Src/Handlers/Loaders/loadEvents');
const { loadAntiCrash} = require("./Src/Handlers/antiCrash.js")
// Function to create client settings object
const clientSettingsObject = require('./Src/Functions/clientSettingsObject');
// Create a new Discord client
const client = new Client(clientSettingsObject());
// Set up collections for commands and events
client.slashCommands = new Collection();
client.events = new Collection();
// Read handlers directory synchronously and load each handler
const handlersDir = './Src/Handlers';
fs.readdirSync(handlersDir).forEach(handlerFile => {
const handlerPath = path.join(handlersDir, handlerFile);
});
// Log in to Discord using bot token from environment variables
client.login(process.env.token).then(() => {
// Load events, commands, and MongoDB connection
loadAntiCrash(client,color);
loadEvents(client, color);
loadCommands(client, color);
}).catch(error => {
console.error('Error logging in:', error);
});