Class: Discordrb::Events::ReactionRemoveAllEventHandler

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

Overview

Event handler for ReactionRemoveAllEvent

Direct Known Subclasses

ReactionRemoveEmojiEventHandler

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #match, #matches_all

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/discordrb/events/reactions.rb', line 160

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

  [
    matches_all(@attributes[:message], event.message_id) do |a, e|
      a == e
    end,
    matches_all(@attributes[:in], event.channel) do |a, e|
      case a
      when String
        # Make sure to remove the "#" from channel names in case it was specified
        a.delete('#') == e.name
      when Integer
        a == e.id
      else
        a == e
      end
    end
  ].reduce(true, &:&)
end