Skip to content

Commit

Permalink
Skip invalid reactions instead of crashing (Tyrrrz#1227)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored and cooljeanius committed Jul 8, 2024
1 parent a58ae35 commit 6ffe2d8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions DiscordChatExporter.Core/Discord/DiscordClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,14 @@ public async IAsyncEnumerable<User> GetMessageReactionsAsync(
.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;
Expand Down

0 comments on commit 6ffe2d8

Please sign in to comment.