Class: OnyxCord::Events::ServerEmojiCDEventHandler

Inherits:
ServerEventHandler show all
Defined in:
lib/onyxcord/events/guilds/emoji.rb

Overview

Generic handler for emoji create and delete

Instance Method Summary collapse

Methods inherited from EventHandler

#after_call, #call, #match, #matches_all

Instance Method Details

#matches?(event) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/onyxcord/events/guilds/emoji.rb', line 89

def matches?(event)
  # Check for the proper event type
  return false unless event.is_a? ServerEmojiCDEvent

  [
    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[:id], event.emoji.id) { |a, e| a.resolve_id == e.resolve_id },
    matches_all(@attributes[:name], event.emoji.name) { |a, e| a == e }
  ].reduce(true, &:&)
end