Skip to content

Commit 90598a1

Browse files
committed
Adds direct mention to developer
1 parent d25437f commit 90598a1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BOT_TOKEN=
22

33
CHANNELS='{"DEV":{"WIKI": "<DEV_WIKI_CHANNEL_ID>", "HIIQ": "<DEV_HIIQ_CHANNEL_ID>"}, "PROD":{"WIKI": "<PROD_WIKI_CHANNEL_ID>"}}'
4-
4+
ALERT_USER_ID='00000000000000000' # Replace with your Discord user ID
55
PROD_URL=
66
PROD_API_URL=
77

src/services/wikiUpdates.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,21 @@ export default class WikiUpdates {
114114
console.log(
115115
`🚨 Sending error notification to ${channelType} channel for ${errorCode}`,
116116
)
117+
118+
const alertUserId = process.env.ALERT_USER_ID
119+
120+
const mentionText = alertUserId ? `<@${alertUserId}> ` : ''
121+
122+
const messageContent = `${mentionText}`
123+
117124
await channel.send({
125+
content: messageContent,
118126
embeds: [
119127
await this.messageApiErrorStyle(link, errorCode, channelType),
120128
],
121129
})
130+
131+
console.log('✅ Message sent successfully')
122132
}
123133
} catch (error) {
124134
console.error(`❌ Failed to send error notification:`, error)
@@ -243,7 +253,6 @@ export default class WikiUpdates {
243253
`Error ${errorCode}: API Request to ${link} failed. Attempt ${count + 1}/${maxRetries}`,
244254
)
245255

246-
247256
if (count >= maxRetries - 1) {
248257
await this.notifyError(count + 1, channelType, link, errorCode)
249258
throw new Error(
@@ -332,6 +341,16 @@ export default class WikiUpdates {
332341

333342
if (previousStatus && !previousStatus.isHealthy) {
334343
console.log(`🎉 API ${channelType} has recovered!`)
344+
const channelId =
345+
channelType === ChannelTypes.DEV
346+
? this.CHANNEL_IDS.DEV.WIKI
347+
: this.CHANNEL_IDS.PROD.WIKI
348+
const channel = client.channels.cache.get(channelId) as TextChannel
349+
if (channel) {
350+
await channel.send(
351+
`✅ **RECOVERY** - ${channelType} API is back online! 🎉`,
352+
)
353+
}
335354
}
336355
}
337356
}

0 commit comments

Comments
 (0)