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.

Defined Under Namespace

Classes: RowBuilder, SelectMenuBuilder

Constant Summary collapse

BUTTON_STYLES =

Possible button style names and values.

{
  primary: 1,
  secondary: 2,
  success: 3,
  danger: 4,
  link: 5
}.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
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ View

Returns a new instance of View.

Yields:

  • (_self)

Yield Parameters:



174
175
176
177
178
# File 'lib/discordrb/webhooks/view.rb', line 174

def initialize
  @rows = []

  yield self if block_given?
end

Instance Attribute Details

#rowsObject (readonly)

Returns the value of attribute rows.



172
173
174
# File 'lib/discordrb/webhooks/view.rb', line 172

def rows
  @rows
end

Instance Method Details

#row {|| ... } ⇒ Object

Add a new ActionRow to the view

Yield Parameters:



182
183
184
185
186
187
188
# File 'lib/discordrb/webhooks/view.rb', line 182

def row
  new_row = RowBuilder.new

  yield new_row

  @rows << new_row
end