Class: Discordrb::Reaction
- Inherits:
-
Object
- Object
- Discordrb::Reaction
- Defined in:
- lib/discordrb/data.rb
Overview
A reaction to a message.
Instance Attribute Summary collapse
-
#count ⇒ Integer
readonly
The amount of users who have reacted with this reaction.
-
#id ⇒ Integer
readonly
The ID of the emoji, if it was custom.
-
#me ⇒ true, false
(also: #me?)
readonly
Whether the current bot or user used this reaction.
-
#name ⇒ String
readonly
The name or unicode representation of the emoji.
Instance Method Summary collapse
-
#initialize(data) ⇒ Reaction
constructor
A new instance of Reaction.
-
#to_s ⇒ String
Converts this Reaction into a string that can be sent back to Discord in other reaction endpoints.
Constructor Details
#initialize(data) ⇒ Reaction
Returns a new instance of Reaction.
2688 2689 2690 2691 2692 2693 |
# File 'lib/discordrb/data.rb', line 2688 def initialize(data) @count = data['count'] @me = data['me'] @id = data['emoji']['id'].nil? ? nil : data['emoji']['id'].to_i @name = data['emoji']['name'] end |
Instance Attribute Details
#count ⇒ Integer (readonly)
Returns the amount of users who have reacted with this reaction.
2676 2677 2678 |
# File 'lib/discordrb/data.rb', line 2676 def count @count end |
#id ⇒ Integer (readonly)
Returns the ID of the emoji, if it was custom.
2683 2684 2685 |
# File 'lib/discordrb/data.rb', line 2683 def id @id end |
#me ⇒ true, false (readonly) Also known as: me?
Returns whether the current bot or user used this reaction.
2679 2680 2681 |
# File 'lib/discordrb/data.rb', line 2679 def me @me end |
#name ⇒ String (readonly)
Returns the name or unicode representation of the emoji.
2686 2687 2688 |
# File 'lib/discordrb/data.rb', line 2686 def name @name end |
Instance Method Details
#to_s ⇒ String
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
.
2698 2699 2700 |
# File 'lib/discordrb/data.rb', line 2698 def to_s id.nil? ? name : "#{name}:#{id}" end |