fix: improve logging and pagination logic in delete_old_messages function
This commit is contained in:
@@ -539,17 +539,11 @@ def delete_old_messages(minutes: int = 6) -> None:
|
||||
headers, DISCORD_CHANNEL_ID, webhook_id, author_id, cutoff, last_message_id
|
||||
)
|
||||
|
||||
# Exit loop if no more messages to delete
|
||||
# Stop scanning when a page has no eligible messages to delete.
|
||||
# Continuing pagination here can walk indefinitely through history.
|
||||
if not delete_list:
|
||||
if deleted_count == 0:
|
||||
if next_last_message_id is None or next_last_message_id == last_message_id:
|
||||
logging.info("No messages to delete.")
|
||||
break
|
||||
else:
|
||||
logging.info(
|
||||
"No messages deleted in this batch, but more messages may exist... Continuing pagination.")
|
||||
last_message_id = next_last_message_id
|
||||
continue
|
||||
logging.info("No messages to delete.")
|
||||
else:
|
||||
logging.info("No more messages to delete.")
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user