Class: Discordrb::Emoji

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/discordrb/data.rb

Overview

Server emoji

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==, #creation_time, synthesise

Constructor Details

#initialize(data, bot, server) ⇒ Emoji


2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
# File 'lib/discordrb/data.rb', line 2430

def initialize(data, bot, server)
  @bot = bot
  @roles = nil

  @name = data['name']
  @server = server
  @id = data['id'].nil? ? nil : data['id'].to_i

  process_roles(data['roles']) if server
end

Instance Attribute Details

#nameString (readonly)


2422
2423
2424
# File 'lib/discordrb/data.rb', line 2422

def name
  @name
end

#rolesArray<Role> (readonly)


2428
2429
2430
# File 'lib/discordrb/data.rb', line 2428

def roles
  @roles
end

#serverServer (readonly)


2425
2426
2427
# File 'lib/discordrb/data.rb', line 2425

def server
  @server
end

Instance Method Details

#icon_urlString


2455
2456
2457
# File 'lib/discordrb/data.rb', line 2455

def icon_url
  API.emoji_icon_url(@id)
end

#inspectObject

The inspect method is overwritten to give more useful output


2460
2461
2462
# File 'lib/discordrb/data.rb', line 2460

def inspect
  "<Emoji name=#{@name} id=#{@id}>"
end

#mentionString Also known as: use, to_s


2442
2443
2444
# File 'lib/discordrb/data.rb', line 2442

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

#to_reactionString


2450
2451
2452
# File 'lib/discordrb/data.rb', line 2450

def to_reaction
  "#{@name}:#{@id}"
end