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, synthesise

Constructor Details

#initialize(data, bot) ⇒ GlobalEmoji

Returns a new instance of GlobalEmoji.



2057
2058
2059
2060
2061
2062
2063
2064
2065
# File 'lib/discordrb/data.rb', line 2057

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:



2052
2053
2054
# File 'lib/discordrb/data.rb', line 2052

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



2055
2056
2057
# File 'lib/discordrb/data.rb', line 2055

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



2081
2082
2083
# File 'lib/discordrb/data.rb', line 2081

def icon_url
  API.emoji_icon_url(@id)
end

#inspectObject

The inspect method is overwritten to give more useful output



2086
2087
2088
# File 'lib/discordrb/data.rb', line 2086

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



2068
2069
2070
# File 'lib/discordrb/data.rb', line 2068

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

#to_reactionString

Returns the layout to use this emoji in a reaction.

Returns:

  • (String)

    the layout to use this emoji in a reaction



2076
2077
2078
# File 'lib/discordrb/data.rb', line 2076

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