Browse Source

Improve exception when creating a group channel with one recipient

pull/10109/head
dolfies 11 months ago
parent
commit
38780526e9
  1. 8
      discord/client.py
  2. 4
      discord/types/experiment.py

8
discord/client.py

@ -3153,10 +3153,13 @@ class Client:
-----------
\*recipients: :class:`~discord.abc.Snowflake`
An argument :class:`list` of :class:`discord.User` to have in
your group.
your group. Groups cannot be created with only one person,
but they can be created with zero people.
Raises
-------
TypeError
Only one recipient was given.
HTTPException
Failed to create the group direct message.
@ -3165,6 +3168,9 @@ class Client:
:class:`.GroupChannel`
The new group channel.
"""
if len(recipients) == 1:
raise TypeError('Cannot create a group with only one recipient')
users: List[_Snowflake] = [u.id for u in recipients]
state = self._connection
data = await state.http.start_group(users)

4
discord/types/experiment.py

@ -58,9 +58,7 @@ Filters = List[
Tuple[Literal[3013771838], Tuple[Tuple[Literal[3013771838], List[int]]]], # IDs
Tuple[Literal[4148745523], Tuple[Tuple[Literal[4148745523], List[int]]]], # HUB_TYPE
Tuple[Literal[188952590], Tuple[Tuple[Literal[188952590], bool]]], # VANITY_URL
Tuple[
Literal[2294888943], Tuple[Tuple[Literal[2690752156], int], Tuple[Literal[1982804121], int]]
], # RANGE_BY_HASH
Tuple[Literal[2294888943], Tuple[Tuple[Literal[2690752156], int], Tuple[Literal[1982804121], int]]], # RANGE_BY_HASH
]
]

Loading…
Cancel
Save