mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-25 02:23:04 +00:00 
			
		
		
		
	Fix Webhook.send returning ForumChannel for WebhookMessage.channel
This commit is contained in:
		| @@ -38,14 +38,14 @@ import aiohttp | |||||||
| from .. import utils | from .. import utils | ||||||
| from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError | from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError | ||||||
| from ..message import Message | from ..message import Message | ||||||
| from ..enums import try_enum, WebhookType | from ..enums import try_enum, WebhookType, ChannelType | ||||||
| from ..user import BaseUser, User | from ..user import BaseUser, User | ||||||
| from ..flags import MessageFlags | from ..flags import MessageFlags | ||||||
| from ..asset import Asset | from ..asset import Asset | ||||||
| from ..partial_emoji import PartialEmoji | from ..partial_emoji import PartialEmoji | ||||||
| from ..http import Route, handle_message_parameters, MultipartParameters, HTTPClient, json_or_text | from ..http import Route, handle_message_parameters, MultipartParameters, HTTPClient, json_or_text | ||||||
| from ..mixins import Hashable | from ..mixins import Hashable | ||||||
| from ..channel import TextChannel, PartialMessageable | from ..channel import TextChannel, ForumChannel, PartialMessageable | ||||||
| from ..file import File | from ..file import File | ||||||
|  |  | ||||||
| __all__ = ( | __all__ = ( | ||||||
| @@ -68,7 +68,7 @@ if TYPE_CHECKING: | |||||||
|     from ..http import Response |     from ..http import Response | ||||||
|     from ..guild import Guild |     from ..guild import Guild | ||||||
|     from ..emoji import Emoji |     from ..emoji import Emoji | ||||||
|     from ..channel import ForumChannel, VoiceChannel |     from ..channel import VoiceChannel | ||||||
|     from ..abc import Snowflake |     from ..abc import Snowflake | ||||||
|     from ..ui.view import View |     from ..ui.view import View | ||||||
|     import datetime |     import datetime | ||||||
| @@ -1492,10 +1492,18 @@ class Webhook(BaseWebhook): | |||||||
|         state = _WebhookState(self, parent=self._state, thread=thread) |         state = _WebhookState(self, parent=self._state, thread=thread) | ||||||
|         # state may be artificial (unlikely at this point...) |         # state may be artificial (unlikely at this point...) | ||||||
|         if thread is MISSING: |         if thread is MISSING: | ||||||
|             channel = self.channel or PartialMessageable(state=self._state, guild_id=self.guild_id, id=int(data['channel_id']))  # type: ignore |             channel_id = int(data['channel_id']) | ||||||
|  |             channel = self.channel | ||||||
|  |             # If this thread is created via thread_name then the channel_id would not be the same as the webhook's channel_id | ||||||
|  |             # which would be the forum channel. | ||||||
|  |             if self.channel_id != channel_id: | ||||||
|  |                 type = ChannelType.public_thread if isinstance(channel, ForumChannel) else (channel and channel.type) | ||||||
|  |                 channel = PartialMessageable(state=self._state, guild_id=self.guild_id, id=channel_id, type=type)  # type: ignore | ||||||
|  |             else: | ||||||
|  |                 channel = self.channel or PartialMessageable(state=self._state, guild_id=self.guild_id, id=channel_id)  # type: ignore | ||||||
|         else: |         else: | ||||||
|             channel = self.channel |             channel = self.channel | ||||||
|             if isinstance(channel, TextChannel): |             if isinstance(channel, (ForumChannel, TextChannel)): | ||||||
|                 channel = channel.get_thread(thread.id) |                 channel = channel.get_thread(thread.id) | ||||||
|  |  | ||||||
|             if channel is None: |             if channel is None: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user