diff --git a/DiscordChatExporter.Core/Models/Message.cs b/DiscordChatExporter.Core/Models/Message.cs index 9102380..538090b 100644 --- a/DiscordChatExporter.Core/Models/Message.cs +++ b/DiscordChatExporter.Core/Models/Message.cs @@ -25,11 +25,13 @@ namespace DiscordChatExporter.Core.Models public IReadOnlyList Embeds { get; } + public IReadOnlyList Reactions { get; } + public IReadOnlyList MentionedUsers { get; } public Message(string id, string channelId, MessageType type, User author, DateTime timestamp, DateTime? editedTimestamp, string content, IReadOnlyList attachments, - IReadOnlyList embeds, IReadOnlyList mentionedUsers) + IReadOnlyList embeds, IReadOnlyList reactions, IReadOnlyList mentionedUsers) { Id = id; ChannelId = channelId; @@ -40,6 +42,7 @@ namespace DiscordChatExporter.Core.Models Content = content; Attachments = attachments; Embeds = embeds; + Reactions = reactions; MentionedUsers = mentionedUsers; } diff --git a/DiscordChatExporter.Core/Models/Reaction.cs b/DiscordChatExporter.Core/Models/Reaction.cs new file mode 100644 index 0000000..a1a6595 --- /dev/null +++ b/DiscordChatExporter.Core/Models/Reaction.cs @@ -0,0 +1,26 @@ +using System; + +namespace DiscordChatExporter.Core.Models +{ + public class Reaction + { + public int Count { get; } + + public bool Me { get; } + + public string Id { get; } + + public string Name { get; } + + public string Emoji { get; } + + public Reaction(int count, bool me, string id, string name) + { + Count = count; + Me = me; + Id = id; + Name = name; + Emoji = (id == "" ? name : $"<:{name}:{id}>"); + } + } +} \ No newline at end of file diff --git a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html index 4eab157..a5ec55e 100644 --- a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html +++ b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Core.html @@ -181,6 +181,16 @@ {{ end }} + + {{~ # Reactions }} +
+ {{ for reaction in message.Reactions}} +
+
{{ reaction.Emoji | FormatContent }}
+
{{ reaction.Count }}
+
+ {{ end }} +
{{ end }} diff --git a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/DarkTheme.css b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/DarkTheme.css index 388af8f..1f79b81 100644 --- a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/DarkTheme.css +++ b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/DarkTheme.css @@ -87,4 +87,8 @@ a { .chatlog__embed-footer { color: #ffffff99; +} + +.chatlog__reaction { + background-color: rgba(255, 255, 255, 0.0392157); } \ No newline at end of file diff --git a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/LightTheme.css b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/LightTheme.css index 48ea7fa..a113de0 100644 --- a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/LightTheme.css +++ b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/LightTheme.css @@ -48,4 +48,8 @@ a { .chatlog__edited-timestamp { color: #99aab5; +} + +.chatlog__reaction { + background-color: rgba(79, 84, 92, 0.0588235); } \ No newline at end of file diff --git a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Shared.css b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Shared.css index 95842c3..4346a03 100644 --- a/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Shared.css +++ b/DiscordChatExporter.Core/Resources/ExportTemplates/Html/Shared.css @@ -283,4 +283,26 @@ img { .chatlog__embed-footer-text { font-weight: 600; font-size: .75em; +} + +.chatlog__reactions { + display: flex; +} + +.chatlog__reaction { + margin: 2px; + border-radius: 3px; + display: block; + padding-right: 6px; +} + +.chatlog__reaction-emoji { + display: inline; + margin-left: 3px; + padding-right: 3px; + font-size: large; +} + +.chatlog__reaction-count { + display: inline; } \ No newline at end of file diff --git a/DiscordChatExporter.Core/Services/DataService.Parsers.cs b/DiscordChatExporter.Core/Services/DataService.Parsers.cs index dd88034..120c041 100644 --- a/DiscordChatExporter.Core/Services/DataService.Parsers.cs +++ b/DiscordChatExporter.Core/Services/DataService.Parsers.cs @@ -138,6 +138,16 @@ namespace DiscordChatExporter.Core.Services return new Embed(title, url, timestamp, color, author, description, fields, thumbnail, image, footer); } + private Reaction ParseReaction(JToken json) + { + var count = json["count"].Value(); + var me = json["me"].Value(); + var id = json["emoji"]["id"]?.ToString(); + var name = json["emoji"]["name"].ToString(); + + return new Reaction(count, me, id, name); + } + private Message ParseMessage(JToken json) { // Get basic data @@ -173,11 +183,15 @@ namespace DiscordChatExporter.Core.Services // Get embeds var embeds = json["embeds"].EmptyIfNull().Select(ParseEmbed).ToArray(); + // Get reactions + var reactions = json["reactions"].EmptyIfNull().Select(ParseReaction).ToArray(); + // Get mentioned users var mentionedUsers = json["mentions"].EmptyIfNull().Select(ParseUser).ToArray(); + return new Message(id, channelId, type, author, timestamp, editedTimestamp, content, attachments, embeds, - mentionedUsers); + reactions, mentionedUsers); } } } \ No newline at end of file