commonMain.entity.component.ActionRowComponent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kord-core Show documentation
Show all versions of kord-core Show documentation
Idiomatic Kotlin Wrapper for The Discord API
package dev.kord.core.entity.component
import dev.kord.common.entity.ComponentType
import dev.kord.common.entity.optional.orEmpty
import dev.kord.core.cache.data.ComponentData
/**
* A non-interactive container component for other types of component.
*/
public class ActionRowComponent(override val data: ComponentData) : Component {
override val type: ComponentType.ActionRow
get() = ComponentType.ActionRow
/**
* All [Component]s that are nested inside this action row.
*/
public val components: List
get() = data.components.orEmpty().map { Component(it) }
/**
* The [ButtonComponent]s of this action row that are not a link button, indexed by their
* [customId][ButtonComponent.customId] (which is always present on these buttons).
*
* @see components
*/
public val interactionButtons: Map
get() = components.filterIsInstance()
.filter { it.customId != null }
.associateBy { it.customId!! }
/**
* The [ButtonComponent]s of this action row that are a link button. [url][ButtonComponent.url] is always present on
* these buttons.
*
* @see components
*/
public val linkButtons: List
get() = components.filterIsInstance().filter { it.url != null }
/**
* The [SelectMenuComponent]s of this action row, indexed by their [customId][SelectMenuComponent.customId].
*
* @see components
*/
public val selectMenus: Map
get() = components.filterIsInstance().associateBy { it.customId }
/**
* The [TextInputComponent]s of this action row, indexed by their [customId][TextInputComponent.customId].
*
* @see components
*/
public val textInputs: Map
get() = components.filterIsInstance().associateBy { it.customId }
override fun toString(): String = "ActionRowComponent(data=$data)"
}