From 811c9d9f3bb71ede2f16661fe55ad39f990c6544 Mon Sep 17 00:00:00 2001 From: owocado <24418520+owocado@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:11:12 +0530 Subject: [PATCH] add `reason` kwarg to thread delete method --- discord/threads.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/discord/threads.py b/discord/threads.py index b47c189d299f..bbf476dc80ec 100644 --- a/discord/threads.py +++ b/discord/threads.py @@ -846,13 +846,21 @@ async def fetch_members(self) -> List[ThreadMember]: members = await self._state.http.get_thread_members(self.id) return [ThreadMember(parent=self, data=data) for data in members] - async def delete(self) -> None: + async def delete(self, *, reason: Optional[str] = None) -> None: """|coro| Deletes this thread. You must have :attr:`~Permissions.manage_threads` to delete threads. + Parameters + ----------- + reason: Optional[:class:`str`] + The reason for deleting this thread. + Shows up on the audit log. + + .. versionadded:: 2.4 + Raises ------- Forbidden @@ -860,7 +868,7 @@ async def delete(self) -> None: HTTPException Deleting the thread failed. """ - await self._state.http.delete_channel(self.id) + await self._state.http.delete_channel(self.id, reason=reason) def get_partial_message(self, message_id: int, /) -> PartialMessage: """Creates a :class:`PartialMessage` from the message ID.