Class: Rubycord::Reaction

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycord/data/reaction.rb

Overview

A reaction to a message.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Reaction



17
18
19
20
21
22
# File 'lib/rubycord/data/reaction.rb', line 17

def initialize(data)
  @count = data["count"]
  @me = data["me"]
  @id = data["emoji"]["id"]&.to_i
  @name = data["emoji"]["name"]
end

Instance Attribute Details

#countInteger (readonly)



5
6
7
# File 'lib/rubycord/data/reaction.rb', line 5

def count
  @count
end

#idInteger (readonly)



12
13
14
# File 'lib/rubycord/data/reaction.rb', line 12

def id
  @id
end

#metrue, false (readonly) Also known as: me?



8
9
10
# File 'lib/rubycord/data/reaction.rb', line 8

def me
  @me
end

#nameString (readonly)



15
16
17
# File 'lib/rubycord/data/reaction.rb', line 15

def name
  @name
end

Instance Method Details

#to_sString

Converts this Reaction into a string that can be sent back to Discord in other reaction endpoints. If ID is present, it will be rendered into the form of name:id.



27
28
29
# File 'lib/rubycord/data/reaction.rb', line 27

def to_s
  id.nil? ? name : "#{name}:#{id}"
end