Class: Discordrb::Webhooks::View::RowBuilder
- Inherits:
-
Object
- Object
- Discordrb::Webhooks::View::RowBuilder
- Defined in:
- lib/discordrb/webhooks/view.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.
Instance Method Summary collapse
-
#button(style:, label: nil, emoji: nil, custom_id: nil, disabled: nil, url: nil) ⇒ Object
Add a button to this action row.
-
#select_menu(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil) {|builder| ... } ⇒ Object
Add a select menu to this action row.
Instance Method Details
#button(style:, label: nil, emoji: nil, custom_id: nil, disabled: nil, url: nil) ⇒ Object
Add a button to this action row.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/discordrb/webhooks/view.rb', line 40 def (style:, label: nil, emoji: nil, custom_id: nil, disabled: nil, url: nil) style = BUTTON_STYLES[style] || style emoji = case emoji when Integer, String emoji.to_i.positive? ? { id: emoji } : { name: emoji } else emoji.to_h end @components << { type: COMPONENT_TYPES[:button], label: label, emoji: emoji, style: style, custom_id: custom_id, disabled: disabled, url: url } end |
#select_menu(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil) {|builder| ... } ⇒ Object
Add a select menu to this action row.
61 62 63 64 65 66 67 |
# File 'lib/discordrb/webhooks/view.rb', line 61 def (custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil) builder = SelectMenuBuilder.new(custom_id, , placeholder, min_values, max_values) yield builder if block_given? @components << builder.to_h end |