Class: Discordrb::Webhooks::View

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/webhooks/view.rb

Overview

A reusable view representing a component collection, with builder methods.

Direct Known Subclasses

Components::View

Defined Under Namespace

Classes: ContainerBuilder, FileBuilder, MediaGalleryBuilder, RowBuilder, SectionBuilder, SelectMenuBuilder, SeparatorBuilder, TextDisplayBuilder

Constant Summary collapse

BUTTON_STYLES =

Possible button style names and values.

{
  primary: 1,
  secondary: 2,
  success: 3,
  danger: 4,
  link: 5
}.freeze
SEPARATOR_SIZES =

Possible separator size names and values.

{
  small: 1,
  large: 2
}.freeze
COMPONENT_TYPES =

Component types.

{
  action_row: 1,
  button: 2,
  string_select: 3,
  # text_input: 4, # (defined in modal.rb)
  user_select: 5,
  role_select: 6,
  mentionable_select: 7,
  channel_select: 8,
  section: 9,
  text_display: 10,
  thumbnail: 11,
  media_gallery: 12,
  file: 13,
  separator: 14,
  container: 17
  # label: 18, # (defined in modal.rb)
  # file_upload: 19, (defined in modal.rb)
  # radio_group: 21, (defined in modal.rb)
  # checkbox_group: 22, (defined in modal.rb)
  # checkbox: 23 (defined in modal.rb)
}.freeze

Instance Method Summary collapse

Instance Method Details

#containerObject

Add a container component to the view.



459
460
461
# File 'lib/discordrb/webhooks/view.rb', line 459

def container(...)
  @components << ContainerBuilder.new(...)
end

#fileObject Also known as: file_display

Add a file component to the view.



439
440
441
# File 'lib/discordrb/webhooks/view.rb', line 439

def file(...)
  @components << FileBuilder.new(...)
end

Add a media gallery component to the view.



471
472
473
# File 'lib/discordrb/webhooks/view.rb', line 471

def media_gallery(...)
  @components << MediaGalleryBuilder.new(...)
end

#rowObject

Add a row component to the view.

See Also:

  • Discordrb::Webhooks::View::RowBuilder#initialize


433
434
435
# File 'lib/discordrb/webhooks/view.rb', line 433

def row(...)
  @components << RowBuilder.new(...)
end

#sectionObject

Add a section component to the view.



447
448
449
# File 'lib/discordrb/webhooks/view.rb', line 447

def section(...)
  @components << SectionBuilder.new(...)
end

#separatorObject

Add a separator component to the view.



453
454
455
# File 'lib/discordrb/webhooks/view.rb', line 453

def separator(...)
  @components << SeparatorBuilder.new(...)
end

#text_displayObject

Add a text display component to the view.



465
466
467
# File 'lib/discordrb/webhooks/view.rb', line 465

def text_display(...)
  @components << TextDisplayBuilder.new(...)
end