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-jvm Show documentation
Show all versions of kord-core-jvm Show documentation
Idiomatic Kotlin Wrapper for The Discord API
The newest version!
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 or premium 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 [ButtonComponent]s of this action row that are a premium button. [skuId][ButtonComponent.skuId] is always
* present on these buttons.
*
* @see components
*/
public val premiumButtons: List
get() = components.filterIsInstance().filter { it.skuId != 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)"
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy