Class: DiscordRDA::Components::StringSelect

Inherits:
SelectMenu show all
Defined in:
lib/discord_rda/interactions/components.rb

Overview

String select menu (dropdown with text options)

Instance Attribute Summary

Attributes inherited from Base

#data, #type

Instance Method Summary collapse

Methods inherited from Base

#to_h

Constructor Details

#initialize(custom_id:, options:, placeholder: nil, min_values: 1, max_values: 1, disabled: false) ⇒ StringSelect

Returns a new instance of StringSelect.

Parameters:

  • custom_id (String)

    Custom ID

  • options (Array<Hash>)

    Select options with label, value, description, emoji

  • placeholder (String) (defaults to: nil)

    Placeholder text

  • min_values (Integer) (defaults to: 1)

    Minimum values to select

  • max_values (Integer) (defaults to: 1)

    Maximum values to select

  • disabled (Boolean) (defaults to: false)

    Whether disabled



206
207
208
209
# File 'lib/discord_rda/interactions/components.rb', line 206

def initialize(custom_id:, options:, placeholder: nil, min_values: 1, max_values: 1, disabled: false)
  super(type: :string_select, custom_id: custom_id, placeholder: placeholder, min_values: min_values, max_values: max_values, disabled: disabled)
  @data[:options] = options.map { |opt| normalize_option(opt) }
end