class Discordrb::Emoji
Server
emoji
Attributes
animated[R]
@return [true, false] if the emoji is animated
animated?[R]
@return [true, false] if the emoji is animated
name[R]
@return [String] the emoji name
roles[R]
@return [Array<Role>, nil] roles this emoji is active for, or nil if the emoji’s server is unknown
server[R]
@return [Server, nil] the server of this emoji
Public Class Methods
new(data, bot, server = nil)
click to toggle source
@!visibility private
# File lib/discordrb/data/emoji.rb, line 22 def initialize(data, bot, server = nil) @bot = bot @roles = nil @name = data['name'] @server = server @id = data['id'].nil? ? nil : data['id'].to_i @animated = data['animated'] process_roles(data['roles']) if server end
Public Instance Methods
==(other)
click to toggle source
ID or name based comparison
# 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
Also aliased as: eql?
icon_url()
click to toggle source
@return [String] the icon URL of the emoji
# File lib/discordrb/data/emoji.rb, line 62 def icon_url API.emoji_icon_url(id) end
inspect()
click to toggle source
The inspect method is overwritten to give more useful output
# File lib/discordrb/data/emoji.rb, line 67 def inspect "<Emoji name=#{name} id=#{id} animated=#{animated}>" end
mention()
click to toggle source
@return [String] the layout to mention it (or have it used) in a message
# File lib/discordrb/data/emoji.rb, line 45 def mention return name if id.nil? "<#{'a' if animated}:#{name}:#{id}>" end
process_roles(roles)
click to toggle source
@!visibility private
# File lib/discordrb/data/emoji.rb, line 72 def process_roles(roles) @roles = [] return unless roles roles.each do |role_id| role = server.role(role_id) @roles << role end end
to_reaction()
click to toggle source
@return [String] the layout to use this emoji in a reaction
# File lib/discordrb/data/emoji.rb, line 55 def to_reaction return name if id.nil? "#{name}:#{id}" end