Module: Discorb::Interaction::ModalResponder

Included in:
CommandInteraction, MessageComponentInteraction
Defined in:
lib/discorb/interaction/response.rb

Overview

A module for response with modal.

Instance Method Summary collapse

Instance Method Details

#show_modal(title, custom_id, components) ⇒ Async::Task<void>

Response with MODAL(9).

Parameters:

  • title (String)

    The title of the modal.

  • custom_id (String)

    The custom id of the modal.

  • components (Array<Discorb::TextInput>)

    The text inputs to send.

Returns:

  • (Async::Task<void>)

    The task.



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/discorb/interaction/response.rb', line 351

def show_modal(title, custom_id, components)
  Async do
    payload = {
      title: title,
      custom_id: custom_id,
      components: Component.to_payload(components)
    }
    @client
      .http
      .request(
        Route.new(
          "/interactions/#{@id}/#{@token}/callback",
          "//interactions/:interaction_id/:token/callback",
          :post
        ),
        { type: 9, data: payload }
      )
      .wait
  end
end