aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2022-04-03 18:59:23 +0100
committerGravatar GitHub <[email protected]>2022-04-03 18:59:23 +0100
commit7ec2429b832df41ffb71c3348e6ec459b12ebad9 (patch)
treee1de84c94e9ceeeaf008f881f25dc25df2c6cff7
parentAdd ModMail appeals to ignore categories (diff)
parentFix bug where having channels without categories causes error (diff)
Merge pull request #14 from python-discord/fix-channel-sync
Fix bug where having channels without categories causes error
-rw-r--r--metricity/bot.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/metricity/bot.py b/metricity/bot.py
index e1a691a..73125bf 100644
--- a/metricity/bot.py
+++ b/metricity/bot.py
@@ -94,24 +94,24 @@ async def sync_channels(guild: Guild) -> None:
not isinstance(channel, CategoryChannel) and
not isinstance(channel, VoiceChannel)
):
+ category_id = str(channel.category.id) if channel.category else None
+ # Cast to bool so is_staff is False if channel.category is None
+ is_staff = bool(
+ channel.category
+ and channel.category.id in BotConfig.staff_categories
+ )
if db_chan := await Channel.get(str(channel.id)):
await db_chan.update(
name=channel.name,
- category_id=str(channel.category.id) if channel.category else None,
- is_staff=(
- channel.category
- and channel.category.id in BotConfig.staff_categories
- ),
+ category_id=category_id,
+ is_staff=is_staff,
).apply()
else:
await Channel.create(
id=str(channel.id),
name=channel.name,
- category_id=str(channel.category.id) if channel.category else None,
- is_staff=(
- channel.category
- and channel.category.id in BotConfig.staff_categories
- ),
+ category_id=category_id,
+ is_staff=is_staff,
)
log.info("Channel synchronisation process complete, synchronising threads")