Class: Discorb::SelectMenu
- Defined in:
- lib/discorb/components.rb
Overview
Represents a select menu component.
Defined Under Namespace
Classes: Option
Instance Attribute Summary collapse
-
#custom_id -> String
The custom ID of the select menu.
-
#disabled -> Boolean
(also: #disabled?)
readonly
Whether the select menu is disabled.
-
#max_values -> Integer
The maximum number of values.
-
#min_values -> Integer
The minimum number of values.
-
#options -> Array<SelectMenu::Option>
The options of the select menu.
Instance Method Summary collapse
-
#initialize(custom_id, options, placeholder: nil, min_values: 1, max_values: 1) -> SelectMenu
constructor
Initialize a new select menu.
-
#to_hash -> Hash
Converts the select menu to a hash.
Methods inherited from Component
Constructor Details
#initialize(custom_id, options, placeholder: nil, min_values: 1, max_values: 1) -> SelectMenu
Initialize a new select menu.
195 196 197 198 199 200 201 |
# File 'lib/discorb/components.rb', line 195 def initialize(custom_id, , placeholder: nil, min_values: 1, max_values: 1) @custom_id = custom_id @options = @placeholder = placeholder @min_values = min_values @max_values = max_values end |
Instance Attribute Details
#custom_id -> String
Returns The custom ID of the select menu.
175 176 177 |
# File 'lib/discorb/components.rb', line 175 def custom_id @custom_id end |
#disabled -> Boolean (readonly) Also known as: disabled?
Returns Whether the select menu is disabled.
183 184 185 |
# File 'lib/discorb/components.rb', line 183 def disabled @disabled end |
#max_values -> Integer
Returns The maximum number of values.
181 182 183 |
# File 'lib/discorb/components.rb', line 181 def max_values @max_values end |
#min_values -> Integer
Returns The minimum number of values.
179 180 181 |
# File 'lib/discorb/components.rb', line 179 def min_values @min_values end |
#options -> Array<SelectMenu::Option>
Returns The options of the select menu.
177 178 179 |
# File 'lib/discorb/components.rb', line 177 def @options end |
Instance Method Details
#to_hash -> Hash
Converts the select menu to a hash.
209 210 211 212 213 214 215 216 217 218 |
# File 'lib/discorb/components.rb', line 209 def to_hash { type: 3, custom_id: @custom_id, options: @options.map(&:to_hash), placeholder: @placeholder, min_values: @min_values, max_values: @max_values, } end |