-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
104 lines (89 loc) · 3.1 KB
/
index.js
File metadata and controls
104 lines (89 loc) · 3.1 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const { Client, Collection, GatewayIntentBits, Partials, EmbedBuilder } = require('discord.js');
require('dotenv').config();
const config = require('./config.json');
const { Database } = require("quickmongo");
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.DirectMessages,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildScheduledEvents,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildModeration
],
partials: [
Partials.Channel,
Partials.Message,
Partials.GuildMember,
Partials.GuildScheduledEvent,
Partials.Reaction,
Partials.ThreadMember,
Partials.User
],
presence: {
activities: [{name: `.help`, type: 2}],
status: "online" //online/idle/dnd
},
allowedMentions:{
repliedUser: false,
parse: ['users','roles','everyone']
}
});
// Increasing Event Listener Size
client.setMaxListeners(0);
Events.defaultMaxListeners = 0;
process.env.UV_THREADPOOL_SIZE = OS.cpus().length;
module.exports = client;
client.afk = new Collection();
client.slashCommands = new Collection();
client.commands = new Collection();
client.aliases = new Collection();
client.categories = fs.readdirSync("./Commands/");
client.context = new Collection();
client.events = new Collection();
client.db = new Database(config.DB);
client.db.connect();
//CONNECT TO DATABASE
(async () => {
await require("./Database/connect")();
})();
//connecting handlers
["command", "event"].forEach(handler => {
require(`./handlers/bot/${handler}`)(client);
});
// Crash - Prevention
process.on('unhandledRejection', (err, cause) => {
//console.log(`[Uncaught Exception]: ${err}`.bold.brightGreen);
client.webhook?.send({embeds: [
new EmbedBuilder()
.setAuthor({name: `Unhandled Rejection`})
.setDescription(`\`\`\`js\n${err.message}\n\`\`\`\n**Stack**\n\`\`\`\n${err.stack}\n\`\`\``)
]}).catch(e => {});
});
process.on('uncaughtException', err => {
// console.log(`[Uncaught Exception] ${err.message}`.bold.brightGreen);
client.webhook?.send({embeds: [
new EmbedBuilder()
.setAuthor({name: `Unhandled Rejection`})
.setDescription(`\`\`\`js\n${err.message}\n\`\`\`\n**Stack**\n\`\`\`\n${err.stack}\n\`\`\``)
]}).catch(e => {});
});
console.log()
// Logging in Discord
client.login(config.TOKEN)
.catch(e => console.log(`[DISCORD API] ${e}`.red))