-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
120 lines (111 loc) · 2.8 KB
/
index.js
File metadata and controls
120 lines (111 loc) · 2.8 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const { Client, Collection, MessageEmbed } = require("discord.js");
const client = new Client({
intents: 32767,
restTimeOffset: 0,
allowedMentions: {
parse: ["roles", "users"],
repliedUser: false,
},
});
module.exports = client;
client.commands = new Collection();
client.slashCommands = new Collection();
client.emo = require("./emojis");
client.developer = ["Your discord user ID"];
client.config = require("./config.js");
require("./handler")(client);
let errChannel = client.channels.cache.get(client.config.logchannel);
let toJSON = require("@stdlib/error-to-json");
process.on("unhandledRejection", (reason, p) => {
let error = toJSON(reason);
console.log(reason);
let embed = new MessageEmbed()
.setAuthor({
name: `${error.name}`,
iconURL: client.user.displayAvatarURL({
dynamic: true,
}),
})
.setTitle(`unhandledRejection`)
.setDescription(`\`\`\`js\n${trim(error.stack, 2045)}\n\`\`\``)
.addFields(
{
name: "Reason",
value: `\`\`\`cs\n#${trim(error.message, 506)}\n(code: ${trim(
error.code,
506
)})\n\`\`\``,
inline: true,
},
{
name: "Path",
value: `\`\`\`bash\n#${trim(error.path, 1018)}\n\`\`\``,
inline: true,
}
)
.setTimestamp()
.setColor("RED")
.setFooter({
text: `httpStatus: ${error.httpStatus}`,
});
errChannel.send({
embeds: [embed],
});
});
process.on("uncaughtException", (err, origin) => {
console.log(err, origin);
let embed = new MessageEmbed()
.setAuthor({
name: `${client.user.username} Error Catcher`,
iconURL: client.user.displayAvatarURL({
dynamic: true,
}),
})
.setTitle(`uncaughtException`)
.addFields({
name: "Error",
value: `\`\`\`js\n${trim(err, 1018)}\n\`\`\``,
})
.setTimestamp()
.setColor("RED")
.setFooter({
text: `[ AntiCrash ]`,
});
errChannel.send({
embeds: [embed],
});
});
process.on("multipleResolves", (type, promise, reason) => {
console.log(type, promise, reason);
let embed = new MessageEmbed()
.setAuthor({
name: `${client.user.username} Error Catcher`,
iconURL: client.user.displayAvatarURL({
dynamic: true,
}),
})
.setTitle(`uncaughtException`)
.addFields(
{
name: "Reason",
value: `\`\`\`js\n${trim(reason, 1018)}\n\`\`\``,
},
{
name: "Type",
value: `\`\`\`js\n${trim(type, 1018)}\n\`\`\``,
}
)
.setTimestamp()
.setColor("RED")
.setFooter({
text: `[ AntiCrash ]`,
});
errChannel.send({
embeds: [embed],
});
});
function trim(str, max) {
if (!str) str = "No output recived.";
return str?.length > max ? `${str?.slice(0, max - 3)}...` : str;
}
client.login(client.config.token);