Class: MijDiscord::Data::Emoji

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/mij-discord/data/emoji.rb

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/mij-discord/data/emoji.rb', line 7

def name
  @name
end

#rolesObject (readonly)

Returns the value of attribute roles.



11
12
13
# File 'lib/mij-discord/data/emoji.rb', line 11

def roles
  @roles
end

#serverObject (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

#mentionObject Also known as: to_s



25
26
27
# File 'lib/mij-discord/data/emoji.rb', line 25

def mention
  "<:#{@name}:#{@id}>"
end

#reactionObject



31
32
33
# File 'lib/mij-discord/data/emoji.rb', line 31

def reaction
  @id.zero? ? @name : "#{@name}:#{@id}"
end