diff --git a/src/main/kotlin/top/boticord/BotiCordClient.kt b/src/main/kotlin/top/boticord/BotiCordClient.kt index 94668e3..356c4ac 100644 --- a/src/main/kotlin/top/boticord/BotiCordClient.kt +++ b/src/main/kotlin/top/boticord/BotiCordClient.kt @@ -98,7 +98,7 @@ public class BotiCordClient( IllegalArgumentException::class, SerializationException::class ) - private inline fun decode(data: String) = + private inline fun decode(data: String): T = json.decodeFromString(parseResultFromString(data)) @Throws(IllegalStateException::class) @@ -110,6 +110,15 @@ public class BotiCordClient( } } +public suspend fun boticord( + block: suspend BotiCordClient.() -> T +): T = BotiCordClient(null).block() + +public suspend fun boticord( + token: String, + block: suspend BotiCordClient.() -> T +): T = BotiCordClient(token).block() + @OptIn(DelicateCoroutinesApi::class) public fun boticord( scope: CoroutineScope = GlobalScope, @@ -133,4 +142,7 @@ public fun boticordBlocking( ): T = runBlocking { BotiCordClient(token).block() } public fun boticord(token: String): BotiCordClient = - BotiCordClient(token) \ No newline at end of file + BotiCordClient(token) + +public fun boticord(): BotiCordClient = + BotiCordClient(null) \ No newline at end of file