Open IncPlusPlus opened 3 years ago
I was just about to open an issue for that.
The exception is caused by the if statements (starting at DiscordRpcClient.cs:303) not accounting for CurrentPresence == null && pm.Presence == null
. This leads to RichPresence.Merge(BaseRichPresence)
being called, which just assumes that the argument is not null
.
Exchanging the if
and else if
checks (i.e. testing for pm.Presence == null
first) should prevent the NRE from happening.
Though, the fact that line 486 nulls CurrentPresence
, which results in CurrentPresence
being set to null
twice (first in DiscordRpcClient.SetPresence(RichPresence)
and then in DiscordRpcClient.ProcessMessage(IMessage)
), suggests, that maybe there was some kind of planning mistake and the whole algorithm should be revised. 🤷
Describe the bug When calling ClearPresence on an active client. An error is logged. This is definitely a bug. Interestingly, the rich presence status is successfully cleared from Discord despite this error.
To Reproduce Steps to reproduce the behavior:
client.SetPresence(new RichPresence(){})
client.ClearPresence()
This error only seems to happen if there's an existing presence. If one was never set,
ClearPresence
. Also, if one was cleared already, callingClearPresence
again doesn't log the error a second time.Expected behavior The status is cleared but without logging an error.
Desktop:
Additional context In case it matters, it's worth noting that my project is using the null safety feature of C# by having
<Nullable>enable</Nullable>
inside of the mainPropertyGroup
of the .csproj file.Logs