-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanti-crash-v14.js
107 lines (90 loc) · 2.81 KB
/
anti-crash-v14.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
// programmed by bastian-js
// https://github.com/bastian-js/
// https://github.com/bastian-js/discord-anticrash-v13v14
const { EmbedBuilder, WebhookClient } = require("discord.js");
const { inspect } = require("util");
const webhook = new WebhookClient({
url: "",
});
module.exports = (client) => {
const embed = new EmbedBuilder().setColor("Red");
client.on("error", (err) => {
console.log(err);
embed
.setTitle("Discord API Error")
.setURL("https://discordjs.guide/popular-topics/errors.html#api-errors")
.setDescription(
`\`\`\`${inspect(err, { depth: 0 }).slice(0, 1000)}\`\`\``
)
.setTimestamp();
return webhook.send({ embeds: [embed] });
});
process.on("unhandledRejection", (reason, promise) => {
console.log(reason, "\n", promise);
embed
.setTitle("Unhandled Rejection/Catch")
.setURL("https://nodejs.org/api/process.html#event-unhandledrejection")
.addFields(
{
name: "Reason",
value: `\`\`\`${inspect(reason, { depth: 0 }).slice(0, 1000)}\`\`\``,
},
{
name: "Promise",
value: `\`\`\`${inspect(promise, { depth: 0 }).slice(0, 1000)}\`\`\``,
}
)
.setTimestamp();
return webhook.send({ embeds: [embed] });
});
process.on("uncaughtException", (err, origin) => {
console.log(err, "\n", origin);
embed
.setTitle("Uncaught Exception/Catch")
.setURL("https://nodejs.org/api/process.html#event-uncaughtexception")
.addFields(
{
name: "Error",
value: `\`\`\`${inspect(err, { depth: 0 }).slice(0, 1000)}\`\`\``,
},
{
name: "Origin",
value: `\`\`\`${inspect(origin, { depth: 0 }).slice(0, 1000)}\`\`\``,
}
)
.setTimestamp();
return webhook.send({ embeds: [embed] });
});
process.on("uncaughtExceptionMonitor", (err, origin) => {
console.log(err, "\n", origin);
embed
.setTitle("Uncaught Exception Monitor")
.setURL(
"https://nodejs.org/api/process.html#event-uncaughtexceptionmonitor"
)
.addFields(
{
name: "Error",
value: `\`\`\`${inspect(err, { depth: 0 }).slice(0, 1000)}\`\`\``,
},
{
name: "Origin",
value: `\`\`\`${inspect(origin, { depth: 0 }).slice(0, 1000)}\`\`\``,
}
)
.setTimestamp();
return webhook.send({ embeds: [embed] });
});
process.on("warning", (warn) => {
console.log(warn);
embed
.setTitle("Uncaught Exception Monitor Warning")
.setURL("https://nodejs.org/api/process.html#event-warning")
.addFields({
name: "Warning",
value: `\`\`\`${inspect(warn, { depth: 0 }).slice(0, 1000)}\`\`\``,
})
.setTimestamp();
return webhook.send({ embeds: [embed] });
});
};