Class: Discordrb::Components::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/component.rb

Overview

A collection of components in an embed-like format.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#colorColourRGB? (readonly) Also known as: colour

Returns the accent colour of the container.

Returns:

  • (ColourRGB, nil)

    the accent colour of the container.



382
383
384
# File 'lib/discordrb/data/component.rb', line 382

def color
  @color
end

#componentsArray<Component> (readonly)

Returns the child components of the container.

Returns:

  • (Array<Component>)

    the child components of the container.



391
392
393
# File 'lib/discordrb/data/component.rb', line 391

def components
  @components
end

#idInteger (readonly)

Returns the numeric identifier of the container.

Returns:

  • (Integer)

    the numeric identifier of the container.



379
380
381
# File 'lib/discordrb/data/component.rb', line 379

def id
  @id
end

#spoilertrue, false (readonly) Also known as: spoiler?

Returns whether or not the container should be blurred out.

Returns:

  • (true, false)

    whether or not the container should be blurred out.



387
388
389
# File 'lib/discordrb/data/component.rb', line 387

def spoiler
  @spoiler
end

Instance Method Details

#buttonsArray<Button>

Get the buttons contained within the container.

Returns:

  • (Array<Button>)

    The buttons within the container.



404
405
406
407
408
409
410
411
412
413
# File 'lib/discordrb/data/component.rb', line 404

def buttons
  @components.flat_map do |component|
    case component
    when ActionRow
      component.buttons
    when Section
      component.accessory if component.accessory.is_a?(Button)
    end
  end.compact
end