mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-16 16:14:26 -04:00
Add support for gif
stickers
This commit is contained in:
parent
cfbbc4b8e2
commit
d0873ecfa7
3 changed files with 10 additions and 3 deletions
|
@ -7,7 +7,12 @@ using JsonExtensions.Reading;
|
|||
namespace DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
@ -22,6 +27,7 @@ public record Sticker(Snowflake Id, string Name, StickerFormat Format, string So
|
|||
StickerFormat.Png => "png",
|
||||
StickerFormat.Apng => "png",
|
||||
StickerFormat.Lottie => "json",
|
||||
StickerFormat.Gif => "gif",
|
||||
_ => throw new InvalidOperationException($"Unknown sticker format '{format}'.")
|
||||
}
|
||||
);
|
||||
|
|
|
@ -4,5 +4,6 @@ public enum StickerFormat
|
|||
{
|
||||
Png = 1,
|
||||
Apng = 2,
|
||||
Lottie = 3
|
||||
Lottie = 3,
|
||||
Gif = 4
|
||||
}
|
||||
|
|
|
@ -634,7 +634,7 @@
|
|||
@foreach (var sticker in message.Stickers)
|
||||
{
|
||||
<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">
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue