Is there a way to use Kord with Springboot to login, run a quick command, and logout for an endpoint

I currently have Kord configured with Springboot, although there's one slight obvious hitch in my plan. When the endpoint is called and Kord logs in, it suspends itself (as expected) until I disconnect. This means that Spring Boot just hangs and it doesn't actually complete the rest of the request until I manually stop Spring Boot. Ideally what I would like to do is: - Get Kord client object/login (this is where it suspends) - Create Forum Thread - Post message to forum thread, pinging a specific user - Logout - Send HTTP response back This is the current basic login I have now:
private suspend fun loginToDiscord(): Kord? {
return try {
val client = Kord(botToken)
client.login {
@OptIn(PrivilegedIntent::class)
intents += Intent.MessageContent
}
Logger.info("Logged in to Discord")
client
} catch (e: Exception) {
Logger.error("{}", e)
null
}
}
private suspend fun loginToDiscord(): Kord? {
return try {
val client = Kord(botToken)
client.login {
@OptIn(PrivilegedIntent::class)
intents += Intent.MessageContent
}
Logger.info("Logged in to Discord")
client
} catch (e: Exception) {
Logger.error("{}", e)
null
}
}
2 Replies
Flying Porygon
Flying PorygonOP12mo ago
I am really dumb, if I don't include the client.login{} it works fine. Thanks for being my unintentional rubber duck. 🤦‍♂️
LustigerLurch
LustigerLurch12mo ago
yes, you only need login if you want to get events from discord, sending requests works without that

Did you find this page helpful?