From de763f8aaaadf1b0de5f1943401944c12b5e0aa9 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Sun, 8 Apr 2018 12:46:55 +0300 Subject: [PATCH] Try to parse DM group chat names instead of only using participants Fixes #41 --- DiscordChatExporter.Core/Services/DataService.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DiscordChatExporter.Core/Services/DataService.cs b/DiscordChatExporter.Core/Services/DataService.cs index 06abb3514..be0832b11 100644 --- a/DiscordChatExporter.Core/Services/DataService.cs +++ b/DiscordChatExporter.Core/Services/DataService.cs @@ -60,8 +60,13 @@ private Channel ParseChannel(JToken token) if (type.IsEither(ChannelType.DirectTextChat, ChannelType.DirectGroupTextChat)) { guildId = Guild.DirectMessages.Id; - var recipients = token["recipients"].Select(ParseUser); - name = recipients.Select(r => r.Name).JoinToString(", "); + + // Try to get name if it's set + name = token["name"]?.Value(); + + // Otherwise use recipients as the name + if (name.IsBlank()) + name = token["recipients"].Select(ParseUser).Select(u => u.Name).JoinToString(", "); } else {