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>] roles this emoji is active for

server[R]

@return [Server] the server of this emoji

Public Class Methods

new(data, bot, server) click to toggle source
# File lib/discordrb/data.rb, line 2720
def initialize(data, bot, server)
  @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

icon_url() click to toggle source

@return [String] the icon URL of the emoji

# File lib/discordrb/data.rb, line 2746
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.rb, line 2751
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.rb, line 2733
def mention
  "<#{'a' if animated}:#{name}:#{id}>"
end
Also aliased as: use, to_s
process_roles(roles) click to toggle source

@!visibility private

# File lib/discordrb/data.rb, line 2756
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.rb, line 2741
def to_reaction
  "#{name}:#{id}"
end
to_s()
Alias for: mention
use()
Alias for: mention