mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-11 12:28:03 +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_create`
|
||||||
- :func:`on_guild_channel_delete`
|
- :func:`on_guild_channel_delete`
|
||||||
- :func:`on_guild_channel_pins_update`
|
- :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:
|
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_remove`
|
||||||
- :func:`on_member_update`
|
- :func:`on_member_update`
|
||||||
- :func:`on_user_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:
|
This also corresponds to the following attributes and classes in terms of cache:
|
||||||
|
|
||||||
|
@ -850,6 +850,9 @@ class ConnectionState:
|
|||||||
has_thread = guild.get_thread(thread.id)
|
has_thread = guild.get_thread(thread.id)
|
||||||
guild._add_thread(thread)
|
guild._add_thread(thread)
|
||||||
if not has_thread:
|
if not has_thread:
|
||||||
|
if data.get('newly_created'):
|
||||||
|
self.dispatch('thread_create', thread)
|
||||||
|
else:
|
||||||
self.dispatch('thread_join', thread)
|
self.dispatch('thread_join', thread)
|
||||||
|
|
||||||
def parse_thread_update(self, data: gw.ThreadUpdateEvent) -> None:
|
def parse_thread_update(self, data: gw.ThreadUpdateEvent) -> None:
|
||||||
|
@ -64,6 +64,7 @@ class Thread(TypedDict):
|
|||||||
member: NotRequired[ThreadMember]
|
member: NotRequired[ThreadMember]
|
||||||
last_message_id: NotRequired[Optional[Snowflake]]
|
last_message_id: NotRequired[Optional[Snowflake]]
|
||||||
last_pin_timestamp: NotRequired[Optional[Snowflake]]
|
last_pin_timestamp: NotRequired[Optional[Snowflake]]
|
||||||
|
newly_created: NotRequired[bool]
|
||||||
|
|
||||||
|
|
||||||
class ThreadPaginationPayload(TypedDict):
|
class ThreadPaginationPayload(TypedDict):
|
||||||
|
15
docs/api.rst
15
docs/api.rst
@ -1096,11 +1096,22 @@ Stages
|
|||||||
Threads
|
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)
|
.. 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
|
Called whenever a thread is joined.
|
||||||
differentiate between a thread being created or the bot joining a thread.
|
|
||||||
|
|
||||||
Note that you can get the guild from :attr:`Thread.guild`.
|
Note that you can get the guild from :attr:`Thread.guild`.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user