timeout

@CheckReturnValue
open fun timeout(timeout: Duration, handler: Runnable): T(source)

Sets the timeout on this component, invalidating the component on expiration, and running the given timeout handler.

Note: Components inside groups cannot have timeouts.

Timeout cancellation

The timeout will be canceled once a component has been deleted, including if the component was set to a single use.

Component deletion

  • If the component is a group, then all of its owned components will also be deleted.

  • If the component is inside a group, then all the group's components will also be deleted.

Captured entities

Pay extra attention to not capture JDA entities in such handlers as they can stop being updated by JDA.

Parameters

timeout

The duration before timeout

handler

The handler to run when the button is clicked


@CheckReturnValue
open fun timeout(timeout: Long, timeoutUnit: TimeUnit, handler: Runnable): T(source)

Sets the timeout on this component, invalidating the component on expiration, and running the given timeout handler.

Note: Components inside groups cannot have timeouts.

Timeout cancellation

The timeout will be canceled once a component has been deleted, including if the component was set to a single use.

Component deletion

  • If the component is a group, then all of its owned components will also be deleted.

  • If the component is inside a group, then all the group's components will also be deleted.

Captured entities

Pay extra attention to not capture JDA entities in such handlers as they can stop being updated by JDA.

Parameters

timeout

The value of the timeout

timeoutUnit

The unit of the timeout

handler

The handler to run when the button is clicked


abstract fun timeout(timeout: Duration, handler: suspend () -> Unit): T(source)

Sets the timeout on this component, invalidating the component on expiration, and running the given timeout handler.

Note: Components inside groups cannot have timeouts.

Timeout cancellation

The timeout will be canceled once a component has been deleted, including if the component was set to a single use.

Component deletion

  • If the component is a group, then all of its owned components will also be deleted.

  • If the component is inside a group, then all the group's components will also be deleted.

Captured entities

Pay extra attention to not capture JDA entities in such handlers as they can stop being updated by JDA.

You can still use User.ref and such from JDA-KTX to attenuate this issue, even though it will return you an outdated object if the entity cannot be found anymore.

Parameters

timeout

The duration of the timeout

handler

The handler to run when the button is clicked