Skip to content

Commit

Permalink
don't set last msg on empty channel
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Jan 17, 2024
1 parent a077339 commit 141bcc8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ async def backup_channel(channel, last_message_id):
print(f'No manifest for {channel.guild.id} - {channel.id}. Likly empty channel. Skipping S3 upload.')

if after is None:
return -1
return None
return after.id


Expand Down Expand Up @@ -550,15 +550,17 @@ async def on_ready():
# Backup channels
last_msg_id = await get_last_message_id(channel)
new_last_msg_id = await backup_channel(channel, last_msg_id)
await set_last_message_id(channel, new_last_msg_id)
if last_msg_id is not None:
await set_last_message_id(channel, new_last_msg_id)

# Backup threads in channel
for thread in channel.threads:
print(f'Backing up Thread {thread.id} in Channel {channel.id} on {channel.guild.id}')

last_msg_id = await get_last_message_id(thread)
new_last_msg_id = await backup_channel(thread, last_msg_id)
await set_last_message_id(thread, new_last_msg_id)
if new_last_msg_id is not None:
await set_last_message_id(thread, new_last_msg_id)

# Quit when done
print('Notifying the heartbeat check...')
Expand Down

0 comments on commit 141bcc8

Please sign in to comment.