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

Discord Member IsPending not updating when passing membership screening #1373

Open
BlackLotusLV opened this issue Aug 9, 2022 · 7 comments
Milestone

Comments

@BlackLotusLV
Copy link

BlackLotusLV commented Aug 9, 2022

Make sure you familiarize yourself with our contributing guidelines.

Summary

IsPending for DiscordMember does not update after agreeing to the rules via membership screening.

Details

D#+ does not update IsPending status if user updates it while bot is active.

  1. Start Bot.
  2. Join the server and IsPending status will be true.
  3. Agree to rules via membership screening, IsPending status is still true. (it should be false)

But if you join the server and agree to rules and only the start the bot, IsPending status is false. So it does get the initial info correctly, just fails to update it.

@VelvetToroyashi
Copy link
Member

VelvetToroyashi commented Aug 9, 2022

Semi-intentional change; DiscordMembers are more so data objects with convenience methods than god objects because constantly checking for places that things are and aren't updated, as well as what exactly is and isn't updated was very inconsistent across the entire library. See this PR

@BlackLotusLV
Copy link
Author

I find this to be quite a big issue in my use case. I use membership screening in my server and the welcome message is sent only after they have agreed. Previously it was simply done by checking past IsPending to current one in the member updated event. Now got to add other checks like adding a role to the user and checking for role count, to not spam whenever the change the nickname, until the bot has restarted.
And quite idiotic to need to restart the bot every time you want to check on a smaller server weather the person has accepted the rules or not.

I understand that in my use case the actual solution is for discord to finally release and documentate the membership screening update thing in the API, but lets be honest, 5.0 is coming sooner than that.

@VelvetToroyashi
Copy link
Member

Previously it was simply done by checking past IsPending to current one in the member updated event.

I'd like to mention that this should work as intended? Just that if you were to pull any given member from DiscordGuild#Members, that member object would not be updated, but instead replaced with the updated object; the events should still work fine, but if that is the issue, then I'll take a look into this.

@VelvetToroyashi
Copy link
Member

Also here's the code I'm referring to.

@BlackLotusLV
Copy link
Author

BlackLotusLV commented Aug 11, 2022

Lets say I have this code running

Client.GuildMemberUpdated += AcceptRules;

public static async Task AcceptRules(object Client, GuildMemberUpdateEventArgs e)
{
   if (e.PendingBefore == null) return;
   if (e.PendingBefore.Value && !e.PendingAfter.Value)
   {
             1. send welcome message,
             2. assign role to user
    }
}

Now theoretically it only should execute the most inner if only once, right after agreeing to rules because the user was pending before but after was not.
But the code will execute again fully because the role was changed, so the event fires and code still thinks before pending was true and after pending was false. Meaning it doesn't change.

Solution was to check if the user has any roles, but lets say i remove the role, it will trigger and execute the full thing once more.

Sorry if im not explaining that well

@VelvetToroyashi
Copy link
Member

So this is in fact an issue with the event, which helps us triage this better.

@BlackLotusLV
Copy link
Author

Yes the issue is with the event, but when i call for GetMemberAsync, it should provide correct information, which, relating to isPending, is not correct.
It just makes that field useless as you can never rly on it to be accurate.

So the issue is with the isPending field not updating correctly in both, DiscordMember and the event when member is updated.

@akiraveliara akiraveliara removed the v4.x label Oct 5, 2023
@akiraveliara akiraveliara added this to the v5.0 milestone Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants