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.
167 168 169 170 171 172 173 |
# File 'lib/discorb/components.rb', line 167 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.
147 148 149 |
# File 'lib/discorb/components.rb', line 147 def custom_id @custom_id end |
#disabled -> Boolean (readonly) Also known as: disabled?
Returns Whether the select menu is disabled.
155 156 157 |
# File 'lib/discorb/components.rb', line 155 def disabled @disabled end |
#max_values -> Integer
Returns The maximum number of values.
153 154 155 |
# File 'lib/discorb/components.rb', line 153 def max_values @max_values end |
#min_values -> Integer
Returns The minimum number of values.
151 152 153 |
# File 'lib/discorb/components.rb', line 151 def min_values @min_values end |
#options -> Array<SelectMenu::Option>
Returns The options of the select menu.
149 150 151 |
# File 'lib/discorb/components.rb', line 149 def @options end |
Instance Method Details
#to_hash -> Hash
Converts the select menu to a hash.
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/discorb/components.rb', line 181 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 |