@@ -4,6 +4,7 @@ import com.kotlindiscord.kord.extensions.extensions.Extension
44import dev.kord.common.annotation.KordExperimental
55import dev.kord.common.annotation.KordUnsafe
66import dev.kord.core.behavior.channel.edit
7+ import dev.kord.core.kordLogger
78import dev.racci.elixir.utils.GUILD_ID
89import dev.racci.elixir.utils.MEMBER_COUNTER
910import dev.racci.elixir.utils.STATUS_CHANNEL
@@ -14,6 +15,7 @@ import io.ktor.client.features.json.JsonFeature
1415import io.ktor.client.request.get
1516import kotlinx.coroutines.DelicateCoroutinesApi
1617import kotlinx.coroutines.GlobalScope
18+ import kotlinx.coroutines.TimeoutCancellationException
1719import kotlinx.coroutines.delay
1820import kotlinx.coroutines.flow.count
1921import kotlinx.coroutines.launch
@@ -43,10 +45,17 @@ class StatChannels : Extension() {
4345
4446 while (loaded) {
4547 // Time it out in 1.5 seconds so we don't end up blocked
46- val tStatus = withTimeoutOrNull<Query ?>(1500 .milliseconds) {
47- try {
48- return @withTimeoutOrNull client.get(" https://mcapi.xdefcon.com/server/$STATUS_SERVER /status/json" )
49- } catch (ignored: ServerResponseException ) { return @withTimeoutOrNull null }
48+ val tStatus: Query ? = try {
49+ withTimeoutOrNull(1500 .milliseconds) {
50+ try {
51+ return @withTimeoutOrNull client.get(" https://mcapi.xdefcon.com/server/$STATUS_SERVER /status/json" )
52+ } catch (ignored: ServerResponseException ) {
53+ return @withTimeoutOrNull null
54+ }
55+ }
56+ } catch (ignored: TimeoutCancellationException ) {
57+ kordLogger.warn { " Timeout while checking server status" }
58+ null
5059 }
5160 // We only want to change the name if it needs changing
5261 if (tStatus != null && status != tStatus.online) {
0 commit comments