class Discordrb::Events::WebhookUpdateEventHandler

Event handler for {WebhookUpdateEvent}

Public Instance Methods

matches?(event) click to toggle source
# File lib/discordrb/events/webhooks.rb, line 25
def matches?(event)
  # Check for the proper event type
  return false unless event.is_a? WebhookUpdateEvent

  [
    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|
      case a
      when String
        # Make sure to remove the "#" from channel names in case it was specified
        a.delete('#') == e.name
      when Integer
        a == e.id
      else
        a == e
      end
    end,
    matches_all(@attributes[:webhook], event) do |a, e|
      a == case a
           when String
             e.name
           when Integer
             e.id
           else
             e
           end
    end
  ].reduce(true, &:&)
end