Class: DiscordRDA::Embed
- Defined in:
- lib/discord_rda/entity/embed.rb
Overview
Represents a Discord message embed.
Defined Under Namespace
Classes: Builder
Constant Summary collapse
- TYPES =
Embed types
%w[rich image video gifv article link].freeze
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#color_object ⇒ Color
Get color as Color object.
-
#embed_author ⇒ EmbedAuthor?
Get author.
-
#embed_fields ⇒ Array<EmbedField>
Get fields.
-
#embed_footer ⇒ EmbedFooter?
Get footer.
-
#embed_image ⇒ EmbedImage?
Get image.
-
#embed_provider ⇒ EmbedProvider?
Get provider.
-
#embed_thumbnail ⇒ EmbedThumbnail?
Get thumbnail.
-
#embed_video ⇒ EmbedVideo?
Get video.
-
#empty? ⇒ Boolean
Check if embed is empty.
-
#has_fields? ⇒ Boolean
Check if embed has fields.
-
#has_media? ⇒ Boolean
Check if embed has image or thumbnail.
Methods inherited from Entity
#==, attribute, #created_at, from_hash, #hash, #initialize, #inspect, #to_h, #to_json
Constructor Details
This class inherits a constructor from DiscordRDA::Entity
Instance Method Details
#color_object ⇒ Color
Get color as Color object
26 27 28 |
# File 'lib/discord_rda/entity/embed.rb', line 26 def color_object Color.new(color) end |
#embed_author ⇒ EmbedAuthor?
Get author
74 75 76 |
# File 'lib/discord_rda/entity/embed.rb', line 74 def EmbedAuthor.new(@raw_data['author']) if @raw_data['author'] end |
#embed_fields ⇒ Array<EmbedField>
Get fields
38 39 40 |
# File 'lib/discord_rda/entity/embed.rb', line 38 def (@raw_data['fields'] || []).map { |f| EmbedField.new(f) } end |
#embed_footer ⇒ EmbedFooter?
Get footer
44 45 46 |
# File 'lib/discord_rda/entity/embed.rb', line 44 def .new(@raw_data['footer']) if @raw_data['footer'] end |
#embed_image ⇒ EmbedImage?
Get image
50 51 52 |
# File 'lib/discord_rda/entity/embed.rb', line 50 def EmbedImage.new(@raw_data['image']) if @raw_data['image'] end |
#embed_provider ⇒ EmbedProvider?
Get provider
68 69 70 |
# File 'lib/discord_rda/entity/embed.rb', line 68 def EmbedProvider.new(@raw_data['provider']) if @raw_data['provider'] end |
#embed_thumbnail ⇒ EmbedThumbnail?
Get thumbnail
56 57 58 |
# File 'lib/discord_rda/entity/embed.rb', line 56 def EmbedThumbnail.new(@raw_data['thumbnail']) if @raw_data['thumbnail'] end |
#embed_video ⇒ EmbedVideo?
Get video
62 63 64 |
# File 'lib/discord_rda/entity/embed.rb', line 62 def EmbedVideo.new(@raw_data['video']) if @raw_data['video'] end |
#empty? ⇒ Boolean
Check if embed is empty
86 87 88 |
# File 'lib/discord_rda/entity/embed.rb', line 86 def empty? title.nil? && description.nil? && !has_fields? end |
#has_fields? ⇒ Boolean
Check if embed has fields
32 33 34 |
# File 'lib/discord_rda/entity/embed.rb', line 32 def has_fields? fields.any? end |
#has_media? ⇒ Boolean
Check if embed has image or thumbnail
80 81 82 |
# File 'lib/discord_rda/entity/embed.rb', line 80 def has_media? @raw_data['image'] || @raw_data['thumbnail'] end |