Improve generic duck type programming with PartialMessageable

This adds jump_url, permissions_for, and created_at. Luckily, most
cases of this type being constructed already have the guild_id at
creation time.
This commit is contained in:
Rapptz
2022-05-03 10:49:52 -04:00
parent e9c7c09ebf
commit 8699d2139a
8 changed files with 59 additions and 11 deletions

View File

@ -1345,14 +1345,14 @@ class Webhook(BaseWebhook):
state = _WebhookState(self, parent=self._state, thread=thread)
# state may be artificial (unlikely at this point...)
if thread is MISSING:
channel = self.channel or PartialMessageable(state=self._state, id=int(data['channel_id'])) # type: ignore
channel = self.channel or PartialMessageable(state=self._state, guild_id=self.guild_id, 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
channel = PartialMessageable(state=self._state, guild_id=self.guild_id, id=int(data['channel_id'])) # type: ignore
# state is artificial
return WebhookMessage(data=data, state=state, channel=channel) # type: ignore