Add support for reactions (#62)

This commit is contained in:
IntriguingTiles
2018-06-25 15:27:45 -06:00
committed by Alexey Golub
parent 61dce7c1a8
commit e8436faf66
7 changed files with 85 additions and 2 deletions

View File

@@ -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<int>();
var me = json["me"].Value<bool>();
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);
}
}
}