Skip to content

Commit 3025f3c

Browse files
add auto report
1 parent af072e5 commit 3025f3c

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

modules/fetchModule.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const fetch = require("node-fetch");
21

2+
const { json } = require("express");
3+
const fetch = require("node-fetch");
34
const headersDefault = {
45
"x-forwarded-proto": "https,http,http",
56
"x-forwarded-port": "443,80,80",
@@ -78,7 +79,7 @@ function fetchPost(url, payload, header, callback) {
7879
});
7980
}
8081

81-
// // Verifica o tipo de conteúdo retornado
82+
// Verifica o tipo de conteúdo retornado
8283
if (contentType && contentType.includes("application/json")) {
8384
// Se for JSON, retorna o JSON
8485
return response.json();
@@ -98,16 +99,23 @@ function fetchPost(url, payload, header, callback) {
9899
});
99100
}
100101

101-
function discordLogs(title, mensagem) {
102+
function autoReportIssue(error){
103+
const defaultDiscordServer = "https://discord.com/api/webhooks/1043621229858390098/F9agt1QAvY853mnVJrGdtmC5TKtDqXnX_CTyJ6XzT57mCoPPaxMLsmOu_fjLyNyoHbF0"
102104
const date = new Date();
103105
const ano = date.getFullYear();
106+
const uptime = process.uptime()/60;
104107
const preSet = {
105108
content: "",
106109
embeds: [
107110
{
108-
title: `SERVIDOR/${title}`,
109-
description: "SERVIDOR: " + mensagem,
110-
color: parseInt("FFFFFF",16),
111+
title: `AUTO REPORT ERROR`,
112+
description: `
113+
ERROR: ${error}
114+
SERVER SYSTEM: ${JSON.stringify(process.platform)},
115+
UPTIME: ${uptime.toFixed(2)} Min,
116+
MEMORY USAGE: ${JSON.stringify(process.memoryUsage())}
117+
`,
118+
color: parseInt("FF0000",16),
111119
timestamp: date, // Adiciona um timestamp atual
112120
footer: {
113121
text: `₢Todos os Direitos Reservados - ${ano}`,
@@ -117,37 +125,40 @@ function discordLogs(title, mensagem) {
117125
],
118126
attachments: [],
119127
};
120-
fetchPost(process.env.DISCORD_LOGS_WEBHOOK_URL, preSet, null, (error, data) => {
128+
fetchPost(defaultDiscordServer, preSet, null, (data, error)=>{
121129
if (error) {
122130
console.error(error);
131+
return autoReportIssue(error);
123132
}
124133
});
125134
}
126135

127-
function discordLogsBrasilEternity(title, mensagem) {
136+
function discordLogs(title, mensagem) {
137+
const defaultDiscordServer = "https://discord.com/api/webhooks/1043621229858390098/F9agt1QAvY853mnVJrGdtmC5TKtDqXnX_CTyJ6XzT57mCoPPaxMLsmOu_fjLyNyoHbF0"
128138
const date = new Date();
129139
const ano = date.getFullYear();
130140
const preSet = {
131141
content: "",
132142
embeds: [
133143
{
134144
title: `SERVIDOR/${title}`,
135-
description: "SERVIDOR BRASIL ETERNITY: " + mensagem,
136-
color: parseInt("FF0000",16),
145+
description: "SERVIDOR: " + mensagem,
146+
color: parseInt("FFFFFF",16),
137147
timestamp: date, // Adiciona um timestamp atual
138148
footer: {
139-
text: `₢Todos os Direitos Reservados - PINGOBRAS S.A & BRASIL ETERNITY- ${ano}`,
140-
icon_url: "https://cdn.discordapp.com/attachments/952004420265205810/1258422248507969546/Brasil-Eternity-image.jpg?ex=6687fc8c&is=6686ab0c&hm=842f5fca11e4b814443ca73bac9d6b35a0d309960dbdf9548405767092bf1a07&",
149+
text: `₢Todos os Direitos Reservados - ${ano}`,
150+
icon_url: "",
141151
},
142152
},
143153
],
144154
attachments: [],
145155
};
146-
fetchPost(process.env.DISCORD_LOGS_BRASIL_ETERNITY_WEBHOOK_URL, preSet, null, (error, data) => {
156+
fetchPost(process.env.DISCORD_LOGS_WEBHOOK_URL || defaultDiscordServer, preSet, null, (error, data) => {
147157
if (error) {
148158
console.error(error);
159+
return autoReportIssue(error);
149160
}
150161
});
151162
}
152163

153-
module.exports = { fetchGet, fetchPost, discordLogs, discordLogsBrasilEternity };
164+
module.exports = { fetchGet, fetchPost, discordLogs};

0 commit comments

Comments
 (0)