Sha256: bf3e534a74a9dae17645f7eacd4a538ca0406a8cebeba14c5cae1d85234f25ec

Contents?: true

Size: 1.17 KB

Versions: 39

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Discorb
  #
  # Represents a reaction to a message.
  #
  class Reaction < DiscordModel
    # @return [Integer] The number of users that have reacted with this emoji.
    attr_reader :count
    # @return [Discorb::Emoji] The emoji that was reacted with.
    attr_reader :emoji
    # @return [Discorb::Message] The message that this reaction is on.
    attr_reader :message
    # @return [Boolean] Whether client user reacted with this emoji.
    attr_reader :me
    alias me? me
    alias reacted? me

    # @!visibility private
    def initialize(message, data)
      @message = message
      _set_data(data)
    end

    #
    # Fetch the user that reacted with this emoji.
    #
    # @param (see Message#fetch_reacted_users)
    #
    # @return [Array<Discorb::User>] The users that reacted with this emoji.
    #
    def fetch_users(...)
      message.fetch_reacted_users(@emoji, ...)
    end

    private

    def _set_data(data)
      @count = data[:count]
      @me = data[:me]
      @emoji = if data[:emoji][:id].nil?
          UnicodeEmoji.new(data[:emoji][:name])
        else
          PartialEmoji.new(data[:emoji])
        end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
discorb-0.9.3 lib/discorb/reaction.rb
discorb-0.9.1 lib/discorb/reaction.rb
discorb-0.9.0 lib/discorb/reaction.rb
discorb-0.8.2 lib/discorb/reaction.rb
discorb-0.8.1 lib/discorb/reaction.rb
discorb-0.8.0 lib/discorb/reaction.rb
discorb-0.7.6 lib/discorb/reaction.rb
discorb-0.7.3 lib/discorb/reaction.rb
discorb-0.7.2 lib/discorb/reaction.rb
discorb-0.7.1 lib/discorb/reaction.rb
discorb-0.7.0 lib/discorb/reaction.rb
discorb-0.6.1 lib/discorb/reaction.rb
discorb-0.6.0 lib/discorb/reaction.rb
discorb-0.5.6 lib/discorb/reaction.rb
discorb-0.5.5 lib/discorb/reaction.rb
discorb-0.5.4 lib/discorb/reaction.rb
discorb-0.5.3 lib/discorb/reaction.rb
discorb-0.5.2 lib/discorb/reaction.rb
discorb-0.5.1 lib/discorb/reaction.rb
discorb-0.5.0 lib/discorb/reaction.rb