forked from Stranger165/discord-rythem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
83 lines (77 loc) · 2.85 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
79
80
81
82
83
/**
* @INFO
* Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
* @INFO
* Work for Milrato Development | https://milrato.eu
* @INFO
* Please mention Him / Milrato Development, when using this Code!
* @INFO
*/
//Importing all needed Commands
const Discord = require("discord.js"); //this is the official discord.js wrapper for the Discord Api, which we use!
const colors = require("colors"); //this Package is used, to change the colors of our Console! (optional and doesnt effect performance)
const fs = require("fs"); //this package is for reading files and getting their inputs
//Creating the Discord.js Client for This Bot with some default settings ;) and with partials, so you can fetch OLD messages
const client = new Discord.Client({
messageCacheLifetime: 60,
fetchAllMembers: false,
messageCacheMaxSize: 10,
restTimeOffset: 0,
restWsBridgetimeout: 100,
disableEveryone: true,
partials: ['MESSAGE', 'CHANNEL', 'REACTION']
});
//Client variables to use everywhere
client.commands = new Discord.Collection(); //an collection (like a digital map(database)) for all your commands
client.aliases = new Discord.Collection(); //an collection for all your command-aliases
client.categories = fs.readdirSync("./commands/"); //categories
client.cooldowns = new Discord.Collection(); //an collection for cooldown commands of each user
//Loading files, with the client variable like Command Handler, Event Handler, ...
["command", "events"].forEach(handler => {
try{
require(`./handlers/${handler}`)(client);
}catch (e){
console.log(e)
}
});
["erela_js_handler", "erela_js_node_log"].forEach(handler => {
try{
require(`./handlers/lavalink/${handler}`)(client);
}catch (e){
console.log(e)
}
});
//login into the bot
client.login(require("./botconfig/config.json").token);
const Enmap = require("enmap")
client.settings = new Enmap({name: "settings", dataDir: "./database/settings"})
/**
* @INFO
* Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
* @INFO
* Work for Milrato Development | https://milrato.eu
* @INFO
* Please mention Him / Milrato Development, when using this Code!
* @INFO
*/
process.on("unhandledRejection", (reason, promise) => {
console.log("Unhandled Rejection at: " + promise)
console.log("Reason: " + reason)
})
process.on("uncaughtException", (err, origin) => {
console.log("Caught exception: " + err)
console.log("Origin: " + origin)
})
process.on('uncaughtExceptionMonitor', (err, origin) => {
console.log(err);
console.log("Origin: " + origin)
});
process.on('beforeExit', (code) => {
console.log('Process beforeExit event with code: ', code);
});
process.on('exit', (code) => {
console.log('Process exit event with code: ', code);
});
process.on('multipleResolves', (type, promise, reason) => {
console.log(type, promise, reason);
});