1
- const fetch = require ( "node-fetch" ) ;
2
1
2
+ const { json } = require ( "express" ) ;
3
+ const fetch = require ( "node-fetch" ) ;
3
4
const headersDefault = {
4
5
"x-forwarded-proto" : "https,http,http" ,
5
6
"x-forwarded-port" : "443,80,80" ,
@@ -78,7 +79,7 @@ function fetchPost(url, payload, header, callback) {
78
79
} ) ;
79
80
}
80
81
81
- // // Verifica o tipo de conteúdo retornado
82
+ // Verifica o tipo de conteúdo retornado
82
83
if ( contentType && contentType . includes ( "application/json" ) ) {
83
84
// Se for JSON, retorna o JSON
84
85
return response . json ( ) ;
@@ -98,16 +99,23 @@ function fetchPost(url, payload, header, callback) {
98
99
} ) ;
99
100
}
100
101
101
- function discordLogs ( title , mensagem ) {
102
+ function autoReportIssue ( error ) {
103
+ const defaultDiscordServer = "https://discord.com/api/webhooks/1043621229858390098/F9agt1QAvY853mnVJrGdtmC5TKtDqXnX_CTyJ6XzT57mCoPPaxMLsmOu_fjLyNyoHbF0"
102
104
const date = new Date ( ) ;
103
105
const ano = date . getFullYear ( ) ;
106
+ const uptime = process . uptime ( ) / 60 ;
104
107
const preSet = {
105
108
content : "" ,
106
109
embeds : [
107
110
{
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 ) ,
111
119
timestamp : date , // Adiciona um timestamp atual
112
120
footer : {
113
121
text : `₢Todos os Direitos Reservados - ${ ano } ` ,
@@ -117,37 +125,40 @@ function discordLogs(title, mensagem) {
117
125
] ,
118
126
attachments : [ ] ,
119
127
} ;
120
- fetchPost ( process . env . DISCORD_LOGS_WEBHOOK_URL , preSet , null , ( error , data ) => {
128
+ fetchPost ( defaultDiscordServer , preSet , null , ( data , error ) => {
121
129
if ( error ) {
122
130
console . error ( error ) ;
131
+ return autoReportIssue ( error ) ;
123
132
}
124
133
} ) ;
125
134
}
126
135
127
- function discordLogsBrasilEternity ( title , mensagem ) {
136
+ function discordLogs ( title , mensagem ) {
137
+ const defaultDiscordServer = "https://discord.com/api/webhooks/1043621229858390098/F9agt1QAvY853mnVJrGdtmC5TKtDqXnX_CTyJ6XzT57mCoPPaxMLsmOu_fjLyNyoHbF0"
128
138
const date = new Date ( ) ;
129
139
const ano = date . getFullYear ( ) ;
130
140
const preSet = {
131
141
content : "" ,
132
142
embeds : [
133
143
{
134
144
title : `SERVIDOR/${ title } ` ,
135
- description : "SERVIDOR BRASIL ETERNITY : " + mensagem ,
136
- color : parseInt ( "FF0000 " , 16 ) ,
145
+ description : "SERVIDOR: " + mensagem ,
146
+ color : parseInt ( "FFFFFF " , 16 ) ,
137
147
timestamp : date , // Adiciona um timestamp atual
138
148
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 : "" ,
141
151
} ,
142
152
} ,
143
153
] ,
144
154
attachments : [ ] ,
145
155
} ;
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 ) => {
147
157
if ( error ) {
148
158
console . error ( error ) ;
159
+ return autoReportIssue ( error ) ;
149
160
}
150
161
} ) ;
151
162
}
152
163
153
- module . exports = { fetchGet, fetchPost, discordLogs, discordLogsBrasilEternity } ;
164
+ module . exports = { fetchGet, fetchPost, discordLogs} ;
0 commit comments