Class: DiscordRDA::Emoji
- Defined in:
- lib/discord_rda/entity/emoji.rb
Overview
Represents a Discord emoji (custom or Unicode).
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#animated? ⇒ Boolean
Check if emoji is animated.
-
#available? ⇒ Boolean
Check if emoji is available (not blocked by role restrictions).
-
#created_at ⇒ Time?
Get creation time (custom emojis only).
-
#custom? ⇒ Boolean
Check if this is a custom emoji.
-
#guild_id ⇒ Snowflake?
Get the guild ID.
-
#managed? ⇒ Boolean
Check if emoji is managed by integration.
-
#mention ⇒ String
Get the emoji mention string.
-
#require_colons? ⇒ Boolean
Check if emoji requires colons.
-
#role_ids ⇒ Array<Snowflake>
Get role restrictions.
-
#unicode? ⇒ Boolean
Check if this is a Unicode emoji (no ID).
-
#url ⇒ String
Get the emoji URL.
-
#user ⇒ User?
Get the emoji creator.
Methods inherited from Entity
#==, attribute, from_hash, #hash, #initialize, #inspect, #to_h, #to_json
Constructor Details
This class inherits a constructor from DiscordRDA::Entity
Instance Method Details
#animated? ⇒ Boolean
Check if emoji is animated
23 24 25 |
# File 'lib/discord_rda/entity/emoji.rb', line 23 def animated? animated end |
#available? ⇒ Boolean
Check if emoji is available (not blocked by role restrictions)
41 42 43 |
# File 'lib/discord_rda/entity/emoji.rb', line 41 def available? available end |
#created_at ⇒ Time?
Get creation time (custom emojis only)
85 86 87 |
# File 'lib/discord_rda/entity/emoji.rb', line 85 def created_at id&. end |
#custom? ⇒ Boolean
Check if this is a custom emoji
79 80 81 |
# File 'lib/discord_rda/entity/emoji.rb', line 79 def custom? !id.nil? end |
#guild_id ⇒ Snowflake?
Get the guild ID
17 18 19 |
# File 'lib/discord_rda/entity/emoji.rb', line 17 def guild_id @raw_data['guild_id'] ? Snowflake.new(@raw_data['guild_id']) : nil end |
#managed? ⇒ Boolean
Check if emoji is managed by integration
35 36 37 |
# File 'lib/discord_rda/entity/emoji.rb', line 35 def managed? managed end |
#mention ⇒ String
Get the emoji mention string
66 67 68 69 |
# File 'lib/discord_rda/entity/emoji.rb', line 66 def mention prefix = animated? ? 'a' : '' "<#{prefix}:#{name}:#{id}>" end |
#require_colons? ⇒ Boolean
Check if emoji requires colons
29 30 31 |
# File 'lib/discord_rda/entity/emoji.rb', line 29 def require_colons? require_colons end |
#role_ids ⇒ Array<Snowflake>
Get role restrictions
53 54 55 |
# File 'lib/discord_rda/entity/emoji.rb', line 53 def role_ids (@raw_data['roles'] || []).map { |r| Snowflake.new(r) } end |
#unicode? ⇒ Boolean
Check if this is a Unicode emoji (no ID)
73 74 75 |
# File 'lib/discord_rda/entity/emoji.rb', line 73 def unicode? id.nil? end |
#url ⇒ String
Get the emoji URL
59 60 61 62 |
# File 'lib/discord_rda/entity/emoji.rb', line 59 def url ext = animated? ? 'gif' : 'png' "https://cdn.discordapp.com/emojis/#{id}.#{ext}" end |