operator [] method

String? operator [](
  1. String id
)

Get the value the user inputted in a component based on its id.

Throws a StateError if no component with the given id exist in the modal.

Implementation

String? operator [](String id) => interaction.data.components
    .expand((component) => component is ActionRowComponent ? component.components : [component])
    .whereType<TextInputComponent>()
    .singleWhere((element) => element.customId == id)
    .value;