Fix channel deletion not removing associated threads

This commit is contained in:
Lilly Rose Berner
2024-05-05 05:23:59 +02:00
committed by GitHub
parent 0b4263e697
commit 0ee1794c6d
3 changed files with 27 additions and 4 deletions

View File

@ -33,6 +33,8 @@ from .app_commands import AppCommandPermissions
from .colour import Colour
if TYPE_CHECKING:
from typing_extensions import Self
from .types.gateway import (
MessageDeleteEvent,
MessageDeleteBulkEvent as BulkMessageDeleteEvent,
@ -399,6 +401,20 @@ class RawThreadDeleteEvent(_RawReprMixin):
self.parent_id: int = int(data['parent_id'])
self.thread: Optional[Thread] = None
@classmethod
def _from_thread(cls, thread: Thread) -> Self:
data: ThreadDeleteEvent = {
'id': thread.id,
'type': thread.type.value,
'guild_id': thread.guild.id,
'parent_id': thread.parent_id,
}
instance = cls(data)
instance.thread = thread
return instance
class RawThreadMembersUpdate(_RawReprMixin):
"""Represents the payload for a :func:`on_raw_thread_member_remove` event.