class Discordrb::Events::PlayingEventHandler

Event handler for PlayingEvent

Public Instance Methods

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

  [
    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[:game], event.game) do |a, e|
      a == e
    end,
    matches_all(@attributes[:type], event.type) do |a, e|
      a == e
    end,
    matches_all(@attributes[:client_status], event.client_status) do |a, e|
      e.slice(a.keys) == a
    end
  ].reduce(true, &:&)
end