Class: OnyxCord::Events::ChannelCreateEventHandler

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

Overview

Event handler for ChannelCreateEvent

Direct Known Subclasses

ChannelUpdateEventHandler

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #match, #matches_all

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/onyxcord/events/channels/base.rb', line 59

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

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