Class: Discordrb::Events::ReactionEventHandler

Inherits:
EventHandler
  • Object
show all
Defined in:
lib/discordrb/events/reactions.rb

Overview

Generic superclass for event handlers pertaining to adding and removing reactions

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #initialize, #match, #matches_all

Constructor Details

This class inherits a constructor from Discordrb::Events::EventHandler

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/discordrb/events/reactions.rb', line 51

def matches?(event)
  # Check for the proper event type
  return false unless event.is_a? ReactionEvent

  [
    matches_all(@attributes[:emoji], event.emoji) do |a, e|
      if a.is_a? Integer
        e.id == a
      elsif a.is_a? String
        e.name == a || e.name == a.delete(':') || e.id == a.resolve_id
      else
        e == a
      end
    end
  ].reduce(true, &:&)
end