Class: Discordrb::Events::GuildEventHandler

Inherits:
EventHandler show all
Defined in:
lib/discordrb/events/guilds.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)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/discordrb/events/guilds.rb', line 20

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

  [
    matches_all(@attributes[:server], event.server) do |a, e|
      a == if a.is_a? String
             e.name
           elsif a.is_a? Fixnum
             e.id
           else
             e
           end
    end
  ].reduce(true, &:&)
end