From 9a5697b5b58e405bac644c761e84c9649939b16e Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Tue, 30 Apr 2024 20:08:03 +0300 Subject: [PATCH] Skip invalid reactions instead of crashing (#1227) --- DiscordChatExporter.Core/Discord/DiscordClient.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DiscordChatExporter.Core/Discord/DiscordClient.cs b/DiscordChatExporter.Core/Discord/DiscordClient.cs index 4b85fec..0aa4ab1 100644 --- a/DiscordChatExporter.Core/Discord/DiscordClient.cs +++ b/DiscordChatExporter.Core/Discord/DiscordClient.cs @@ -676,10 +676,14 @@ public class DiscordClient(string token) .SetQueryParameter("after", currentAfter.ToString()) .Build(); - var response = await GetJsonResponseAsync(url, cancellationToken); + // Can be null on reactions with an emoji that has been deleted (?) + // https://github.com/Tyrrrz/DiscordChatExporter/issues/1226 + var response = await TryGetJsonResponseAsync(url, cancellationToken); + if (response is null) + yield break; var count = 0; - foreach (var userJson in response.EnumerateArray()) + foreach (var userJson in response.Value.EnumerateArray()) { var user = User.Parse(userJson); yield return user;