mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
Fix bug where PMs would be sent to the wrong person.
This bug triggered because we did not call `yield from` to the coroutine that starts the private message if it isn't found in cache. Obviously the fix for that is to make the destination resolution a coroutine and thus it'll be invoked correctly.
This commit is contained in:
parent
0009225d08
commit
2b6bdf7c82
@ -170,6 +170,7 @@ class Client:
|
||||
return m.group(1)
|
||||
return invite
|
||||
|
||||
@asyncio.coroutine
|
||||
def _resolve_destination(self, destination):
|
||||
if isinstance(destination, (Channel, PrivateChannel, Server)):
|
||||
return destination.id
|
||||
@ -177,7 +178,7 @@ class Client:
|
||||
found = utils.find(lambda pm: pm.user == destination, self.private_channels)
|
||||
if found is None:
|
||||
# Couldn't find the user, so start a PM with them first.
|
||||
self.start_private_message(destination)
|
||||
yield from self.start_private_message(destination)
|
||||
channel_id = self.private_channels[-1].id
|
||||
return channel_id
|
||||
else:
|
||||
@ -758,7 +759,7 @@ class Client:
|
||||
The message that was sent.
|
||||
"""
|
||||
|
||||
channel_id = self._resolve_destination(destination)
|
||||
channel_id = yield from self._resolve_destination(destination)
|
||||
|
||||
content = str(content)
|
||||
mentions = self._resolve_mentions(content, mentions)
|
||||
@ -796,7 +797,7 @@ class Client:
|
||||
The location to send the typing update.
|
||||
"""
|
||||
|
||||
channel_id = self._resolve_destination(destination)
|
||||
channel_id = yield from self._resolve_destination(destination)
|
||||
|
||||
url = '{base}/{id}/typing'.format(base=endpoints.CHANNELS, id=channel_id)
|
||||
|
||||
@ -847,7 +848,7 @@ class Client:
|
||||
The message sent.
|
||||
"""
|
||||
|
||||
channel_id = self._resolve_destination(destination)
|
||||
channel_id = yield from self._resolve_destination(destination)
|
||||
|
||||
url = '{base}/{id}/messages'.format(base=endpoints.CHANNELS, id=channel_id)
|
||||
files = aiohttp.FormData()
|
||||
|
Loading…
x
Reference in New Issue
Block a user