Class: Discordrb::Events::ComponentEventHandler

Inherits:
InteractionCreateEventHandler show all
Defined in:
lib/discordrb/events/interactions.rb

Overview

Generic handler for component 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)


381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/discordrb/events/interactions.rb', line 381

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