Properly handle locked channel being deleted
This commit is contained in:
parent
b8c64bae31
commit
7dcfd1aaf7
1 changed files with 15 additions and 15 deletions
|
@ -14,6 +14,7 @@ from jarvis_tasks.util import runat
|
|||
|
||||
async def _unlock(channel: GuildChannel, lock: Lock, logger: Logger) -> None:
|
||||
logger.debug(f"Deactivating lock {lock.id}")
|
||||
try:
|
||||
overwrite = get(channel.permission_overwrites, id=lock.guild)
|
||||
if overwrite and lock.original_perms:
|
||||
overwrite.allow = lock.original_perms.allow
|
||||
|
@ -23,13 +24,12 @@ async def _unlock(channel: GuildChannel, lock: Lock, logger: Logger) -> None:
|
|||
except Exception:
|
||||
logger.debug("Locked channel deleted, ignoring error")
|
||||
elif overwrite and not lock.original_perms:
|
||||
try:
|
||||
await channel.delete_permission(target=overwrite, reason="Automatic unlock")
|
||||
except Exception:
|
||||
logger.debug("Locked channel deleted, ignoring error")
|
||||
else:
|
||||
logger.debug("Permission neither exists not existed")
|
||||
lock.active = False
|
||||
except Exception:
|
||||
logger.debug("Locked channel deleted, ignoring error")
|
||||
await lock.commit()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue