Skip to content

Commit 635f4f4

Browse files
committed
Problem here - this would constantly throw NullReferenceExceptions because it was trying to merge with a value of pm.Presence that was null (which Merge() cannot do).
So, we can check if the received presence is null first before trying to do Merge.
1 parent 5548f5b commit 635f4f4

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

DiscordRPC/DiscordRpcClient.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,13 @@ private void ProcessMessage(IMessage message)
300300
if (pm != null)
301301
{
302302
//We need to merge these presences together
303-
if (CurrentPresence == null)
304-
{
305-
CurrentPresence = (new RichPresence()).Merge(pm.Presence);
306-
}
307-
else if (pm.Presence == null)
303+
if (pm.Presence == null)
308304
{
309305
CurrentPresence = null;
310-
}
311-
else
306+
} else if (CurrentPresence == null)
307+
{
308+
CurrentPresence = (new RichPresence()).Merge(pm.Presence);
309+
} else
312310
{
313311
CurrentPresence.Merge(pm.Presence);
314312
}

0 commit comments

Comments
 (0)