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

Add note about why there is a seemingly superfluous check for whether the member is part of the guild #201

Merged
merged 6 commits into from May 11, 2024

Conversation

MattyTheHacker
Copy link
Member

Puts the check to make sure the user is in the guild to be the very first check as this supersedes all others because if they're not in the server there's no point checking anything else.

@MattyTheHacker MattyTheHacker self-assigned this May 9, 2024
@MattyTheHacker MattyTheHacker added the enhancement New feature or request label May 9, 2024
Copy link
Member

@CarrotManMatt CarrotManMatt left a comment

Choose a reason for hiding this comment

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

This check can be moved even sooner, to line 87.

@MattyTheHacker
Copy link
Member Author

I don't think it can? cos you'd be saying loop over the members in the guild then check if the member is in the guild wouldn't you?

@CarrotManMatt
Copy link
Member

Yh, it seems stupid. But I think there's something wrong with the caching from pycord here. Because surely the logic of "we're looping through the guild members" holds true even further down in the condition checks? How can the member be part of the main guild at line 87, but suddenly not at line 127?

@CarrotManMatt
Copy link
Member

I would suggest that if we think there's a possibility that the user is leaving the server between the start and the checks, the. The "is in guild" check should be as close to the action to be taken as possible.

If it is a caching issue, moving this check higher leaves a greater gap for the user to leave before we want to send them a message.

@MattyTheHacker
Copy link
Member Author

yeah there's definitely something funky going on - my guess was something along the lines of yeah it's doing the loop, then before it gets to person xyz they've already left but idk

@MattyTheHacker
Copy link
Member Author

MattyTheHacker commented May 9, 2024

counter proposal: every single line of this method should just check if the user is in the guild over and over again /s

@MattyTheHacker
Copy link
Member Author

I reckon bin this for now, we'll see if the new induction check stuff helps and if not we can reconsider this

@CarrotManMatt
Copy link
Member

CarrotManMatt commented May 9, 2024

yeah there's definitely something funky going on - my guess was something along the lines of yeah it's doing the loop, then before it gets to person xyz they've already left but idk

If this is currently our best guess, I think we have the greatest chance of success by keeping the check closer. Sure it hurts performance a tiny bit in some cases as extra checks are performed despite this one later failing, but if rather that than open the door to random request.Forbidden exceptions.

It might be worthwhile, rather than moving the check further away, just adding a note comment explaining why this check is there and why it's in that location

# NOTE: blah blah blah.

@CarrotManMatt CarrotManMatt reopened this May 9, 2024
@CarrotManMatt CarrotManMatt added refactor Improvements to the codebase that do not directly affect users and removed enhancement New feature or request labels May 9, 2024
@MattyTheHacker MattyTheHacker removed their assignment May 9, 2024
@CarrotManMatt CarrotManMatt added the good first issue Good for newcomers label May 9, 2024
@CarrotManMatt CarrotManMatt self-assigned this May 9, 2024
CarrotManMatt
CarrotManMatt previously approved these changes May 9, 2024
@CarrotManMatt CarrotManMatt added documentation Improvements or additions to documentation and removed refactor Improvements to the codebase that do not directly affect users labels May 9, 2024
@CarrotManMatt CarrotManMatt changed the title Move pre-reminder check to be first Add note about why there is a seemingly superfluous check for whether the member is part of the guild May 9, 2024
@CarrotManMatt CarrotManMatt merged commit 98c30cb into main May 11, 2024
8 checks passed
@CarrotManMatt CarrotManMatt deleted the move-member-intro-check branch May 11, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants