forked from Emerald-Services/SupportBot
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
Latest commit
79 lines (64 loc) · 2.01 KB
/
Copy pathindex.js
File metadata and controls
79 lines (64 loc) · 2.01 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
// ___ _ ___ _
// / __> _ _ ___ ___ ___ _ _ _| |_ | . > ___ _| |_
// \__ \| | || . \| . \/ . \| '_> | | | . \/ . \ | |
// <___/`___|| _/| _/\___/|_| |_| |___/\___/ |_|
// |_| |_|
//
// SupportBot created by Emerald Services
// Installed with MIT License
//
// Discord Support: https://emeraldsrv.dev/discord
// Community Resources: https://community.emeraldsrv.dev
constfs=require("fs");
constpath=require("path");
constyaml=require("js-yaml");
constsupportbot=yaml.load(
fs.readFileSync("./Configs/supportbot.yml","utf8")
);
constClient=require("./Structures/Client.js");
constclient=newClient({
intents: ['Guilds','GuildMembers','GuildMessages','MessageContent']
});
constAPIServer=require("./API/server.js");
client.start(supportbot.General.Token);
client.once('clientReady',()=>{
constapi=newAPIServer(client);
api.start();
});
// SupportBot - New Logging System
constlogTypes=["Output","Warn","Error"];
if(!fs.existsSync("./Logs")){
fs.mkdirSync("./Logs");
}
logTypes.forEach((type)=>{
constdir=`./Logs/${type}`;
if(!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
});
functionlogToFile(type,data){
constdate=newDate().toISOString().split("T")[0];
constfile=path.join(`./Logs/${type}`,`${type}-${date}.log`);
fs.appendFileSync(file,`[${newDate().toISOString()}] ${data}\n`);
}
constorigLog=console.log;
console.log=(...args)=>{
origLog(...args);
logToFile("Output",args.join(" "));
};
constorigWarn=console.warn;
console.warn=(...args)=>{
origWarn(...args);
logToFile("Warn",args.join(" "));
};
constorigError=console.error;
console.error=(...args)=>{
origError(...args);
logToFile("Error",args.join(" "));
};
process.on("unhandledRejection",(reason)=>{
console.error("Unhandled Rejection:",reason);
});
process.on("uncaughtException",(err)=>{
console.error("Uncaught Exception:",err);
});