Class: Discordrb::Emoji
- Inherits:
-
Object
- Object
- Discordrb::Emoji
- Includes:
- IDObject
- Defined in:
- lib/discordrb/data.rb
Overview
Server emoji
Instance Attribute Summary collapse
-
#animated ⇒ true, false
(also: #animated?)
readonly
If the emoji is animated.
-
#name ⇒ String
readonly
The emoji name.
-
#roles ⇒ Array<Role>
readonly
Roles this emoji is active for.
-
#server ⇒ Server
readonly
The server of this emoji.
Attributes included from IDObject
Instance Method Summary collapse
-
#icon_url ⇒ String
The icon URL of the emoji.
-
#initialize(data, bot, server) ⇒ Emoji
constructor
A new instance of Emoji.
-
#inspect ⇒ Object
The inspect method is overwritten to give more useful output.
-
#mention ⇒ String
(also: #use, #to_s)
The layout to mention it (or have it used) in a message.
-
#to_reaction ⇒ String
The layout to use this emoji in a reaction.
Methods included from IDObject
#==, #creation_time, synthesise
Constructor Details
#initialize(data, bot, server) ⇒ Emoji
Returns a new instance of Emoji.
2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 |
# 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 |
Instance Attribute Details
#animated ⇒ true, false (readonly) Also known as: animated?
Returns if the emoji is animated.
2717 2718 2719 |
# File 'lib/discordrb/data.rb', line 2717 def animated @animated end |
#name ⇒ String (readonly)
Returns the emoji name.
2708 2709 2710 |
# File 'lib/discordrb/data.rb', line 2708 def name @name end |
#roles ⇒ Array<Role> (readonly)
Returns roles this emoji is active for.
2714 2715 2716 |
# File 'lib/discordrb/data.rb', line 2714 def roles @roles end |
#server ⇒ Server (readonly)
Returns the server of this emoji.
2711 2712 2713 |
# File 'lib/discordrb/data.rb', line 2711 def server @server end |
Instance Method Details
#icon_url ⇒ String
Returns the icon URL of the emoji.
2746 2747 2748 |
# File 'lib/discordrb/data.rb', line 2746 def icon_url API.emoji_icon_url(id) end |
#inspect ⇒ Object
The inspect method is overwritten to give more useful output
2751 2752 2753 |
# File 'lib/discordrb/data.rb', line 2751 def inspect "<Emoji name=#{name} id=#{id} animated=#{animated}>" end |
#mention ⇒ String Also known as: use, to_s
Returns the layout to mention it (or have it used) in a message.
2733 2734 2735 |
# File 'lib/discordrb/data.rb', line 2733 def mention "<#{'a' if animated}:#{name}:#{id}>" end |
#to_reaction ⇒ String
Returns the layout to use this emoji in a reaction.
2741 2742 2743 |
# File 'lib/discordrb/data.rb', line 2741 def to_reaction "#{name}:#{id}" end |