aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-02-13 18:53:00 +0000
committerGravatar Chris Lovering <[email protected]>2022-02-13 18:56:00 +0000
commitb1ca171384edc887871b7fdee1208abd624115a3 (patch)
treec458a61a4d8fd89813263dc3a72b6a1466bf2ad8
parentIgnore threads in forum channels (diff)
Listen for thread create and unarchive events
-rw-r--r--metricity/bot.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/metricity/bot.py b/metricity/bot.py
index 9de690f..e1a691a 100644
--- a/metricity/bot.py
+++ b/metricity/bot.py
@@ -185,6 +185,23 @@ async def on_guild_channel_update(_before: Messageable, channel: Messageable) ->
@bot.event
+async def on_thread_join(thread: ThreadChannel) -> None:
+ """
+ Sync channels when thread join is triggered.
+
+ Unlike what the name suggested, this is also triggered when:
+ - A thread is created.
+ - An un-cached thread is un-archived.
+ """
+ await db_ready.wait()
+
+ if thread.guild.id != BotConfig.guild_id:
+ return
+
+ await sync_channels(thread.guild)
+
+
async def on_thread_update(_before: Messageable, thread: Messageable) -> None:
"""Sync the channels when one is updated."""
await db_ready.wait()
@@ -207,6 +224,9 @@ async def on_guild_available(guild: Guild) -> None:
await sync_channels(guild)
+ log.info("Beginning thread archive state synchronisation process")
+ await sync_thread_archive_state(guild)
+
log.info("Beginning user synchronisation process")
await User.update.values(in_guild=False).gino.status()