Add support for `gif` stickers

pull/1167/head 2.42.6
Tyrrrz 7 months ago
parent cfbbc4b8e2
commit d0873ecfa7

@ -7,7 +7,12 @@ using JsonExtensions.Reading;
namespace DiscordChatExporter.Core.Discord.Data; namespace DiscordChatExporter.Core.Discord.Data;
// https://discord.com/developers/docs/resources/sticker#sticker-resource // https://discord.com/developers/docs/resources/sticker#sticker-resource
public record Sticker(Snowflake Id, string Name, StickerFormat Format, string SourceUrl) public partial record Sticker(Snowflake Id, string Name, StickerFormat Format, string SourceUrl)
{
public bool IsImage => Format != StickerFormat.Lottie;
}
public partial record Sticker
{ {
public static Sticker Parse(JsonElement json) public static Sticker Parse(JsonElement json)
{ {
@ -22,6 +27,7 @@ public record Sticker(Snowflake Id, string Name, StickerFormat Format, string So
StickerFormat.Png => "png", StickerFormat.Png => "png",
StickerFormat.Apng => "png", StickerFormat.Apng => "png",
StickerFormat.Lottie => "json", StickerFormat.Lottie => "json",
StickerFormat.Gif => "gif",
_ => throw new InvalidOperationException($"Unknown sticker format '{format}'.") _ => throw new InvalidOperationException($"Unknown sticker format '{format}'.")
} }
); );

@ -4,5 +4,6 @@ public enum StickerFormat
{ {
Png = 1, Png = 1,
Apng = 2, Apng = 2,
Lottie = 3 Lottie = 3,
Gif = 4
} }

@ -634,7 +634,7 @@
@foreach (var sticker in message.Stickers) @foreach (var sticker in message.Stickers)
{ {
<div class="chatlog__sticker" title="@sticker.Name"> <div class="chatlog__sticker" title="@sticker.Name">
@if (sticker.Format is StickerFormat.Png or StickerFormat.Apng) @if (sticker.IsImage)
{ {
<img class="chatlog__sticker--media" src="@await ResolveAssetUrlAsync(sticker.SourceUrl)" alt="Sticker"> <img class="chatlog__sticker--media" src="@await ResolveAssetUrlAsync(sticker.SourceUrl)" alt="Sticker">
} }

Loading…
Cancel
Save