From ede50eedbb543e64211e54fce1812de77b9c7df6 Mon Sep 17 00:00:00 2001 From: MagM1go Date: Wed, 18 Sep 2024 20:29:54 +0800 Subject: [PATCH] whoopsie doopsie :3 nya --- .../kotlin/top/boticord/BotiCordClient.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main/kotlin/top/boticord/BotiCordClient.kt b/src/main/kotlin/top/boticord/BotiCordClient.kt index 356c4ac..7a819e8 100644 --- a/src/main/kotlin/top/boticord/BotiCordClient.kt +++ b/src/main/kotlin/top/boticord/BotiCordClient.kt @@ -108,6 +108,37 @@ public class BotiCordClient( websockets.listen { block(it) } } + + @OptIn(DelicateCoroutinesApi::class) + public suspend fun autopost( + botId: Long, + memberCount: Int?, + shardCount: Int? = null, + guildCount: Int? = null + ) { + GlobalScope.launch { + while (isActive) { + update(botId, memberCount, shardCount, guildCount) + delay(10_000L) + } + } + } + + @OptIn(DelicateCoroutinesApi::class) + public suspend fun autopost( + scope: CoroutineScope = GlobalScope, + botId: Long, + memberCount: Int?, + shardCount: Int? = null, + guildCount: Int? = null + ) { + scope.launch { + while (isActive) { + update(botId, memberCount, shardCount, guildCount) + delay(10_000L) + } + } + } } public suspend fun boticord(