diff --git a/.pylintrc b/.pylintrc index b44d61e..e6eb8b2 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,4 +3,5 @@ disable= C0114, # docstrings C0115, C0116, - C0301 #line too long + C0301, #line too long + R0912 diff --git a/main.py b/main.py index 1fc4271..0f4e5ea 100644 --- a/main.py +++ b/main.py @@ -298,17 +298,22 @@ async def backup_channel(channel, last_message_id): raise # pull all messages since message - while True: - messages = await channel.history(limit=100, after=after, oldest_first=True).flatten() - if not messages: - break - - # Process messages - for message in messages: - backup_msg = extract_message(message) - write_to_storage(backup_msg) - - after = messages[-1] + try: + while True: + messages = await channel.history(limit=100, after=after, oldest_first=True).flatten() + if not messages: + break + + # Process messages + for message in messages: + backup_msg = extract_message(message) + write_to_storage(backup_msg) + + after = messages[-1] + except nextcord.Forbidden: + print('No permission to read channel. Check roles in discord!') + # exit the function with no new location msg id + return None # Seal the manifest seal_manifest(channel.guild.id, channel.id)