mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-18 23:15:48 +00:00
Add new on_thread_create event
This commit is contained in:
parent
b561024163
commit
deb7958797
@ -552,6 +552,10 @@ class Intents(BaseFlags):
|
||||
- :func:`on_guild_channel_create`
|
||||
- :func:`on_guild_channel_delete`
|
||||
- :func:`on_guild_channel_pins_update`
|
||||
- :func:`on_thread_create`
|
||||
- :func:`on_thread_join`
|
||||
- :func:`on_thread_update`
|
||||
- :func:`on_thread_delete`
|
||||
|
||||
This also corresponds to the following attributes and classes in terms of cache:
|
||||
|
||||
@ -574,6 +578,8 @@ class Intents(BaseFlags):
|
||||
- :func:`on_member_remove`
|
||||
- :func:`on_member_update`
|
||||
- :func:`on_user_update`
|
||||
- :func:`on_thread_member_join`
|
||||
- :func:`on_thread_member_remove`
|
||||
|
||||
This also corresponds to the following attributes and classes in terms of cache:
|
||||
|
||||
|
@ -850,7 +850,10 @@ class ConnectionState:
|
||||
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: gw.ThreadUpdateEvent) -> None:
|
||||
guild_id = int(data['guild_id'])
|
||||
|
@ -64,6 +64,7 @@ class Thread(TypedDict):
|
||||
member: NotRequired[ThreadMember]
|
||||
last_message_id: NotRequired[Optional[Snowflake]]
|
||||
last_pin_timestamp: NotRequired[Optional[Snowflake]]
|
||||
newly_created: NotRequired[bool]
|
||||
|
||||
|
||||
class ThreadPaginationPayload(TypedDict):
|
||||
|
15
docs/api.rst
15
docs/api.rst
@ -1096,11 +1096,22 @@ Stages
|
||||
Threads
|
||||
~~~~~~~~
|
||||
|
||||
.. 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 was created.
|
||||
:type thread: :class:`Thread`
|
||||
|
||||
.. 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`.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user