From 29d4c264665dcc3e8579005896e9a587cf1578d2 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 10 Apr 2022 18:15:02 -0400 Subject: [PATCH] Upgrade WebhookMessage.channel to Thread if available --- discord/webhook/async_.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index f8bb5c63a..52884f92e 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -1344,7 +1344,16 @@ class Webhook(BaseWebhook): def _create_message(self, data, *, thread: Snowflake): state = _WebhookState(self, parent=self._state, thread=thread) # state may be artificial (unlikely at this point...) - channel = self.channel or PartialMessageable(state=self._state, id=int(data['channel_id'])) # type: ignore + if thread is MISSING: + channel = self.channel or PartialMessageable(state=self._state, id=int(data['channel_id'])) # type: ignore + else: + channel = self.channel + if isinstance(channel, TextChannel): + channel = channel.get_thread(thread.id) + + if channel is None: + channel = PartialMessageable(state=self._state, id=int(data['channel_id'])) # type: ignore + # state is artificial return WebhookMessage(data=data, state=state, channel=channel) # type: ignore