Skip to content

Commit

Permalink
Attempt again to fix the status ping
Browse files Browse the repository at this point in the history
  • Loading branch information
NoComment1105 committed Nov 6, 2024
1 parent 8cf0f74 commit 13e64ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.hyacinthbots.lilybot.extensions.utility.commands

import dev.kordex.core.extensions.Extension
import dev.kordex.core.utils.envOrNull
import dev.kordex.core.utils.scheduling.Scheduler
import dev.kordex.core.utils.scheduling.Task
import io.github.oshai.kotlinlogging.KotlinLogging
import io.ktor.client.HttpClient
import io.ktor.client.request.post
import org.hyacinthbots.lilybot.utils.STATUS_ENV
import io.ktor.client.*
import io.ktor.client.request.*
import kotlin.time.Duration.Companion.seconds

class StatusPing : Extension() {
Expand All @@ -18,18 +18,18 @@ class StatusPing : Extension() {

private val client = HttpClient {}

private val statusEnv = envOrNull("STATUS_URL")

private val logger = KotlinLogging.logger("Status ping")

override suspend fun setup() {
if (STATUS_ENV != null) {
if (statusEnv != null) {
task = scheduler.schedule(30.seconds, repeat = true, callback = ::post)
}
}

private suspend fun post() {
logger.debug { "Pinging!" }
if (STATUS_ENV != null) {
client.post(STATUS_ENV)
client.post(statusEnv!!)
}
}
}
2 changes: 0 additions & 2 deletions src/main/kotlin/org/hyacinthbots/lilybot/utils/_Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ val SENTRY_DSN = envOrNull("SENTRY_DSN")
/** The environment the bot is being run in. production or development. */
val ENVIRONMENT = env("ENVIRONMENT")

val STATUS_ENV = envOrNull("STATUS_URL")

const val HYACINTH_GITHUB: String = "https://github.com/HyacinthBots"

0 comments on commit 13e64ee

Please sign in to comment.