Repository navigation
fix: unmute members when their mute expires - #194
Conversation
The scheduler treated second-based deadlines as milliseconds and then slept inside the loop, so a long ban blocked every automatic unmute. Co-authored-by: Cursor <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #194 +/- ##
==========================================
+ Coverage 66.60% 68.32% +1.72%
==========================================
Files 54 76 +22
Lines 3177 3770 +593
==========================================
+ Hits 2116 2576 +460
- Misses 1061 1194 +133 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Codecov rejected the patch because the new scheduler and unmute branches were untested. Co-authored-by: Cursor <[email protected]>
|
Nice find with the seconds vs milliseconds bug. I checked prod: there are 77 old mutes waiting, the oldest from January 2024, so this fix is really needed. Tests pass for me on top of current main. One thing to keep in mind: the first run after deploy will process all of them at once. |
The minute loop was leaving those rows in place and looking them up again forever. Expiry now has a single scheduler path. Co-authored-by: Cursor <[email protected]>
dimoschi
left a comment
There was a problem hiding this comment.
Looks good. unban_member and unmute_member only use .id, so passing discord.Object works, and the stale records get cleared once. Tests pass on top of current main.
Small optional thing: for unbans we could skip get_member_or_user and pass Object(id=...) directly. A banned user is never a guild member, so the lookup always fails first.
Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that apply.Proposed changes
Automatic unmute never ran.
unmute_timeandunban_timeare stored as Unix seconds, but the scheduler compared them to a millisecond cutoff, so every mute and ban matched, including permanent bans of about 500 weeks. The job then slept insideschedule()until the furthest deadline, and unbans run before unmutes, so a long ban blocked every unmute./mutealso started its unmute task without keeping a reference. On Python 3.13 the event loop only holds a weak reference, so that sleeping task could be garbage-collected and never fire.This change:
/mute.Checklist
Put an
xin the boxes that apply.doc.
Additional context
Covered by
tests/src/cmds/automation/test_scheduled_tasks.py: a far-future ban does not block scheduling, and an expired mute is cleared while a mute still hours away is left in place.Made with Cursor