-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
48 lines (38 loc) · 1.37 KB
/
index.ts
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
// Importing necessary modules
const { Client, Collection, Intents } = require('discord.js');
const Discord = require('discord.js');
require('dotenv').config();
// Importing custom module
const loader = require('./loader');
// Define the intents to be used
const myIntents = new Intents();
myIntents.add(
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGES,
);
// Client configuration
const client = new Client({
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
intents: myIntents
});
// Exporting client for use in other modules
module.exports = client;
// Setting fields for the client object
client.discord = Discord; // Assigning the Discord.js module to the client object
client.commands = new Collection(); // Creating an empty collection to hold commands
client.slashCommands = new Collection(); // Creating an empty collection to hold slash commands
// Loading all slash commands
loader.loadSlashCommands(client, "slashCommands");
// Loading all events
loader.loadEvents(client, "events");
// Error handling
process.on("uncaughtException", (err) => {
// console.log("Uncaught Exception: " + err);
console.log("CHUJH");
});
process.on("unhandledRejection", (reason: any, promise) => {
console.log("[REJECTION] Promise ", promise, " reason: ", reason.message);
});
// Logging the bot into Discord
client.login(process.env.BOT_TOKEN);