class Discorb::SelectMenu
Represents a select menu component.
Attributes
@return [String] The custom ID of the select menu.
@return [Boolean] Whether the select menu is disabled.
@return [Boolean] Whether the select menu is disabled.
@return [Integer] The maximum number of values.
@return [Integer] The minimum number of values.
@return [Array<SelectMenu::Option>] The options of the select menu.
Public Class Methods
Initialize a new select menu.
@param [String, Symbol] custom_id
Custom ID of the select menu. @param [Array<Discorb::SelectMenu::Option>] options The options of the select menu. @param [String] placeholder The placeholder of the select menu. @param [Integer] min_values
The minimum number of values. @param [Integer] max_values
The maximum number of values.
# File lib/discorb/components.rb, line 167 def initialize(custom_id, options, placeholder: nil, min_values: 1, max_values: 1) @custom_id = custom_id @options = options @placeholder = placeholder @min_values = min_values @max_values = max_values end
Public Instance Methods
Converts the select menu to a hash.
@see discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure Official Discord API docs @return [Hash] A hash representation of the select menu.
# 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
Private Instance Methods
# File lib/discorb/components.rb, line 273 def hash_emoji(emoji) case emoji when UnicodeEmoji { id: nil, name: emoji.to_s, animated: false, } when CustomEmoji { id: emoji.id, name: emoji.name, animated: emoji.animated?, } end end