From 08d0ca4dfbb04818564e089f29e4cfea7f3309ee Mon Sep 17 00:00:00 2001 From: DarkAtra Date: Mon, 15 Apr 2024 20:21:28 +0200 Subject: [PATCH] fix: message the user when a newly created monitor throws errors --- README.md | 4 +++- .../darkatra/vrising/discord/commands/AddServerCommand.kt | 2 +- .../discord/serverstatus/ServerStatusMonitorService.kt | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 20ea487..59a648f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/main/kotlin/de/darkatra/vrising/discord/commands/AddServerCommand.kt b/src/main/kotlin/de/darkatra/vrising/discord/commands/AddServerCommand.kt index 7d34c7b..50ff648 100644 --- a/src/main/kotlin/de/darkatra/vrising/discord/commands/AddServerCommand.kt +++ b/src/main/kotlin/de/darkatra/vrising/discord/commands/AddServerCommand.kt @@ -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() } } } diff --git a/src/main/kotlin/de/darkatra/vrising/discord/serverstatus/ServerStatusMonitorService.kt b/src/main/kotlin/de/darkatra/vrising/discord/serverstatus/ServerStatusMonitorService.kt index c1c1ab7..09ef066 100644 --- a/src/main/kotlin/de/darkatra/vrising/discord/serverstatus/ServerStatusMonitorService.kt +++ b/src/main/kotlin/de/darkatra/vrising/discord/serverstatus/ServerStatusMonitorService.kt @@ -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