Method: Discordrb::Interaction#show_modal

Defined in:
lib/discordrb/data/interaction.rb

#show_modal(title:, custom_id:, components: nil) {|A| ... } ⇒ Object

Create a modal as a response.

Parameters:

  • title (String)

    The title of the modal being shown.

  • custom_id (String)

    The custom_id used to identify the modal and store data.

  • components (Array<Component, Hash>, nil) (defaults to: nil)

    An array of components. These can be defined through the block as well.

Yield Parameters:

  • A (Discordrb::Webhooks::Modal)

    builder for the modal's components.



138
139
140
141
142
143
144
145
146
147
148
# File 'lib/discordrb/data/interaction.rb', line 138

def show_modal(title:, custom_id:, components: nil)
  if block_given?
    modal_builder = Discordrb::Webhooks::Modal.new
    yield modal_builder

    components = modal_builder.to_a
  end

  Discordrb::API::Interaction.create_interaction_modal_response(@token, @id, custom_id, title, components.to_a) unless type == Interaction::TYPES[:modal_submit]
  nil
end