fix(Activity): accept non-string application ids #1513
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been writing some code to read VoiceStates on application start-up and noticed it wasn't finding records where I would expect.
I noticed this coincided with the error
wsapi.go:646:onEvent() error unmarshalling GUILD_CREATE event, json: cannot unmarshal number into Go struct field Presence.presences.activities of type string
.After doing some digging, I realised that discord is sending along activities with an
application_id
of1
in some cases (Note that is1
the integer, not"1"
the string)This causes the
GUILD_CREATE
event (and others) to fail parsing and not get added to the state, meaning I then have no way of accessing the current voice states when my app starts up.I have run my app against my
discordgo
fork and it is now working as expected.I know this logic isn't ideal, but I don't know of a better way to fix it given:
Example activity with a bad app id:
Out of 1142 activities found on this
GUILD_CREATE
event, the above is the single activity with a non-string application_id.