@@ -93,6 +93,68 @@ export default class WikiUpdates {
9393 return errorEmbed
9494 }
9595
96+ private async messagePrediqtErrorStyle ( url : string , errorCode : string ) {
97+ let description = `π Error code: ${ errorCode } `
98+ let color : number = 0xff0000
99+ let title = `π PrediQT API is down π`
100+
101+ if ( errorCode === 'TIMEOUT' ) {
102+ description = `π PredIQt API is unresponsive (timeout after 30 seconds)\nπ The prediction market service is not responding within the expected timeframe.`
103+ color = 0xff6600
104+ title = `π PredIQt API Timeout`
105+ } else if ( errorCode === 'HEALTH_CHECK_FAILED' ) {
106+ description = `π PredIQt API health check failed - service may be down\nπ Automated monitoring detected an issue with the PredIQt API endpoint.`
107+ color = 0xcc0000
108+ title = `π PredIQt API Health Check Failed`
109+ }
110+
111+ const errorEmbed = new EmbedBuilder ( )
112+ . setColor ( color )
113+ . setTitle ( title )
114+ . setURL ( url )
115+ . setDescription ( description )
116+ . addFields ( [
117+ { name : 'π Service' , value : 'PredIQt' , inline : true } ,
118+ { name : 'π URL' , value : url , inline : false } ,
119+ { name : 'β° Time' , value : new Date ( ) . toLocaleString ( ) , inline : true } ,
120+ ] )
121+ . setTimestamp ( )
122+ . setFooter ( {
123+ text : 'EP Bot PrediQT Monitor' ,
124+ } )
125+ return errorEmbed
126+ }
127+
128+ async notifyPrediqtError ( errorCode : string ) {
129+ try {
130+ const webhookUrl = this . PROD_ALARMS_WEBHOOK
131+
132+ if ( ! webhookUrl ) {
133+ console . error ( `β Webhook URL not configured for PrediQT alerts` )
134+ return
135+ }
136+
137+ const webhook = new WebhookClient ( { url : webhookUrl } )
138+
139+ console . log ( `π Sending PrediQT error notification for ${ errorCode } ` )
140+
141+ const alertUserId = process . env . ALERT_USER_ID
142+ const mentionText = alertUserId ? `<@${ alertUserId } > ` : ''
143+
144+ await webhook . send ( {
145+ content : mentionText ,
146+ embeds : [
147+ await this . messagePrediqtErrorStyle ( this . PREDIQT_API_URL , errorCode ) ,
148+ ] ,
149+ } )
150+
151+ console . log ( 'β
PrediQT alert sent successfully' )
152+ webhook . destroy ( )
153+ } catch ( error ) {
154+ console . error ( `β Failed to send PrediQT error notification:` , error )
155+ }
156+ }
157+
96158 async notifyError (
97159 count : number ,
98160 channelType : ChannelTypes ,
@@ -418,13 +480,8 @@ export default class WikiUpdates {
418480 )
419481
420482 if ( ! currentStatus ?. alertSent ) {
421- console . log ( `π¨ Sending initial error alert for PrediQT` )
422- await this . notifyError (
423- 1 ,
424- ChannelTypes . PROD ,
425- this . PREDIQT_API_URL ,
426- 'HEALTH_CHECK_FAILED' ,
427- )
483+ console . log ( `π Sending initial error alert for PrediQT` )
484+ await this . notifyPrediqtError ( 'HEALTH_CHECK_FAILED' )
428485
429486 this . apiHealthStatus . set ( 'PREDIQT' , {
430487 isHealthy : false ,
@@ -440,12 +497,12 @@ export default class WikiUpdates {
440497 )
441498
442499 if ( previousStatus && ! previousStatus . isHealthy && previousStatus . alertSent ) {
443- console . log ( `π PrediQT API has recovered!` )
500+ console . log ( `π PrediQT API has recovered!` )
444501 const webhookUrl = this . PROD_ALARMS_WEBHOOK
445502 if ( webhookUrl ) {
446503 const webhook = new WebhookClient ( { url : webhookUrl } )
447504 await webhook . send (
448- `β
**RECOVERY** - PrediQT API is back online! π ` ,
505+ `π **RECOVERY** - PrediQT API is back online! π ` ,
449506 )
450507 webhook . destroy ( )
451508 }
0 commit comments