Class: Rubycord::Webhooks::View::SelectMenuBuilder
- Inherits:
-
Object
- Object
- Rubycord::Webhooks::View::SelectMenuBuilder
- Defined in:
- lib/rubycord/webhooks/view.rb
Overview
A builder to assist in adding options to select menus.
Instance Method Summary collapse
-
#initialize(custom_id, options = [], placeholder = nil, min_values = nil, max_values = nil, disabled = nil, select_type: :string_select) ⇒ SelectMenuBuilder
constructor
A new instance of SelectMenuBuilder.
-
#option(label:, value:, description: nil, emoji: nil, default: nil) ⇒ Object
Add an option to this select menu.
Constructor Details
#initialize(custom_id, options = [], placeholder = nil, min_values = nil, max_values = nil, disabled = nil, select_type: :string_select) ⇒ SelectMenuBuilder
Returns a new instance of SelectMenuBuilder.
128 129 130 131 132 133 134 135 136 |
# File 'lib/rubycord/webhooks/view.rb', line 128 def initialize(custom_id, = [], placeholder = nil, min_values = nil, max_values = nil, disabled = nil, select_type: :string_select) @custom_id = custom_id @options = @placeholder = placeholder @min_values = min_values @max_values = max_values @disabled = disabled @select_type = select_type end |
Instance Method Details
#option(label:, value:, description: nil, emoji: nil, default: nil) ⇒ Object
Add an option to this select menu.
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/rubycord/webhooks/view.rb', line 145 def option(label:, value:, description: nil, emoji: nil, default: nil) emoji = case emoji when Integer, String emoji.to_i.positive? ? {id: emoji} : {name: emoji} else emoji&.to_h end @options << {label: label, value: value, description: description, emoji: emoji, default: default} end |