|
@ -46,7 +46,7 @@ from ..asset import Asset |
|
|
from ..partial_emoji import PartialEmoji |
|
|
from ..partial_emoji import PartialEmoji |
|
|
from ..http import Route, handle_message_parameters, HTTPClient |
|
|
from ..http import Route, handle_message_parameters, HTTPClient |
|
|
from ..mixins import Hashable |
|
|
from ..mixins import Hashable |
|
|
from ..channel import PartialMessageable |
|
|
from ..channel import TextChannel, PartialMessageable |
|
|
from ..file import File |
|
|
from ..file import File |
|
|
|
|
|
|
|
|
__all__ = ( |
|
|
__all__ = ( |
|
@ -69,7 +69,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 TextChannel |
|
|
from ..channel import TextChannel, VoiceChannel |
|
|
from ..abc import Snowflake |
|
|
from ..abc import Snowflake |
|
|
import datetime |
|
|
import datetime |
|
|
from ..types.webhook import ( |
|
|
from ..types.webhook import ( |
|
@ -744,8 +744,8 @@ class BaseWebhook(Hashable): |
|
|
return self._state and self._state._get_guild(self.guild_id) |
|
|
return self._state and self._state._get_guild(self.guild_id) |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def channel(self) -> Optional[TextChannel]: |
|
|
def channel(self) -> Optional[Union[VoiceChannel, TextChannel]]: |
|
|
"""Optional[:class:`TextChannel`]: The text channel this webhook belongs to. |
|
|
"""Optional[Union[:class:`VoiceChannel`, :class:`TextChannel`]]: The channel this webhook belongs to. |
|
|
|
|
|
|
|
|
If this is a partial webhook, then this will always return ``None``. |
|
|
If this is a partial webhook, then this will always return ``None``. |
|
|
""" |
|
|
""" |
|
@ -1156,7 +1156,16 @@ class Webhook(BaseWebhook): |
|
|
def _create_message(self, data, *, thread: Snowflake): |
|
|
def _create_message(self, data, *, thread: Snowflake): |
|
|
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...) |
|
|
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 |
|
|
# state is artificial |
|
|
return WebhookMessage(data=data, state=state, channel=channel) # type: ignore |
|
|
return WebhookMessage(data=data, state=state, channel=channel) # type: ignore |
|
|
|
|
|
|
|
|