Class: MijDiscord::Data::Emoji
- Inherits:
-
Object
- Object
- MijDiscord::Data::Emoji
- Includes:
- IDObject
- Defined in:
- lib/mij-discord/data/emoji.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Attributes included from IDObject
Instance Method Summary collapse
- #icon_url(format = :png) ⇒ Object
-
#initialize(data, bot, server) ⇒ Emoji
constructor
A new instance of Emoji.
- #mention ⇒ Object (also: #to_s)
- #reaction ⇒ Object
Methods included from IDObject
#==, #creation_time, #hash, synthesize
Constructor Details
#initialize(data, bot, server) ⇒ Emoji
Returns a new instance of Emoji.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mij-discord/data/emoji.rb', line 13 def initialize(data, bot, server) @bot, @server = bot, server @id = data['id'].to_i @name = data['name'] @roles = [] if @server && (roles = data['roles']) @roles = roles.map {|ro| @server.role(ro) } end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/mij-discord/data/emoji.rb', line 7 def name @name end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
11 12 13 |
# File 'lib/mij-discord/data/emoji.rb', line 11 def roles @roles end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
9 10 11 |
# File 'lib/mij-discord/data/emoji.rb', line 9 def server @server end |
Instance Method Details
#icon_url(format = :png) ⇒ Object
35 36 37 |
# File 'lib/mij-discord/data/emoji.rb', line 35 def icon_url(format = :png) MijDiscord::Core::API.emoji_icon_url(@id, format) end |
#mention ⇒ Object Also known as: to_s
25 26 27 |
# File 'lib/mij-discord/data/emoji.rb', line 25 def mention "<:#{@name}:#{@id}>" end |
#reaction ⇒ Object
31 32 33 |
# File 'lib/mij-discord/data/emoji.rb', line 31 def reaction @id.zero? ? @name : "#{@name}:#{@id}" end |