Class: Rubord::ActionRow
- Inherits:
-
Object
- Object
- Rubord::ActionRow
- Defined in:
- lib/rubord/components/actionRow.rb
Overview
Represents a Discord action row container.
Action rows are containers for message components (buttons, select menus). They can hold up to 5 buttons or 1 select menu per row.
Instance Attribute Summary collapse
-
#components ⇒ Array<Button, SelectMenu>
Components in this action row.
-
#type ⇒ Integer
Component type (always 1 for action rows).
Instance Method Summary collapse
-
#add(component) ⇒ Rubord::ActionRow
Adds a component to the action row.
-
#initialize(*components) ⇒ ActionRow
constructor
Creates a new action row.
-
#to_h ⇒ Hash
Converts the action row to a Discord API-compatible hash.
Constructor Details
#initialize(*components) ⇒ ActionRow
Note:
Action rows can contain either:
-
Up to 5 buttons
-
OR 1 select menu
Not a mixture of both.
Creates a new action row.
46 47 48 49 |
# File 'lib/rubord/components/actionRow.rb', line 46 def initialize(*components) @type = 1 @components = components end |
Instance Attribute Details
#components ⇒ Array<Button, SelectMenu>
Returns Components in this action row.
26 27 28 |
# File 'lib/rubord/components/actionRow.rb', line 26 def components @components end |
#type ⇒ Integer
Returns Component type (always 1 for action rows).
23 24 25 |
# File 'lib/rubord/components/actionRow.rb', line 23 def type @type end |
Instance Method Details
#add(component) ⇒ Rubord::ActionRow
Adds a component to the action row.
62 63 64 65 |
# File 'lib/rubord/components/actionRow.rb', line 62 def add(component) @components << component self end |
#to_h ⇒ Hash
Converts the action row to a Discord API-compatible hash.
75 76 77 78 79 80 |
# File 'lib/rubord/components/actionRow.rb', line 75 def to_h { type: @type, components: @components.map(&:to_h) } end |