Class: Discordrb::Events::MessageIDEventHandler

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

Overview

Event handler for MessageIDEvent

Direct Known Subclasses

MessageDeleteEventHandler

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)


260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/discordrb/events/message.rb', line 260

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

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