Class: Discordrb::Events::EventHandler
- Inherits:
-
Object
- Object
- Discordrb::Events::EventHandler
- Defined in:
- lib/discordrb/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, 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, &block) ⇒ Object
Constructor Details
#initialize(attributes, block) ⇒ EventHandler
Returns a new instance of EventHandler.
78 79 80 81 |
# File 'lib/discordrb/events/generic.rb', line 78 def initialize(attributes, block) @attributes = attributes @block = block end |
Instance Method Details
#after_call(event) ⇒ Object
to be overwritten by extending event handlers
102 |
# File 'lib/discordrb/events/generic.rb', line 102 def after_call(event); end |
#call(event) ⇒ Object
Calls this handler
97 98 99 |
# File 'lib/discordrb/events/generic.rb', line 97 def call(event) @block.call(event) end |
#match(event) ⇒ Object
Checks whether this handler matches the given event, and then calls it.
91 92 93 |
# File 'lib/discordrb/events/generic.rb', line 91 def match(event) call(event) if matches? event end |
#matches?(_) ⇒ Boolean
Whether or not this event handler matches the given event with its attributes.
85 86 87 |
# File 'lib/discordrb/events/generic.rb', line 85 def matches?(_) raise 'Attempted to call matches?() from a generic EventHandler' end |
#matches_all(attributes, to_check, &block) ⇒ Object
105 106 107 |
# File 'lib/discordrb/events/generic.rb', line 105 def matches_all(attributes, to_check, &block) Discordrb::Events.matches_all(attributes, to_check, &block) end |