@@ -4,6 +4,7 @@ import com.kotlindiscord.kord.extensions.extensions.Extension
4
4
import dev.kord.common.annotation.KordExperimental
5
5
import dev.kord.common.annotation.KordUnsafe
6
6
import dev.kord.core.behavior.channel.edit
7
+ import dev.kord.core.kordLogger
7
8
import dev.racci.elixir.utils.GUILD_ID
8
9
import dev.racci.elixir.utils.MEMBER_COUNTER
9
10
import dev.racci.elixir.utils.STATUS_CHANNEL
@@ -14,6 +15,7 @@ import io.ktor.client.features.json.JsonFeature
14
15
import io.ktor.client.request.get
15
16
import kotlinx.coroutines.DelicateCoroutinesApi
16
17
import kotlinx.coroutines.GlobalScope
18
+ import kotlinx.coroutines.TimeoutCancellationException
17
19
import kotlinx.coroutines.delay
18
20
import kotlinx.coroutines.flow.count
19
21
import kotlinx.coroutines.launch
@@ -43,10 +45,17 @@ class StatChannels : Extension() {
43
45
44
46
while (loaded) {
45
47
// 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
50
59
}
51
60
// We only want to change the name if it needs changing
52
61
if (tStatus != null && status != tStatus.online) {
0 commit comments