Class: Discordrb::Events::ChannelRecipientEventHandler

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

Overview

Generic event handler for channel recipient 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)

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/discordrb/events/channels.rb', line 147

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

  [
    matches_all(@attributes[:owner_id], event.owner_id) do |a, e|
      a.resolve_id == e.resolve_id
    end,
    matches_all(@attributes[:id], event.id) do |a, e|
      a.resolve_id == e.resolve_id
    end,
    matches_all(@attributes[:name], event.name) do |a, e|
      a == if a.is_a? String
             e.to_s
           else
             e
           end
    end
  ]
end