Skip to content

Commit

Permalink
add TextInputComponent list retrival property
Browse files Browse the repository at this point in the history
  • Loading branch information
HopeBaron committed Feb 12, 2022
1 parent 992fac9 commit 4b96ef5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/src/main/kotlin/entity/component/ActionRowComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class ActionRowComponent(override val data: ComponentData) : Component {
public val selectMenus: List<SelectMenuComponent>
get() = components.filterIsInstance<SelectMenuComponent>()

/**
* The [TextInputComponent] that are nested inside this component.
*/
public val textInputs: List<TextInputComponent>
get() = components.filterIsInstance<TextInputComponent>()

override fun toString(): String = "ActionRowComponent(data=$data)"

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TextInputComponent(override val data: TextInputComponentData) : Com
/**
* The custom identifier for this Text Input.
*/
public val customId: String? get() = data.customId.value
public val customId: String get() = data.customId.value!!

/**
* The minimum text length of the text input, if present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import dev.kord.core.Kord
import dev.kord.core.cache.data.InteractionData
import dev.kord.core.entity.component.ActionRowComponent
import dev.kord.core.entity.component.Component
import dev.kord.core.entity.component.SelectMenuComponent
import dev.kord.core.event.interaction.GlobalModalSubmitInteractionCreateEvent
import dev.kord.core.supplier.EntitySupplier
import dev.kord.core.supplier.EntitySupplyStrategy

public sealed interface ModalSubmitInteraction : Interaction, ActionInteraction {
public val customId: String get() = data.data.customId.value!!
public val components: List<ActionRowComponent> get() = data.data.components.orEmpty().map { ActionRowComponent(it) }

}

public class GuildModalSubmitInteraction(
Expand Down

0 comments on commit 4b96ef5

Please sign in to comment.