Browse Source

Allow creating gdms with one user

pull/10109/head
dolfies 3 months ago
parent
commit
14d37fa0b7
  1. 13
      discord/client.py

13
discord/client.py

@ -3147,13 +3147,10 @@ class Client:
----------- -----------
\*recipients: :class:`~discord.abc.Snowflake` \*recipients: :class:`~discord.abc.Snowflake`
An argument :class:`list` of :class:`discord.User` to have in An argument :class:`list` of :class:`discord.User` to have in
your group. Groups cannot be created with only one person, your group.
but they can be created with zero people.
Raises Raises
------- -------
TypeError
Only one recipient was given.
HTTPException HTTPException
Failed to create the group direct message. Failed to create the group direct message.
@ -3162,11 +3159,13 @@ class Client:
:class:`.GroupChannel` :class:`.GroupChannel`
The new group channel. The new group channel.
""" """
if len(recipients) == 1: state = self._connection
raise TypeError('Cannot create a group with only one recipient')
users: List[_Snowflake] = [u.id for u in recipients] users: List[_Snowflake] = [u.id for u in recipients]
state = self._connection if len(users) == 1:
# To create a group DM with one user, the client user must be included
users.append(state.self_id) # type: ignore # user is always present when logged in
data = await state.http.start_group(users) data = await state.http.start_group(users)
return GroupChannel(me=self.user, data=data, state=state) # type: ignore # user is always present when logged in return GroupChannel(me=self.user, data=data, state=state) # type: ignore # user is always present when logged in

Loading…
Cancel
Save