Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
561 stars 93 forks source link

Allows nullable fields to be ignored during JSON deserialization #213

Closed RecklessBoon closed 1 year ago

RecklessBoon commented 1 year ago

I have had some users provide some error messages like the following (account info redacted since it's irrelevant)

[ERROR]: Failed to process event! Error converting value {null} to type 'DiscordRPC.User+PremiumType'. Path 'user.premium_type'.
[ERROR]: Data: {"cmd":"DISPATCH","data":{"v":1,"config":{"cdn_host":"cdn.discordapp.com","api_endpoint":"//discord.com/api","environment":"production"},"user":{"id":"==REDACTED==","username":"==REDACTED==","discriminator":"==REDACTED==","avatar":"==REDACTED==","avatar_decoration":null,"bot":false,"flags":32,"premium_type":null}},"evt":"READY","nonce":null}

I have not been able to replicate this issue, however according to the documentation on the Discord Developer Portal - Documentation | Users Resource section, there are a handful of fields that can come in as null. This should make the library closer to spec and hopefully alleviate the issues my users are facing. Let me know if you want to discuss or if you have some way to test this before merging and releasing.

Thanks!

dowmeister commented 1 year ago

Fix confirmed. Had a user today reporting this, this PR fix it

Lachee commented 1 year ago

Thank you for your contribution. This is now released in v1.1.1 ✨🌟 🎉