From 469665bcceb2193e45d7156c8935f68e019e4477 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 22 Aug 2021 11:45:31 +0200 Subject: Prevent error on uncategorized channel. If the channel is not part of a category, `channel.category` will be `None`, and the check would fail with an `AttributeError`. --- metricity/bot.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/metricity/bot.py b/metricity/bot.py index 24f80fd..e19bca1 100644 --- a/metricity/bot.py +++ b/metricity/bot.py @@ -78,10 +78,9 @@ async def sync_channels(guild: Guild) -> None: name=channel.name, category_id=str(channel.category.id) if channel.category else None, is_staff=( - True - if channel.category.id in BotConfig.staff_categories - else False - ) + channel.category + and channel.category.id in BotConfig.staff_categories + ), ).apply() else: await Channel.create( @@ -89,10 +88,9 @@ async def sync_channels(guild: Guild) -> None: name=channel.name, category_id=str(channel.category.id) if channel.category else None, is_staff=( - True - if channel.category.id in BotConfig.staff_categories - else False - ) + channel.category + and channel.category.id in BotConfig.staff_categories + ), ) channel_sync_in_progress.set() -- cgit v1.2.3