EventWaiterBuilder

Builder for EventWaiter

Parameters

T

Type of the JDA event being awaited

Functions

Link copied to clipboard
abstract fun addPrecondition(precondition: Predicate<T>): EventWaiterBuilder<T>

Adds a precondition to this event waiter; the action won't be executed unless all your preconditions are met.

Link copied to clipboard
suspend fun <T : Event> EventWaiterBuilder<T>.await(): T

Suspends until the event waiter receives an event of the specified type, and all preconditions have passed.

Link copied to clipboard
abstract fun complete(): T

Blocks until the event waiter receives an event of the specified type, and all preconditions have passed.

Link copied to clipboard
abstract fun setOnCancelled(onCancelled: Runnable): EventWaiterBuilder<T>

Sets the consumer called after the event waiter has been canceled.

Link copied to clipboard

Sets the consumer called after the event waiter has "completed," i.e., it has either been successfully run, or been canceled, or has been timeout.

Link copied to clipboard
abstract fun setOnSuccess(onSuccess: Consumer<T>): EventWaiterBuilder<T>

Sets the consumer called after the event waiter has all its preconditions met and the task has not timeout nor been canceled.

Link copied to clipboard
abstract fun setOnTimeout(onTimeout: Runnable): EventWaiterBuilder<T>

Sets the consumer called when the event waiter has expired due to a timeout.

Link copied to clipboard
abstract fun setTimeout(timeout: Duration): EventWaiterBuilder<T>
open fun setTimeout(timeout: Long, timeoutUnit: TimeUnit): EventWaiterBuilder<T>

Sets the timeout for this event waiter; the action will no longer be usable after the time has elapsed.

Link copied to clipboard
abstract fun submit(): CompletableFuture<T>

Returns a CompletableFuture which is completed when the event waiter receives an event of the specified type, and all preconditions have passed.