Class: Discordrb::Events::GuildMemberEventHandler

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

#call, #initialize, #match, #matches_all

Constructor Details

This class inherits a constructor from Discordrb::Events::EventHandler

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/discordrb/events/members.rb', line 36

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

  [
    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