io.github.freya022.botcommands.api.components.AwaitableComponent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of BotCommands Show documentation
Show all versions of BotCommands Show documentation
A Kotlin-first (and Java) framework that makes creating Discord bots a piece of cake, using the JDA library.
The newest version!
package io.github.freya022.botcommands.api.components
import kotlinx.coroutines.TimeoutCancellationException
import net.dv8tion.jda.api.interactions.components.ComponentInteraction
interface AwaitableComponent : IdentifiableComponent {
/**
* Suspends until the component is used and all checks passed, and returns the event.
*
* @throws TimeoutCancellationException If the timeout set in the component builder has been reached
*/
@JvmSynthetic
suspend fun await(): T
}
/**
* Suspends until the component is used and all checks passed, and returns the event,
* or `null` if the timeout has been reached.
*/
@JvmSynthetic
suspend fun AwaitableComponent.awaitOrNull(): T? = try {
await()
} catch (e: TimeoutCancellationException) {
null
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy