diff --git a/discord/state.py b/discord/state.py index c2c55d9ac5..f115f0193f 100644 --- a/discord/state.py +++ b/discord/state.py @@ -897,7 +897,10 @@ def parse_thread_create(self, data) -> None: has_thread = guild.get_thread(thread.id) guild._add_thread(thread) if not has_thread: - self.dispatch("thread_join", thread) + if data.get("newly_created"): + self.dispatch("thread_create", thread) + else: + self.dispatch("thread_join", thread) def parse_thread_update(self, data) -> None: guild_id = int(data["guild_id"]) diff --git a/docs/api.rst b/docs/api.rst index d1a7d4b067..7be1558187 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -899,8 +899,7 @@ to handle it, which defaults to print a traceback and ignoring the exception. .. function:: on_thread_join(thread) - Called whenever a thread is joined or created. Note that from the API's perspective there is no way to - differentiate between a thread being created or the bot joining a thread. + Called whenever a thread is joined. Note that you can get the guild from :attr:`Thread.guild`. @@ -911,6 +910,19 @@ to handle it, which defaults to print a traceback and ignoring the exception. :param thread: The thread that got joined. :type thread: :class:`Thread` +.. function:: on_thread_create(thread) + + Called whenever a thread is created. + + Note that you can get the guild from :attr:`Thread.guild`. + + This requires :attr:`Intents.guilds` to be enabled. + + .. versionadded:: 2.0 + + :param thread: The thread that got created. + :type thread: :class:`Thread` + .. function:: on_thread_remove(thread) Called whenever a thread is removed. This is different from a thread being deleted.