diff options
| -rw-r--r-- | metricity/bot.py | 20 | 
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()  |