Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed State.MemberAdd to set fields individually #533

Merged
merged 1 commit into from Apr 13, 2018

Conversation

CarsonHoffman
Copy link
Collaborator

This fixes #532. Though it's not mentioned on the Discord docs, it seems Member.JoinedAt isn't sent in member updates (it is sent in member chunks), which caused the value to be overwritten to an empty value after member updates. This pull request changes State.MemberAdd to handle each field individually, similarly to other function in the State that have similar dilemmas, checking for an empty JoinedAt field.

@CarsonHoffman
Copy link
Collaborator Author

It seems the check failed to a network timeout completely unrelated to the code changed. :(

@wtfuzzy
Copy link

wtfuzzy commented Apr 12, 2018

Confirmed, this fixed the issue I reported in #532 for me. (And, just FTR, I built it fine with 1.10.1.)

@@ -299,7 +299,17 @@ func (s *State) MemberAdd(member *Member) error {
members[member.User.ID] = member
guild.Members = append(guild.Members, member)
} else {
*m = *member // Update the actual data, which will also update the member pointer in the slice
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you implement this in the same way as we do in Guild, it will mean that we don't have to update 2 places whenever the Member struct changes, ie:

// We are about to replace `m` in the state with `member`, but first we need to
// make sure we preserve any fields that the `member` doesn't contain from `m`.
if member.JoinedAt == "" {
  member.JoinedAt = m.JoinedAt
}
*m = *member

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like a better solution; will do.

@iopred iopred merged commit 293b411 into bwmarrin:develop Apr 13, 2018
@bwmarrin bwmarrin added this to the v0.19.0 milestone Nov 2, 2018
ErikMcClure pushed a commit to ErikMcClure/discordgo that referenced this pull request Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants