Class: Discordrb::Webhooks::Modal::RowBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/webhooks/modal.rb

Overview

This builder is used when constructing an ActionRow. All current components must be within an action row, but this can change in the future. A message can have 5 action rows, each action row can hold a weight of 5. Buttons have a weight of 1, and dropdowns have a weight of 5.

Constant Summary collapse

TEXT_INPUT_STYLES =

A mapping of short names to types of input styles. short is a single line where paragraph is a block.

{
  short: 1,
  paragraph: 2
}.freeze

Instance Method Summary collapse

Instance Method Details

#text_input(style:, custom_id:, label: nil, min_length: nil, max_length: nil, required: nil, value: nil, placeholder: nil) ⇒ Object

Add a text input to this action row.

Parameters:

  • style (Symbol, Integer)

    The text input's style type. See TEXT_INPUT_STYLES

  • custom_id (String)

    Custom IDs are used to pass state to the events that are raised from interactions. There is a limit of 100 characters to each custom_id.

  • label (String, nil) (defaults to: nil)

    The text label for the field.

  • min_length (Integer, nil) (defaults to: nil)

    The minimum input length for a text input, min 0, max 4000.

  • max_length (Integer, nil) (defaults to: nil)

    The maximum input length for a text input, min 1, max 4000.

  • required (true, false, nil) (defaults to: nil)

    Whether this component is required to be filled, default true.

  • value (String, nil) (defaults to: nil)

    A pre-filled value for this component, max 4000 characters.

  • placeholder (String, nil) (defaults to: nil)

    Custom placeholder text if the input is empty, max 100 characters



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/discordrb/webhooks/modal.rb', line 36

def text_input(style:, custom_id:, label: nil, min_length: nil, max_length: nil, required: nil, value: nil, placeholder: nil)
  style = TEXT_INPUT_STYLES[style] || style

  @components << {
    style: style,
    custom_id: custom_id,
    type: COMPONENT_TYPES[:text_input],
    label: label,
    min_length: min_length,
    max_length: max_length,
    required: required,
    value: value,
    placeholder: placeholder
  }
end