Class: Discordrb::GlobalEmoji

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

Overview

Emoji that is not tailored to a server

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==, #creation_time

Constructor Details

#initialize(data, bot) ⇒ GlobalEmoji

Returns a new instance of GlobalEmoji.



1857
1858
1859
1860
1861
1862
1863
1864
1865
# File 'lib/discordrb/data.rb', line 1857

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

  @name = data.name
  @id = data.id
  @role_associations = Hash.new([])
  @role_associations[data.server.id] = data.roles
end

Instance Attribute Details

#nameString (readonly)

Returns the emoji name.

Returns:



1852
1853
1854
# File 'lib/discordrb/data.rb', line 1852

def name
  @name
end

#role_associationsHash<Integer => Array<Role>> (readonly)

Returns roles this emoji is active for in every server.

Returns:

  • (Hash<Integer => Array<Role>>)

    roles this emoji is active for in every server



1855
1856
1857
# File 'lib/discordrb/data.rb', line 1855

def role_associations
  @role_associations
end

Instance Method Details

#icon_urlString

Returns the icon URL of the emoji.

Returns:

  • (String)

    the icon URL of the emoji



1876
1877
1878
# File 'lib/discordrb/data.rb', line 1876

def icon_url
  API.emoji_icon_url(@id)
end

#inspectObject

The inspect method is overwritten to give more useful output



1881
1882
1883
# File 'lib/discordrb/data.rb', line 1881

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

#mentionString Also known as: use, to_s

Returns the layout to mention it (or have it used) in a message.

Returns:

  • (String)

    the layout to mention it (or have it used) in a message



1868
1869
1870
# File 'lib/discordrb/data.rb', line 1868

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