Components

This class lets you create smart components such as buttons, select menus, and groups.

Every component can either be persistent or ephemeral, all components can be configured to:

  • Be used once

  • Have timeouts, a default timeout is set on ephemeral components, which can be overridden, or set by the timeout methods.

  • Have handlers

  • Have constraints (checks before the button can be used)

Except component groups which can only have their timeout configured, their default timeouts are the same as components.

Persistent components

  • Kept after restart

  • Handlers are methods; they can have arguments passed to them

  • Timeouts are also methods, additionally, they will be rescheduled when the bot restarts

Ephemeral components

  • Are deleted once the bot restarts

  • Handlers are closures, they can capture objects, but you shouldn't capture JDA entities

  • Timeouts are also closures, but are not rescheduled when restarting

Component groups

  • If deleted, all contained components are deleted

  • If one of the contained components is deleted, then all of its subsequent groups are also deleted

Note: Component groups cannot contain components with timeouts, you will need to disable the timeout on the components.

See also

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun deleteComponents(vararg components: IdentifiableComponent)
Link copied to clipboard
suspend fun deleteComponentsByIds(vararg ids: Int)
Link copied to clipboard
@JvmName(name = "deleteComponentsByIds")
fun deleteComponentsByIdsJava(vararg ids: Int)
@JvmName(name = "deleteComponentsByIds")
fun deleteComponentsByIdsJava(ids: Collection<Int>)
Link copied to clipboard
@JvmName(name = "deleteComponents")
fun deleteComponentsJava(vararg components: IdentifiableComponent)
@JvmName(name = "deleteComponents")
fun deleteComponentsJava(components: Collection<IdentifiableComponent>)
Link copied to clipboard
suspend fun deleteRows(components: Collection<LayoutComponent>)
Link copied to clipboard
@JvmName(name = "deleteRows")
fun deleteRowsJava(components: Collection<LayoutComponent>)
Link copied to clipboard
fun ephemeralButton(style: ButtonStyle, label: String? = null, emoji: Emoji? = null): EphemeralButtonBuilder
inline suspend fun ephemeralButton(style: ButtonStyle, label: String? = null, emoji: Emoji? = null, block: EphemeralButtonBuilder.() -> Unit): Button
Link copied to clipboard
@CheckReturnValue
fun group(vararg components: IGroupHolder): ComponentGroupFactory
Link copied to clipboard
fun persistentButton(style: ButtonStyle, label: String? = null, emoji: Emoji? = null): PersistentButtonBuilder
inline suspend fun persistentButton(style: ButtonStyle, label: String? = null, emoji: Emoji? = null, block: PersistentButtonBuilder.() -> Unit): Button