Fixes Missing Reminders From Empty Caches#1919
Conversation
Duplicates the `get_or_fetch_member` utility for users.
Refractors the reminders cog to not check for users in cache during startup, when they are most likely to be missing. Tries to fetch from the discord API if user could not be found in cache. Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
2dae405 to
5debba4
Compare
|
This is no longer blocked by python-discord/site#618 as its been merged! |
jchristgit
left a comment
There was a problem hiding this comment.
Hassan my beloved
After Mark's comments are addressed, this looks good to me.
|
Bumping this PR, would anyone like to take over? |
Keeping ensure_valid_reminder separate wasn't improving readability; it required a complex return type.
Inactive reminders aren't used anywhere, so they may as well just be deleted.
It's only used for a mention, which can trivially be created manually.
Both try_send_reminder and send_reminder delete the reminder, so allowing them both to run simultaneously for the same reminder could lead to a race condition. Admittedly, it'd be quite rare, since it'd require the reminder to become invalid after send_reminder has been called.
The exact time isn't used, so it's simpler to just used a boolean to determine whether the reminder is late.
|
In hindsight, the DB should have been modified to store the timestamp of the last send attempt rather than a count of failures. The latter approach is flawed because if the bot restarts immediately after failing, it will instantly try again rather than waiting. |
|
Hmmm. Given #2080 should have fixed the original issue, I'm not sure what the benefit of this retry approach is any more. |
It fixed it by doing away with the author check. This means it still sends the reminder even if the user left the server. |
Doesn't |
|
@wookie184 Yes, actually. I guess I don't know what the point is. @HassanAbouelela ? |
|
This PR was written before that one and opted not to do away with the checks. If we don't care about the check anymore, then this is redundant. |
|
I'm going to close this then. I don't see any benefit to checking the user if it can't reliably know whether they're in the guild. |
Blocked by python-discord/site#618.
See #1916 for more info. This PR shouldn't close that issue.
I updated the reminders cog to try and get around the issue with missing users in the cache during startup. To try and resolve that issue, I switched to fetching as a fallback if the user wasn't found. To avoid accidentally hammering the discord API with fetch requests at startup, I removed the validity checks from the init function, instead opting to only run the check during the send function. It doesn't cost much to fail the task later.