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`
An argument :class:`list` of :class:`discord.User` to have in
your group. Groups cannot be created with only one person,
but they can be created with zero people.
your group.
Raises
-------
TypeError
Only one recipient was given.
HTTPException
Failed to create the group direct message.
@ -3162,11 +3159,13 @@ class Client:
:class:`.GroupChannel`
The new group channel.
"""
if len(recipients) == 1:
raise TypeError('Cannot create a group with only one recipient')
state = self._connection
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)
return GroupChannel(me=self.user, data=data, state=state) # type: ignore # user is always present when logged in

Loading…
Cancel
Save