Class: Rubycord::Events::EventHandler
- Inherits:
-
Object
- Object
- Rubycord::Events::EventHandler
- Defined in:
- lib/rubycord/events/generic.rb
Overview
Generic event handler that can be extended
Direct Known Subclasses
ApplicationCommandEventHandler, AwaitEventHandler, ChannelCreateEventHandler, ChannelDeleteEventHandler, ChannelRecipientEventHandler, InteractionCreateEventHandler, InviteCreateEventHandler, InviteDeleteEventHandler, MessageEventHandler, MessageIDEventHandler, PlayingEventHandler, PresenceEventHandler, RawEventHandler, ReactionEventHandler, ReactionRemoveAllEventHandler, ServerEmojiUpdateEventHandler, ServerEventHandler, ServerMemberEventHandler, ServerRoleCreateEventHandler, ServerRoleDeleteEventHandler, ThreadCreateEventHandler, TrueEventHandler, TypingEventHandler, UserBanEventHandler, VoiceServerUpdateEventHandler, VoiceStateUpdateEventHandler, WebhookUpdateEventHandler
Instance Method Summary collapse
-
#after_call(event) ⇒ Object
to be overwritten by extending event handlers.
-
#call(event) ⇒ Object
Calls this handler.
-
#initialize(attributes, block) ⇒ EventHandler
constructor
A new instance of EventHandler.
-
#match(event) ⇒ Object
Checks whether this handler matches the given event, and then calls it.
-
#matches?(_) ⇒ Boolean
Whether or not this event handler matches the given event with its attributes.
- #matches_all(attributes, to_check) ⇒ Object
Constructor Details
#initialize(attributes, block) ⇒ EventHandler
Returns a new instance of EventHandler.
76 77 78 79 |
# File 'lib/rubycord/events/generic.rb', line 76 def initialize(attributes, block) @attributes = attributes @block = block end |
Instance Method Details
#after_call(event) ⇒ Object
to be overwritten by extending event handlers
100 101 |
# File 'lib/rubycord/events/generic.rb', line 100 def after_call(event) end |
#call(event) ⇒ Object
Calls this handler
95 96 97 |
# File 'lib/rubycord/events/generic.rb', line 95 def call(event) @block.call(event) end |
#match(event) ⇒ Object
Checks whether this handler matches the given event, and then calls it.
89 90 91 |
# File 'lib/rubycord/events/generic.rb', line 89 def match(event) call(event) if matches? event end |
#matches?(_) ⇒ Boolean
Whether or not this event handler matches the given event with its attributes.
83 84 85 |
# File 'lib/rubycord/events/generic.rb', line 83 def matches?(_) raise "Attempted to call matches?() from a generic EventHandler" end |
#matches_all(attributes, to_check) ⇒ Object
104 105 106 |
# File 'lib/rubycord/events/generic.rb', line 104 def matches_all(attributes, to_check, &) Rubycord::Events.matches_all(attributes, to_check, &) end |