Sha256: f55b49dfd8e26daa663e3d0f402136768b5b902d1316c9fceae057673b7b3436

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 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

1 entries across 1 versions & 1 rubygems

Version Path
discorb-0.20.0 lib/discorb/interaction/modal.rb