class Discordrb::Events::InteractionCreateEventHandler

Event handler for INTERACTION_CREATE events.

Public Instance Methods

matches?(event) click to toggle source

@!visibility private

# File lib/discordrb/events/interactions.rb, line 102
def matches?(event)
  return false unless event.is_a? InteractionCreateEvent

  [
    matches_all(@attributes[:type], event.type) do |a, e|
      a == case a
           when String, Symbol
             Discordrb::Interactions::TYPES[e.to_sym]
           else
             e
           end
    end,

    matches_all(@attributes[:server], event.interaction) do |a, e|
      a.resolve_id == e.server_id
    end,

    matches_all(@attributes[:channel], event.interaction) do |a, e|
      a.resolve_id == e.channel_id
    end,

    matches_all(@attributes[:user], event.user) do |a, e|
      a.resolve_id == e.id
    end
  ].reduce(true, &:&)
end