diff --git a/DiscordChatExporter.Core/Discord/Data/Embeds/Embed.cs b/DiscordChatExporter.Core/Discord/Data/Embeds/Embed.cs index 619550f8..2839ccb3 100644 --- a/DiscordChatExporter.Core/Discord/Data/Embeds/Embed.cs +++ b/DiscordChatExporter.Core/Discord/Data/Embeds/Embed.cs @@ -23,6 +23,10 @@ public partial record Embed( EmbedVideo? Video, EmbedFooter? Footer) { + // Embeds can only have one image according to the API model, + // but the client can render multiple images in some cases. + public EmbedImage? Image => Images.FirstOrDefault(); + public SpotifyTrackEmbedProjection? TryGetSpotifyTrack() => SpotifyTrackEmbedProjection.TryResolve(this); diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index 514e4315..5aabd51a 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -150,11 +150,10 @@ internal class JsonMessageWriter : MessageWriter await WriteEmbedImageAsync(embed.Thumbnail, cancellationToken); } - // Legacy: backwards-compatibility for old embeds with a single image - if (embed.Images.Count > 0) + if (embed.Image is not null) { _writer.WritePropertyName("image"); - await WriteEmbedImageAsync(embed.Images[0], cancellationToken); + await WriteEmbedImageAsync(embed.Image, cancellationToken); } if (embed.Footer is not null) diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index 29d8156d..10e64c30 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -392,11 +392,11 @@ } // Generic image embed - else if (embed.Kind == EmbedKind.Image && !string.IsNullOrWhiteSpace(embed.Url)) + else if (embed.Kind == EmbedKind.Image && !string.IsNullOrWhiteSpace(embed.Image?.Url)) {
- - Embedded image + + Embedded image
}