-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
78 lines (68 loc) · 2.3 KB
/
index.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const {Client, Collection, GatewayIntentBits, Partials, EmbedBuilder} = require('discord.js');
require('dotenv').config();
const fs = require('fs');
const OS = require('os');
const Events = require('events');
require('colors');
// Initialzing Client
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildScheduledEvents,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Channel,
Partials.Reaction,
Partials.User
],
presence: {
activities: [{name: `Djs Template`, type: 0}],
status: "online" //online/idle/dnd
}
});
// Increasing Event Listener Size
client.setMaxListeners(0);
Events.defaultMaxListeners = 0;
process.env.UV_THREADPOOL_SIZE = OS.cpus().length;
//CONNECT TO DATABASE
(async () => {
await require("./Database/connect")();
})();
//exporting client
module.exports = client;
//defining useful collection
client.slashCommands = new Collection();
client.commands = new Collection();
client.aliases = new Collection();
client.categories = fs.readdirSync("./Commands/");
client.context = new Collection();
client.events = 0;
//connecting handlers
["command", "event","slash"].forEach(handler => {
require(`./handlers/bot/${handler}`)(client);
});
// Crash - Prevention
process.on('unhandledRejection', (err, cause) => {
console.log(`[Uncaught Exception]: ${err}`.bold.brightGreen);
});
process.on('uncaughtException', err => {
console.log(`[Uncaught Exception] ${err.message}`.bold.brightGreen)
});
// Logging in Discord
client.login(process.env.token)
.catch(e => console.log(`[DISCORD API] ${e}`.red))