Class: Discordrb::Emoji
- Inherits:
-
Object
- Object
- Discordrb::Emoji
- Includes:
- IDObject
- Defined in:
- lib/discordrb/data/emoji.rb
Overview
Server emoji
Instance Attribute Summary collapse
-
#animated ⇒ true, false
(also: #animated?)
readonly
If the emoji is animated.
-
#name ⇒ String
readonly
The emoji name.
-
#roles ⇒ Array<Role>?
readonly
Roles this emoji is active for, or nil if the emoji’s server is unknown.
-
#server ⇒ Server?
readonly
The server of this emoji.
Attributes included from IDObject
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
ID or name based comparison.
-
#icon_url ⇒ String
The icon URL of the emoji.
-
#inspect ⇒ Object
The inspect method is overwritten to give more useful output.
-
#mention ⇒ String
(also: #use, #to_s)
The layout to mention it (or have it used) in a message.
-
#to_reaction ⇒ String
The layout to use this emoji in a reaction.
Methods included from IDObject
Instance Attribute Details
#animated ⇒ true, false (readonly) Also known as: animated?
Returns if the emoji is animated.
18 19 20 |
# File 'lib/discordrb/data/emoji.rb', line 18 def animated @animated end |
#name ⇒ String (readonly)
Returns the emoji name.
9 10 11 |
# File 'lib/discordrb/data/emoji.rb', line 9 def name @name end |
#roles ⇒ Array<Role>? (readonly)
Returns roles this emoji is active for, or nil if the emoji’s server is unknown.
15 16 17 |
# File 'lib/discordrb/data/emoji.rb', line 15 def roles @roles end |
#server ⇒ Server? (readonly)
Returns the server of this emoji.
12 13 14 |
# File 'lib/discordrb/data/emoji.rb', line 12 def server @server end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
ID or name based comparison
35 36 37 38 39 40 |
# File 'lib/discordrb/data/emoji.rb', line 35 def ==(other) return false unless other.is_a? Emoji return Discordrb.id_compare(@id, other) if @id name == other.name end |
#icon_url ⇒ String
Returns the icon URL of the emoji.
62 63 64 |
# File 'lib/discordrb/data/emoji.rb', line 62 def icon_url API.emoji_icon_url(id) end |
#inspect ⇒ Object
The inspect method is overwritten to give more useful output
67 68 69 |
# File 'lib/discordrb/data/emoji.rb', line 67 def inspect "<Emoji name=#{name} id=#{id} animated=#{animated}>" end |
#mention ⇒ String Also known as: use, to_s
Returns the layout to mention it (or have it used) in a message.
45 46 47 48 49 |
# File 'lib/discordrb/data/emoji.rb', line 45 def mention return name if id.nil? "<#{'a' if animated}:#{name}:#{id}>" end |
#to_reaction ⇒ String
Returns the layout to use this emoji in a reaction.
55 56 57 58 59 |
# File 'lib/discordrb/data/emoji.rb', line 55 def to_reaction return name if id.nil? "#{name}:#{id}" end |