SpaceManiac / discord-rs

Rust library for the Discord chat client API
MIT License
387 stars 94 forks source link

Fix error return due to incomplete fields in USER_UPDATE events #144

Closed bdonlan closed 7 years ago

bdonlan commented 7 years ago

Discord sends incomplete CurrentUser structures for USER_UPDATE events in certain cases. This change makes most of the fields Options, and changes the state logic to retain the prior value of the field if it is missing in the update.

I've left id, username, and discriminator alone as I suspect these are the most commonly used fields (and thus would have the most compatibility impact if changed), and they do seem to be present, at least for the messages I've seen so far.

Closes #139.

tinaun commented 7 years ago

wouldn't it be better if the incomplete structs were their own type? having Option fields at all feels weird.

bdonlan commented 7 years ago

Will resubmit with a separate type