Class: Rubycord::Webhooks::View::RowBuilder
- Inherits:
-
Object
- Object
- Rubycord::Webhooks::View::RowBuilder
- Defined in:
- lib/rubycord/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.
-
#channel_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select channel to this action row.
-
#mentionable_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select mentionable to this action row.
-
#role_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select role to this action row.
-
#string_select(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil, disabled: nil) {|builder| ... } ⇒ Object
(also: #select_menu)
Add a select string to this action row.
-
#user_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select user 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.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rubycord/webhooks/view.rb', line 43 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 |
#channel_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select channel to this action row.
115 116 117 |
# File 'lib/rubycord/webhooks/view.rb', line 115 def channel_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) @components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :channel_select).to_h end |
#mentionable_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select mentionable to this action row.
104 105 106 |
# File 'lib/rubycord/webhooks/view.rb', line 104 def mentionable_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) @components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :mentionable_select).to_h end |
#role_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select role to this action row.
93 94 95 |
# File 'lib/rubycord/webhooks/view.rb', line 93 def role_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) @components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :role_select).to_h end |
#string_select(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil, disabled: nil) {|builder| ... } ⇒ Object Also known as:
Add a select string to this action row.
65 66 67 68 69 70 71 |
# File 'lib/rubycord/webhooks/view.rb', line 65 def string_select(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil, disabled: nil) builder = SelectMenuBuilder.new(custom_id, , placeholder, min_values, max_values, disabled, select_type: :string_select) yield builder if block_given? @components << builder.to_h end |
#user_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) ⇒ Object
Add a select user to this action row.
82 83 84 |
# File 'lib/rubycord/webhooks/view.rb', line 82 def user_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil) @components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :user_select).to_h end |