Class: DiscordRDA::Components::ActionRow
- Defined in:
- lib/discord_rda/interactions/components.rb
Overview
Action Row - Container for other components (max 5 components)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#add(component) ⇒ self
Add a component to this row.
-
#button(**kwargs) ⇒ self
Button helper.
-
#channel_select(**kwargs) ⇒ self
Channel select helper.
-
#initialize ⇒ ActionRow
constructor
A new instance of ActionRow.
-
#mentionable_select(**kwargs) ⇒ self
Mentionable select helper.
-
#role_select(**kwargs) ⇒ self
Role select helper.
-
#string_select(**kwargs) ⇒ self
String select helper.
-
#user_select(**kwargs) ⇒ self
User select helper.
Methods inherited from Base
Constructor Details
#initialize ⇒ ActionRow
Returns a new instance of ActionRow.
61 62 63 64 |
# File 'lib/discord_rda/interactions/components.rb', line 61 def initialize super(:action_row) @components = [] end |
Instance Method Details
#add(component) ⇒ self
Add a component to this row
69 70 71 72 73 74 75 |
# File 'lib/discord_rda/interactions/components.rb', line 69 def add(component) raise ArgumentError, 'ActionRow can only contain non-row components' if component.is_a?(ActionRow) raise ArgumentError, 'ActionRow can contain max 5 components' if @components.length >= 5 @components << component @data[:components] = @components.map(&:to_h) self end |
#button(**kwargs) ⇒ self
Button helper
80 81 82 |
# File 'lib/discord_rda/interactions/components.rb', line 80 def (**kwargs) add(Button.new(**kwargs)) end |
#channel_select(**kwargs) ⇒ self
Channel select helper
115 116 117 |
# File 'lib/discord_rda/interactions/components.rb', line 115 def channel_select(**kwargs) add(ChannelSelect.new(**kwargs)) end |
#mentionable_select(**kwargs) ⇒ self
Mentionable select helper
108 109 110 |
# File 'lib/discord_rda/interactions/components.rb', line 108 def mentionable_select(**kwargs) add(MentionableSelect.new(**kwargs)) end |
#role_select(**kwargs) ⇒ self
Role select helper
101 102 103 |
# File 'lib/discord_rda/interactions/components.rb', line 101 def role_select(**kwargs) add(RoleSelect.new(**kwargs)) end |
#string_select(**kwargs) ⇒ self
String select helper
87 88 89 |
# File 'lib/discord_rda/interactions/components.rb', line 87 def string_select(**kwargs) add(StringSelect.new(**kwargs)) end |
#user_select(**kwargs) ⇒ self
User select helper
94 95 96 |
# File 'lib/discord_rda/interactions/components.rb', line 94 def user_select(**kwargs) add(UserSelect.new(**kwargs)) end |