Class: OnyxCord::Components::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/onyxcord/models/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.



388
389
390
# File 'lib/onyxcord/models/component.rb', line 388

def color
  @color
end

#componentsArray<Component> (readonly)

Returns the child components of the container.

Returns:

  • (Array<Component>)

    the child components of the container.



397
398
399
# File 'lib/onyxcord/models/component.rb', line 397

def components
  @components
end

#idInteger (readonly)

Returns the numeric identifier of the container.

Returns:

  • (Integer)

    the numeric identifier of the container.



385
386
387
# File 'lib/onyxcord/models/component.rb', line 385

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.



393
394
395
# File 'lib/onyxcord/models/component.rb', line 393

def spoiler
  @spoiler
end

Instance Method Details

#buttonsArray<Button>

Get the buttons contained within the container.

Returns:

  • (Array<Button>)

    The buttons within the container.



410
411
412
413
414
415
416
417
418
419
# File 'lib/onyxcord/models/component.rb', line 410

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