Class: Discordrb::Events::ServerMemberEventHandler

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

Overview

Generic event handler for member events

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)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/discordrb/events/members.rb', line 49

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

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