mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Add Client.create_dm
This commit is contained in:
parent
83611edb66
commit
b0ec22065e
@ -1347,3 +1347,31 @@ class Client:
|
|||||||
"""
|
"""
|
||||||
data = await self.http.get_webhook(webhook_id)
|
data = await self.http.get_webhook(webhook_id)
|
||||||
return Webhook.from_state(data, state=self._connection)
|
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…
x
Reference in New Issue
Block a user