Skip to content

Commit

Permalink
fix: message the user when a newly created monitor throws errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkAtra committed Apr 15, 2024
1 parent 4d6c5cd commit 08d0ca4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ bot:

### Using the bot as a service

Since most people were having issues hosting the bot, i decided to provide it as a free service going forward.
Since most people were having issues hosting the bot, I decided to provide it as a free service going forward.
Feel free to invite the bot to your discord server and use it as you please: https://discord.com/oauth2/authorize?client_id=982682186207592470.
Please [reach out](https://discord.gg/KcMcYKa6Nt) if something doesn't work for you.

If your server is unreachable for more than 180 attempts, with 1 attempt per minute, your status monitor is automatically deactivated.

> **Disclaimer**
> This service is provided to the best of my ability. I can not guarantee that the bot is available 24/7.
> I also reserve the right to prohibit you from using the bot at any time if there is any suspicion of misuse.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class AddServerCommand(

interaction.deferEphemeralResponse().respond {
content = """Added monitor with id '${serverStatusMonitorId}' for '${hostname}:${queryPort}' to channel '$channelId'.
|It may take some time until the status message appears.""".trimMargin()
|It may take a minute for the status message to appear.""".trimMargin()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ class ServerStatusMonitorService(
}
}

if (serverStatusMonitor.currentEmbedMessageId == null && serverStatusMonitor.currentFailedAttempts == 1) {
val channel = getDiscordChannel(kord, serverStatusMonitor.discordChannelId)
channel.createMessage(
"""The status check for your status monitor '${serverStatusMonitor.id}' failed.
|Please check the detailed error message using the get-server-details command.""".trimMargin()
)
}

if (botProperties.maxFailedAttempts != 0 && serverStatusMonitor.currentFailedAttempts >= botProperties.maxFailedAttempts) {
logger.warn("Disabling server monitor '${serverStatusMonitor.id}' because it exceeded the max failed attempts.")
serverStatusMonitor.status = ServerStatusMonitorStatus.INACTIVE
Expand Down

0 comments on commit 08d0ca4

Please sign in to comment.