aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2021-08-22 11:45:31 +0200
committerGravatar Johannes Christ <[email protected]>2021-08-22 11:45:31 +0200
commit469665bcceb2193e45d7156c8935f68e019e4477 (patch)
treefc89b1100f86eca2cd4e5be0b29d68274b3e2757
parentMerge pull request #5 from python-discord/drop-deps (diff)
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`.
-rw-r--r--metricity/bot.py14
1 files 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()