Visitar URL original
Fix memberBefore missing roles in GuildMemberUpdateEventArgs when not… by selfdocumentingcode · Pull Request #1364 · DSharpPlus/DSharpPlus · GitHub
Skip to content

Fix memberBefore missing roles in GuildMemberUpdateEventArgs when not… - #1364

Merged
OoLunar merged 3 commits into
DSharpPlus:masterfrom
selfdocumentingcode:fix/missingRolesInGuildMemberUpdateEventArgs
Aug 9, 2022
Merged

OoLunar merged 3 commits into
DSharpPlus:masterfrom
selfdocumentingcode:fix/missingRolesInGuildMemberUpdateEventArgs

Conversation

@selfdocumentingcode

@selfdocumentingcode selfdocumentingcode commented Aug 2, 2022 •

Copy link
Copy Markdown

Summary

Fix memberBefore missing roles in GuildMemberUpdateEventArgs when it's not retrieved from cache.

Details

When the pre-update member object is not in the guild member cache, the copy is created from a DiscordUser object which doesn't have roles.

Changes proposed

Initalize memberBefore copy from TransportMember object so that it populates roles.
In addition, update cached guild member in OnGuildMemberUpdateEventAsync internal event handler

Notes

Follow-up to #1359

@selfdocumentingcode
selfdocumentingcode marked this pull request as draft August 2, 2022 20:58
@selfdocumentingcode
selfdocumentingcode marked this pull request as ready for review August 2, 2022 21:51
@selfdocumentingcode

Copy link
Copy Markdown
Author

Alternatively, it might be safer to remove the member from the guild members "cache", instead of updating it, and fetch a fresh one the next time it's needed. Thoughts?

@OoLunar

OoLunar commented Aug 4, 2022

Copy link
Copy Markdown
Contributor

The library does not and should not make any hidden requests. What we currently do (or should be doing) is subscribing to the member added, updated and removed events and update the cache accordingly

@OoLunar
OoLunar merged commit 8447942 into DSharpPlus:master Aug 9, 2022
@selfdocumentingcode

Copy link
Copy Markdown
Author

@OoLunar sorry I didn't answer you yet. I've been away, traveling and I won't be home until next week. I will create a subsequent PR and fix what you suggested.

@OoLunar

OoLunar commented Aug 9, 2022

Copy link
Copy Markdown
Contributor

@selfdocumentingcode Don't worry about it. I committed to your branch directly and fixed my complaints. Enjoy your traveling!

VelvetToroyashi pushed a commit that referenced this pull request Jan 28, 2023
* Change GuildMemberUpdatedEventArgs to contain before and after DiscordMember objects (#1359)

* Fix #1325 - WebhookBuilder Throws Bad Request (#1363)

* use DiscordMentions on RestWebhookPayloads

* keep null value when null

* remove null check from discordmentions arg

* Implemented PATCH /guilds/:guild_id/roles (tested) (#1311)

* Fix compile errors caused by #1333

* Update hosting.md

* Remove unused DSharpPlus.MSTest folder

* Cache threads upon thread creation (#1366)

* categorization for the cnext default help command (#1371)

* Fix memberBefore missing roles in GuildMemberUpdateEventArgs when not… (#1364)

* Fix memberBefore missing roles in GuildMemberUpdateEventArgs when not in cache

* Update cached guild member in OnGuildMemberUpdateEventAsync internal event handler

* Update DiscordClient.Dispatch.cs

Co-authored-by: Lunar Starstrum <lunar@forsaken-borders.net>

* Ported CommandsNext cooldown attribute to Slash Commands (#1375)

* Ported CommandsNext cooldown attribute to Slash Commands; Fixed compiler warnings and suggestions

* Still untested; Attempted to resolve @Erisa's review

* Made all exceptions inherit from ApplicationCommandExecutionChecksFailedException (previously Exception)

* Start on converters

* Added custom converter support:

- No, I did not implement the checks in the converters. I felt that should be done in a separate area of code
- Yes, I did break my Enter, Backspace, D and Apostrophe keys because of this PR. Don't ask how.

* Fixed startup errors; Added DiscordMessageArgumentConverter; Added (un)register converter methods (untested).

* Fix registering converters

* (untested) Add number converters; Fix enums not registering choices correctly

* Add DiscordMember converter; Switch from ArgumentException to new MissingArgumentConverterException

* Actually fix Nullable and update TimeSpan converter to match with CNext

* Add params/array support

* Boundry checks

* [ci-skip] Resolve naming errors

* "One less variable allocation"

* Remove unsupport NETSTANDARD1_3 support; Un-Emziware those variable names

* Remove unused property

* Extra parameter limit attribute check

* Remove UnregisterConverter(s) methods

* Changed BCL types to use framework names

* Pass InnerException to prevent passing TargetInvocationException

* Fix enum support (again)

---------

Co-authored-by: Bob Loblaw <razvanmandache@gmail.com>
Co-authored-by: waffle-lord <76401815+waffle-lord@users.noreply.github.com>
Co-authored-by: Iris Féanorá <61018569+ExaInsanity@users.noreply.github.com>
@selfdocumentingcode
selfdocumentingcode deleted the fix/missingRolesInGuildMemberUpdateEventArgs branch September 21, 2024 21:46
OoLunar added a commit that referenced this pull request Oct 3, 2024
#1364)

* Fix memberBefore missing roles in GuildMemberUpdateEventArgs when not in cache

* Update cached guild member in OnGuildMemberUpdateEventAsync internal event handler

* Update DiscordClient.Dispatch.cs

Co-authored-by: Lunar Starstrum <lunar@forsaken-borders.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants