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. You should instead make a variable from the entity's ID, outside the lambda, then capture it.

Parameters

timeout

The duration before timeout

handler

The handler to run when the component expires


@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. You should instead make a variable from the entity's ID, outside the lambda, then capture it.

Parameters

timeout

The value of the timeout

timeoutUnit

The unit of the timeout

handler

The handler to run when the component expires


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 should instead make a variable from the entity's ID, outside the lambda, then capture it.

Parameters

timeout

The duration of the timeout

handler

The handler to run when the component expires