Add support for PartialMessageable instances

This allows library users to send messages to channels without fetching
it first.
This commit is contained in:
Rapptz
2021-08-10 09:24:49 -04:00
parent 4fca699810
commit 1279510194
6 changed files with 125 additions and 30 deletions

View File

@ -405,12 +405,12 @@ class ConnectionState:
try:
guild = self._get_guild(int(data['guild_id']))
except KeyError:
channel = DMChannel._from_message(self, channel_id)
channel = PartialMessageable(state=self, id=channel_id, type=ChannelType.private)
guild = None
else:
channel = guild and guild._resolve_channel(channel_id)
return channel or Object(id=channel_id), guild
return channel or PartialMessageable(state=self, id=channel_id), guild
async def chunker(self, guild_id, query='', limit=0, presences=False, *, nonce=None):
ws = self._get_websocket(guild_id) # This is ignored upstream