class Discordrb::Events::PresenceEventHandler

Event handler for PresenceEvent

Public Instance Methods

matches?(event) click to toggle source
# File lib/discordrb/events/presence.rb, line 34
def matches?(event)
  # Check for the proper event type
  return false unless event.is_a? PresenceEvent

  [
    matches_all(@attributes[:from], event.user) do |a, e|
      a == case a
           when String
             e.name
           when Integer
             e.id
           else
             e
           end
    end,
    matches_all(@attributes[:status], event.status) do |a, e|
      a == if a.is_a? String
             e.to_s
           else
             e
           end
    end
  ].reduce(true, &:&)
end