#Member roles before/after in MemberUpdate

1 messages · Page 1 of 1 (latest)

warped forge
#

Hi,
I'm currently @ the latest nightly and started getting weird (out-of-sync?) behavior regarding the member update event and the roles before/after - I'm checking whether the member had / has the server booster role by ID (single server owned by me):

  1. A person applies boost
  2. BOTH args.RolesBefore and args.RolesAfter contain the booster role

This weird (wrong?) behavior seems to occur only if the member added 2 or more boosts. With a single one it works as expected - the roles before does not contain the booster role while the roles after does contain the booster role.
The member update event always occurs only once.

Wondering whether it's some caching (therefore lib related) issue (or similar) or discord itself being special.
As far as I remember before updating the lib from 5.0.0-nightly-02304 to latest (first 5.0.0-nightly-02512 now 5.0.0-nightly-02531) I didn't experience such issue but also I didn't use this feature (boost tracking) for quite some time (hence the bigger version bump).

Check is done via:

var hasBoostNow = args.RolesAfter.FirstOrDefault(r => r.Id == _options.Value.BoosterRoleId) is not null;
var hadBoostBefore = args.RolesBefore.FirstOrDefault(r => r.Id == _options.Value.BoosterRoleId) is not null;
        
_logger.LogInformation("Checking member: {MemberUsername}:{MemberDisplayName} for booster role - had: {Had}, has: {Has}", args.Member.Username, args.Member.DisplayName, hadBoostBefore, hasBoostNow);
#

Member roles before/after in MemberUpdate

hardy bobcat
#

This weird (wrong?) behavior seems to occur only if the member added 2 or more boosts. With a single one it works as expected - the roles before does not contain the booster role while the roles after does contain the booster role.
this would indicate a discord issue

#

though, *Before fields are generally not guaranteed to be reliable and you shouldn't use them as your source of truth

warped forge
#

Is there any other, more reliable way to check whether a member just boosted the server, esp. assuming it's discord doing something weird?

#

The PremiumSince would also use before/after comparison ig

hardy bobcat
#

no, just check how far back it lies

#

if PremiumSince is at most a few seconds past

warped forge
#

True that would work, alright I'll change the behavior to that for now, meanwhile I'll add some more logging to see whether it's really discords fault

hardy bobcat
#

i don't really know why it would behave like that; if it also broke with only a single boost that would make sense to me