Class: Discordrb::Webhooks::Modal::GroupBuilder

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

Overview

Builder for radio and checkbox groups.

Instance Method Summary collapse

Instance Method Details

#checkbox(value:, label:, description: nil, default: nil) ⇒ Object

Add a checkbox component to the group.

Parameters:

  • value (String)

    The value that the checkbox represents.

  • label (String)

    The primary text of the checkbox.

  • description (String, nil) (defaults to: nil)

    The description of the checkbox.

  • default (true, false, nil) (defaults to: nil)

    Whether or not the checkbox should be checked by default.



40
41
42
43
44
# File 'lib/discordrb/webhooks/modal.rb', line 40

def checkbox(value:, label:, description: nil, default: nil)
  raise "Cannot add a checkbox to a #{@type}" unless @type == :checkbox_group

  @options << { value: value, label: label, description: description, default: default }
end

#radio_button(value:, label:, description: nil, default: nil) ⇒ Object Also known as: button

Add a radio button component to the group.

Parameters:

  • value (String)

    The value that the radio button represents.

  • label (String)

    The primary text of the radio button.

  • description (String, nil) (defaults to: nil)

    The description of the radio button.

  • default (true, false, nil) (defaults to: nil)

    Whether or not the radio button should be selected by default.



51
52
53
54
55
# File 'lib/discordrb/webhooks/modal.rb', line 51

def radio_button(value:, label:, description: nil, default: nil)
  raise "Cannot add a radio button to a #{@type}" unless @type == :radio_group

  @options << { value: value, label: label, description: description, default: default }
end