Browse Source

Add Client.create_dm

pull/6836/head
Rapptz 4 years ago
parent
commit
b0ec22065e
  1. 28
      discord/client.py

28
discord/client.py

@ -1347,3 +1347,31 @@ class Client:
"""
data = await self.http.get_webhook(webhook_id)
return Webhook.from_state(data, state=self._connection)
async def create_dm(self, user):
"""|coro|
Creates a :class:`.DMChannel` with this user.
This should be rarely called, as this is done transparently for most
people.
.. versionadded:: 2.0
Parameters
-----------
user: :class:`~discord.abc.Snowflake`
The user to create a DM with.
Returns
-------
:class:`.DMChannel`
The channel that was created.
"""
state = self._connection
found = state._get_private_channel_by_user(user.id)
if found:
return found
data = await state.http.start_private_message(user.id)
return state.add_dm_channel(data)

Loading…
Cancel
Save