Class: Discordrb::Events::InviteCreateEventHandler

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

Overview

Event handler for InviteCreateEvent.

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)

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/discordrb/events/invites.rb', line 66

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