Class: Discorb::Component Abstract
- Inherits:
-
Object
- Object
- Discorb::Component
- Defined in:
- lib/discorb/components.rb
Overview
This class is abstract.
Represents a Discord component.
Direct Known Subclasses
Class Method Summary collapse
-
.from_hash(data) -> Component
Create a new component from hash data.
Class Method Details
.from_hash(data) -> Component
Create a new component from hash data.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/discorb/components.rb', line 18 def from_hash(data) case data[:type] when 2 Button.new( data[:label], data[:style], emoji: data[:emoji], custom_id: data[:custom_id], url: data[:url], disabled: data[:disabled], ) when 3 SelectMenu.new( data[:custom_id], data[:options].map { |o| SelectMenu::Option.from_hash(o) }, placeholder: data[:placeholder], min_values: data[:min_values], max_values: data[:max_values], ) end end |