Class: Rubycord::Events::ReactionEvent
- Includes:
- Respondable
- Defined in:
- lib/rubycord/events/reactions.rb
Overview
Generic superclass for events about adding and removing reactions
Direct Known Subclasses
Instance Attribute Summary collapse
-
#emoji ⇒ Emoji
readonly
The emoji that was reacted with.
Attributes inherited from Event
Instance Method Summary collapse
-
#channel ⇒ Channel
The channel that was reacted in.
-
#initialize(data, bot) ⇒ ReactionEvent
constructor
A new instance of ReactionEvent.
-
#message ⇒ Message
The message that was reacted to.
-
#server ⇒ Server?
The server that was reacted in.
-
#user ⇒ User, Member
The user that reacted to this message, or member if a server exists.
Methods included from Respondable
#<<, #drain, #drain_into, #send_embed, #send_message, #send_temporary_message
Constructor Details
#initialize(data, bot) ⇒ ReactionEvent
Returns a new instance of ReactionEvent.
15 16 17 18 19 20 21 22 |
# File 'lib/rubycord/events/reactions.rb', line 15 def initialize(data, bot) @bot = bot @emoji = Rubycord::Emoji.new(data["emoji"], bot, nil) @user_id = data["user_id"].to_i @message_id = data["message_id"].to_i @channel_id = data["channel_id"].to_i end |
Instance Attribute Details
#emoji ⇒ Emoji (readonly)
Returns the emoji that was reacted with.
10 11 12 |
# File 'lib/rubycord/events/reactions.rb', line 10 def emoji @emoji end |
Instance Method Details
#channel ⇒ Channel
Returns the channel that was reacted in.
40 41 42 |
# File 'lib/rubycord/events/reactions.rb', line 40 def channel @channel ||= @bot.channel(@channel_id) end |
#message ⇒ Message
Returns the message that was reacted to.
35 36 37 |
# File 'lib/rubycord/events/reactions.rb', line 35 def @message ||= channel.(@message_id) end |
#server ⇒ Server?
Returns the server that was reacted in. If reacted in a PM channel, it will be nil.
45 46 47 |
# File 'lib/rubycord/events/reactions.rb', line 45 def server @server ||= channel.server end |
#user ⇒ User, Member
Returns the user that reacted to this message, or member if a server exists.
25 26 27 28 29 30 31 32 |
# File 'lib/rubycord/events/reactions.rb', line 25 def user # Cache the user so we don't do requests all the time @user ||= if server @server.member(@user_id) else @bot.user(@user_id) end end |