perf: use channel.purge() instead of per-message delete loops #93
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#93
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Multiple locations iterate channel history and call
message.delete()in a loop — each delete is a separate Discord API call subject to rate limiting (5/sec per channel).commands/admin/management.pylines 572–578 (admin_clear_scorecards)Up to 100 individual API calls. Note:
admin_clearin the same file already correctly useschannel.purge().tasks/live_scorebug_tracker.pylines 192–193, 220–221Both
_post_scorebugs_to_channeland_clear_live_scores_channeldelete messages one at a time in achannel.history(limit=25)loop. This runs every 3 minutes on the update cycle.Fix
channel.purge()uses Discord's bulk delete API — one request for up to 100 messages. Note: only works for messages under 14 days old; if older messages are possible, add a check parameter.Impact
MEDIUM — The scorebug tracker runs every 3 minutes and adds several seconds of unnecessary latency to each cycle. Admin command goes from ~20 seconds to ~1 second for 100 messages.
PR #108 opens the fix: #108
Replaced all three
async for message in channel.history(): await message.delete()loops withawait channel.purge()— one bulk API call instead of up to 100 individual ones. Tests: 935 passed.