Class: DiscordRDA::Components::Builder
- Inherits:
-
Object
- Object
- DiscordRDA::Components::Builder
- Defined in:
- lib/discord_rda/interactions/components.rb
Overview
Builder class for constructing component rows
Instance Method Summary collapse
-
#button(**kwargs) ⇒ self
Add a button to current row.
-
#channel_select(**kwargs) ⇒ self
Add a channel select to current row.
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
-
#mentionable_select(**kwargs) ⇒ self
Add a mentionable select to current row.
-
#role_select(**kwargs) ⇒ self
Add a role select to current row.
-
#row {|ActionRow| ... } ⇒ self
Start a new action row.
-
#string_select(**kwargs) ⇒ self
Add a string select to current row.
-
#to_a ⇒ Array<Hash>
Convert to array of component hashes.
-
#user_select(**kwargs) ⇒ self
Add a user select to current row.
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
371 372 373 374 |
# File 'lib/discord_rda/interactions/components.rb', line 371 def initialize @rows = [] @current_row = nil end |
Instance Method Details
#button(**kwargs) ⇒ self
Add a button to current row
390 391 392 393 394 |
# File 'lib/discord_rda/interactions/components.rb', line 390 def (**kwargs) ensure_row @current_row.add(Button.new(**kwargs)) self end |
#channel_select(**kwargs) ⇒ self
Add a channel select to current row
435 436 437 438 439 |
# File 'lib/discord_rda/interactions/components.rb', line 435 def channel_select(**kwargs) ensure_row @current_row.add(ChannelSelect.new(**kwargs)) self end |
#mentionable_select(**kwargs) ⇒ self
Add a mentionable select to current row
426 427 428 429 430 |
# File 'lib/discord_rda/interactions/components.rb', line 426 def mentionable_select(**kwargs) ensure_row @current_row.add(MentionableSelect.new(**kwargs)) self end |
#role_select(**kwargs) ⇒ self
Add a role select to current row
417 418 419 420 421 |
# File 'lib/discord_rda/interactions/components.rb', line 417 def role_select(**kwargs) ensure_row @current_row.add(RoleSelect.new(**kwargs)) self end |
#row {|ActionRow| ... } ⇒ self
Start a new action row
379 380 381 382 383 384 385 |
# File 'lib/discord_rda/interactions/components.rb', line 379 def row @current_row = ActionRow.new yield @current_row if block_given? @rows << @current_row @current_row = nil self end |
#string_select(**kwargs) ⇒ self
Add a string select to current row
399 400 401 402 403 |
# File 'lib/discord_rda/interactions/components.rb', line 399 def string_select(**kwargs) ensure_row @current_row.add(StringSelect.new(**kwargs)) self end |
#to_a ⇒ Array<Hash>
Convert to array of component hashes
443 444 445 |
# File 'lib/discord_rda/interactions/components.rb', line 443 def to_a @rows.map(&:to_h) end |
#user_select(**kwargs) ⇒ self
Add a user select to current row
408 409 410 411 412 |
# File 'lib/discord_rda/interactions/components.rb', line 408 def user_select(**kwargs) ensure_row @current_row.add(UserSelect.new(**kwargs)) self end |