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


2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
# File 'lib/discordrb/data.rb', line 2704

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

Instance Attribute Details

#animatedtrue, false (readonly) Also known as: animated?


2701
2702
2703
# File 'lib/discordrb/data.rb', line 2701

def animated
  @animated
end

#nameString (readonly)


2692
2693
2694
# File 'lib/discordrb/data.rb', line 2692

def name
  @name
end

#rolesArray<Role> (readonly)


2698
2699
2700
# File 'lib/discordrb/data.rb', line 2698

def roles
  @roles
end

#serverServer (readonly)


2695
2696
2697
# File 'lib/discordrb/data.rb', line 2695

def server
  @server
end

Instance Method Details

#icon_urlString


2730
2731
2732
# File 'lib/discordrb/data.rb', line 2730

def icon_url
  API.emoji_icon_url(id)
end

#inspectObject

The inspect method is overwritten to give more useful output


2735
2736
2737
# File 'lib/discordrb/data.rb', line 2735

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

#mentionString Also known as: use, to_s


2717
2718
2719
# File 'lib/discordrb/data.rb', line 2717

def mention
  "<#{'a' if animated}:#{name}:#{id}>"
end

#to_reactionString


2725
2726
2727
# File 'lib/discordrb/data.rb', line 2725

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