Merge pull request 'perf: use channel.purge() instead of per-message delete loops (#93)' (#108) from ai/major-domo-v2#93 into next-release
All checks were successful
Build Docker Image / build (push) Successful in 1m21s

Reviewed-on: #108
This commit is contained in:
cal 2026-03-20 17:44:29 +00:00
commit f0934937cb
2 changed files with 9 additions and 15 deletions

View File

@ -568,14 +568,9 @@ class AdminCommands(commands.Cog):
return
try:
# Clear all messages from the channel
deleted_count = 0
async for message in live_scores_channel.history(limit=100):
try:
await message.delete()
deleted_count += 1
except discord.NotFound:
pass # Message already deleted
# Clear all messages from the channel using bulk delete
deleted_messages = await live_scores_channel.purge(limit=100)
deleted_count = len(deleted_messages)
self.logger.info(f"Cleared {deleted_count} messages from #live-sba-scores")

View File

@ -112,7 +112,8 @@ class LiveScorebugTracker:
for text_channel_id, sheet_url in all_scorecards:
try:
scorebug_data = await self.scorebug_service.read_scorebug_data(
sheet_url, full_length=False # Compact view for live channel
sheet_url,
full_length=False, # Compact view for live channel
)
# Only include active (non-final) games
@ -188,9 +189,8 @@ class LiveScorebugTracker:
embeds: List of scorebug embeds
"""
try:
# Clear old messages
async for message in channel.history(limit=25):
await message.delete()
# Clear old messages using bulk delete
await channel.purge(limit=25)
# Post new scorebugs (Discord allows up to 10 embeds per message)
if len(embeds) <= 10:
@ -216,9 +216,8 @@ class LiveScorebugTracker:
channel: Discord text channel
"""
try:
# Clear all messages
async for message in channel.history(limit=25):
await message.delete()
# Clear all messages using bulk delete
await channel.purge(limit=25)
self.logger.info("Cleared live-sba-scores channel (no active games)")