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:
|
async def _unlock(channel: GuildChannel, lock: Lock, logger: Logger) -> None:
|
||||||
logger.debug(f"Deactivating lock {lock.id}")
|
logger.debug(f"Deactivating lock {lock.id}")
|
||||||
|
try:
|
||||||
overwrite = get(channel.permission_overwrites, id=lock.guild)
|
overwrite = get(channel.permission_overwrites, id=lock.guild)
|
||||||
if overwrite and lock.original_perms:
|
if overwrite and lock.original_perms:
|
||||||
overwrite.allow = lock.original_perms.allow
|
overwrite.allow = lock.original_perms.allow
|
||||||
|
@ -23,13 +24,12 @@ async def _unlock(channel: GuildChannel, lock: Lock, logger: Logger) -> None:
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.debug("Locked channel deleted, ignoring error")
|
logger.debug("Locked channel deleted, ignoring error")
|
||||||
elif overwrite and not lock.original_perms:
|
elif overwrite and not lock.original_perms:
|
||||||
try:
|
|
||||||
await channel.delete_permission(target=overwrite, reason="Automatic unlock")
|
await channel.delete_permission(target=overwrite, reason="Automatic unlock")
|
||||||
except Exception:
|
|
||||||
logger.debug("Locked channel deleted, ignoring error")
|
|
||||||
else:
|
else:
|
||||||
logger.debug("Permission neither exists not existed")
|
logger.debug("Permission neither exists not existed")
|
||||||
lock.active = False
|
lock.active = False
|
||||||
|
except Exception:
|
||||||
|
logger.debug("Locked channel deleted, ignoring error")
|
||||||
await lock.commit()
|
await lock.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue