-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanti-crash-v13.js
141 lines (132 loc) · 4.47 KB
/
anti-crash-v13.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// programmed by bastian-js
// https://github.com/bastian-js/
// https://github.com/bastian-js/discord-anticrash-v13v14
const chalk = require("chalk"); // Importing Chalk from Chalk
const config = require("../../config.json");
const { MessageEmbed, WebhookClient } = require("discord.js"); // Importing MessageEmbed from Discord.js
const { inspect } = require("util");
const s = new WebhookClient({
id: "",
token: "",
});
module.exports = (client) => {
client.on("error", (err) => {
// const a = client.channels.cache.get(config.ERROR_LOG_CHANNEL)
console.log(err);
const ErrorEmbed = new MessageEmbed()
.setTitle("Error")
.setURL("https://discordjs.guide/popular-topics/errors.html#api-errors")
.setColor("#2F3136")
.setDescription(`\`\`\`${inspect(error, { depth: 0 })}\`\`\``)
.setTimestamp();
return s.send({
embeds: [ErrorEmbed],
});
});
process.on("unhandledRejection", (reason, p) => {
// const b = client.channels.cache.get(config.ERROR_LOG_CHANNEL)
console.log(
chalk.yellow("——————————[Unhandled Rejection/Catch]——————————\n"),
reason,
p
);
const unhandledRejectionEmbed = new MessageEmbed()
.setTitle("**🟥 There was an Unhandled Rejection/Catch 🟥**")
.setURL("https://nodejs.org/api/process.html#event-unhandledrejection")
.setColor("RED")
.addField(
"Reason",
`\`\`\`${inspect(reason, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.addField(
"Promise",
`\`\`\`${inspect(p, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.setTimestamp();
return s.send({
embeds: [unhandledRejectionEmbed],
});
});
process.on("uncaughtException", (err, origin) => {
// const c = client.channels.cache.get(config.ERROR_LOG_CHANNEL)
console.log(err, origin);
const uncaughtExceptionEmbed = new MessageEmbed()
.setTitle("**🟥There was an Uncaught Exception/Catch 🟥**")
.setColor("RED")
.setURL("https://nodejs.org/api/process.html#event-uncaughtexception")
.addField(
"Error",
`\`\`\`${inspect(err, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.addField(
"Origin",
`\`\`\`${inspect(origin, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.setTimestamp();
return s.send({
embeds: [uncaughtExceptionEmbed],
});
});
process.on("uncaughtExceptionMonitor", (err, origin) => {
// const d = client.channels.cache.get(config.ERROR_LOG_CHANNEL)
console.log(err, origin);
const uncaughtExceptionMonitorEmbed = new MessageEmbed()
.setTitle("**🟥 There was an Uncaught Exception Monitor 🟥**")
.setColor("RED")
.setURL(
"https://nodejs.org/api/process.html#event-uncaughtexceptionmonitor"
)
.addField(
"Error",
`\`\`\`${inspect(err, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.addField(
"Origin",
`\`\`\`${inspect(origin, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.setTimestamp();
return s.send({
embeds: [uncaughtExceptionMonitorEmbed],
});
});
process.on("multipleResolves", (type, promise, reason) => {
// const e = client.channels.cache.get(config.ERROR_LOG_CHANNEL)
console.log(type, promise, reason);
const multipleResolvesEmbed = new MessageEmbed()
.setTitle("**🟥 There was an Multiple Resolve 🟥**")
.setURL("https://nodejs.org/api/process.html#event-multipleresolves")
.setColor("RED")
.addField(
"Type",
`\`\`\`${inspect(type, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.addField(
"Promise",
`\`\`\`${inspect(promise, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.addField(
"Reason",
`\`\`\`${inspect(reason, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.setTimestamp();
return s.send({
embeds: [multipleResolvesEmbed],
});
});
process.on("warning", (warn) => {
// const f = client.channels.cache.get(config.ERROR_LOG_CHANNEL)
console.log(warn);
const warningEmbed = new MessageEmbed()
.setTitle("**🟥 There was an Uncaught Exception Monitor Warning 🟥**")
.setColor("RED")
.setURL("https://nodejs.org/api/process.html#event-warning")
.addField(
"Warn",
`\`\`\`${inspect(warn, { depth: 0 })}\`\`\``.substring(0, 1000)
)
.setTimestamp();
return s.send({
embeds: [warningEmbed],
});
});
};