class Discordrb::Events::ComponentEventHandler

Generic handler for component events.

Public Instance Methods

matches?(event) click to toggle source
# File lib/discordrb/events/interactions.rb, line 345
def matches?(event)
  return false unless super
  return false unless event.is_a? ComponentEvent

  [
    matches_all(@attributes[:custom_id], event.custom_id) do |a, e|
      # Match regexp and strings
      case a
      when Regexp
        a.match?(e)
      else
        a == e
      end
    end,
    matches_all(@attributes[:message], event.message) do |a, e|
      case a
      when String, Integer
        a.resolve_id == e.id
      else
        a.id == e.id
      end
    end
  ].reduce(&:&)
end