From d2f004b0807d90d4a9448cd128f9c5e443c8738a Mon Sep 17 00:00:00 2001 From: Luna Date: Mon, 4 Feb 2019 21:27:12 -0300 Subject: [PATCH] guilds: handle removal of ask/sys channel --- litecord/blueprints/guilds.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 810cf29..cb906bc 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -246,6 +246,17 @@ async def _update_guild(guild_id): channel_fields = ['afk_channel_id', 'system_channel_id'] for field in [f for f in channel_fields if f in j]: + # setting to null should remove the link between the afk/sys channel + # to the guild. + if j[field] is None: + await app.db.execute(f""" + UPDATE guilds + SET {field} = NULL + WHERE id = $1 + """, guild_id) + + continue + chan = await app.storage.get_channel(int(j[field])) if chan is None: