Add raw thread delete event

This commit is contained in:
Lilly Rose Berner
2022-04-22 06:42:39 +02:00
committed by GitHub
parent 222dd3cf5b
commit 3e8fa5a661
3 changed files with 63 additions and 3 deletions

View File

@ -26,6 +26,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Optional, Set, List, Tuple, Union
from .enums import ChannelType, try_enum
if TYPE_CHECKING:
from .types.gateway import (
MessageDeleteEvent,
@ -36,10 +38,12 @@ if TYPE_CHECKING:
MessageReactionRemoveEmojiEvent as ReactionClearEmojiEvent,
MessageUpdateEvent,
IntegrationDeleteEvent,
ThreadDeleteEvent,
)
from .message import Message
from .partial_emoji import PartialEmoji
from .member import Member
from .threads import Thread
ReactionActionEvent = Union[MessageReactionAddEvent, MessageReactionRemoveEvent]
@ -52,6 +56,7 @@ __all__ = (
'RawReactionClearEvent',
'RawReactionClearEmojiEvent',
'RawIntegrationDeleteEvent',
'RawThreadDeleteEvent',
)
@ -280,3 +285,32 @@ class RawIntegrationDeleteEvent(_RawReprMixin):
self.application_id: Optional[int] = int(data['application_id'])
except KeyError:
self.application_id: Optional[int] = None
class RawThreadDeleteEvent(_RawReprMixin):
"""Represents the payload for a :func:`on_raw_thread_delete` event.
.. versionadded:: 2.0
Attributes
----------
thread_id: :class:`int`
The ID of the thread that was deleted.
thread_type: :class:`discord.ChannelType`
The channel type of the deleted thread.
guild_id: :class:`int`
The ID of the guild the thread was deleted in.
parent_id: :class:`int`
The ID of the channel the thread belonged to.
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', 'thread')
def __init__(self, data: ThreadDeleteEvent) -> 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.thread: Optional[Thread] = None