From 610bf4baa30a8d62c936c3e23fc990718389136f Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Sun, 1 Dec 2019 18:09:23 +0200 Subject: [PATCH] Fallback channel name to channel ID Fixes #227 --- DiscordChatExporter.Core.Services/DataService.Parsers.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DiscordChatExporter.Core.Services/DataService.Parsers.cs b/DiscordChatExporter.Core.Services/DataService.Parsers.cs index 3d301edb..cb3354b9 100644 --- a/DiscordChatExporter.Core.Services/DataService.Parsers.cs +++ b/DiscordChatExporter.Core.Services/DataService.Parsers.cs @@ -50,7 +50,12 @@ namespace DiscordChatExporter.Core.Services // If the name is blank, it's direct messages if (string.IsNullOrWhiteSpace(name)) - name = json["recipients"].Select(ParseUser).Select(u => u.Name).JoinToString(", "); + name = json["recipients"]?.Select(ParseUser).Select(u => u.Name).JoinToString(", "); + + // If the name is still blank for some reason, fallback to ID + // (blind fix to https://github.com/Tyrrrz/DiscordChatExporter/issues/227) + if (string.IsNullOrWhiteSpace(name)) + name = id; return new Channel(id, parentId, guildId, name, topic, type); }