class Discordrb::Events::ThreadCreateEventHandler

Event handler for ChannelCreateEvent

Public Instance Methods

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

  [
    matches_all(@attributes[:name], event.name) do |a, e|
      a == if a.is_a? String
             e.to_s
           else
             e
           end
    end,
    matches_all(@attributes[:server], event.server) do |a, e|
      a.resolve_id == e.resolve_id
    end,
    matches_all(@attributes[:invitable], event.thread.invitable) do |a, e|
      a == e
    end,
    matches_all(@attributes[:owner], event.thread.owner) do |a, e|
      a.resolve_id == e.resolve_id
    end,
    matches_all(@attributes[:channel], event.thread.parent) do |a, e|
      a.resolve_id == e.resolve_id
    end
  ].reduce(true, &:&)
end