Class: OnyxCord::Events::InviteCreateEventHandler

Inherits:
EventHandler
  • Object
show all
Defined in:
lib/onyxcord/events/invite/create.rb

Overview

Event handler for InviteCreateEvent.

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #match, #matches_all

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/onyxcord/events/invite/create.rb', line 50

def matches?(event)
  return false unless event.is_a? InviteCreateEvent

  [
    matches_all(@attributes[:server], event.server) do |a, e|
      a == case a
           when String
             e.name
           when Integer
             e.id
           else
             e
           end
    end,
    matches_all(@attributes[:channel], event.channel) do |a, e|
      a == case a
           when String
             e.name
           when Integer
             e.id
           else
             e
           end
    end,
    matches_all(@attributes[:temporary], event.temporary?, &:==),
    matches_all(@attributes[:inviter], event.inviter, &:==)
  ].reduce(true, &:&)
end