Sha256: 3a758c3b168d5ff20fef897781af2a716bc99e7f3d42bc45fc1c3fa2a362fb7a

Contents?: true

Size: 735 Bytes

Versions: 5

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

module Discorb
  #
  # Represents a modal interaction.
  #
  class ModalInteraction < Interaction
    include Interaction::SourceResponder

    @interaction_type = 5
    @interaction_name = :modal_submit
    @event_name = :modal_submit

    # @return [String] The custom id of the modal.
    attr_reader :custom_id
    # @return [{String => String}] The contents of the modal.
    attr_reader :contents

    private

    def _set_data(data)
      @custom_id = data[:custom_id]
      @contents = data[:components].to_h do |component|
        [component[:components][0][:custom_id], component[:components][0][:value]]
      end
    end

    class << self
      alias make_interaction new
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
discorb-0.19.0 lib/discorb/interaction/modal.rb
discorb-0.18.1 lib/discorb/interaction/modal.rb
discorb-0.18.0 lib/discorb/interaction/modal.rb
discorb-0.17.1 lib/discorb/interaction/modal.rb
discorb-0.17.0 lib/discorb/interaction/modal.rb