Add on_raw_thread_update event

This commit is contained in:
Enes Kurbetoğlu
2022-06-03 11:49:32 +03:00
committed by GitHub
parent af265dba06
commit 06c1f44d74
3 changed files with 62 additions and 3 deletions

View File

@ -40,6 +40,7 @@ if TYPE_CHECKING:
MessageReactionRemoveEmojiEvent as ReactionClearEmojiEvent,
MessageUpdateEvent,
IntegrationDeleteEvent,
ThreadUpdateEvent,
ThreadDeleteEvent,
TypingStartEvent,
GuildMemberRemoveEvent,
@ -61,6 +62,7 @@ __all__ = (
'RawReactionClearEvent',
'RawReactionClearEmojiEvent',
'RawIntegrationDeleteEvent',
'RawThreadUpdateEvent',
'RawThreadDeleteEvent',
'RawTypingEvent',
'RawMemberRemoveEvent',
@ -294,6 +296,38 @@ class RawIntegrationDeleteEvent(_RawReprMixin):
self.application_id: Optional[int] = None
class RawThreadUpdateEvent(_RawReprMixin):
"""Represents the payload for a :func:`on_raw_thread_update` event.
.. versionadded:: 2.0
Attributes
----------
thread_id: :class:`int`
The ID of the thread that was updated.
thread_type: :class:`discord.ChannelType`
The channel type of the updated thread.
guild_id: :class:`int`
The ID of the guild the thread is in.
parent_id: :class:`int`
The ID of the channel the thread belongs to.
data: :class:`dict`
The raw data given by the :ddocs:`gateway <topics/gateway#thread-update>`
thread: Optional[:class:`discord.Thread`]
The thread, if it could be found in the internal cache.
"""
__slots__ = ('thread_id', 'thread_type', 'parent_id', 'guild_id', 'data', 'thread')
def __init__(self, data: ThreadUpdateEvent) -> None:
self.thread_id: int = int(data['id'])
self.thread_type: ChannelType = try_enum(ChannelType, data['type'])
self.guild_id: int = int(data['guild_id'])
self.parent_id: int = int(data['parent_id'])
self.data: ThreadUpdateEvent = data
self.thread: Optional[Thread] = None
class RawThreadDeleteEvent(_RawReprMixin):
"""Represents the payload for a :func:`on_raw_thread_delete` event.