diff options
| author | Rapptz <[email protected]> | 2017-02-09 20:47:47 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-02-09 20:50:02 -0500 |
| commit | ca81f0c3fcdd29b16adbf39c616ab15231d21a7f (patch) | |
| tree | af1ca89e7e79e44b1a69333f3aa1658adf1b3f89 /discord/user.py | |
| parent | Call message edit handlers after attempting to patch individual fields (diff) | |
| download | discord.py-ca81f0c3fcdd29b16adbf39c616ab15231d21a7f.tar.xz discord.py-ca81f0c3fcdd29b16adbf39c616ab15231d21a7f.zip | |
Better group DM support.
Diffstat (limited to 'discord/user.py')
| -rw-r--r-- | discord/user.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/discord/user.py b/discord/user.py index 47cebde5..cadf84db 100644 --- a/discord/user.py +++ b/discord/user.py @@ -308,6 +308,45 @@ class ClientUser(BaseUser): # manually update data by calling __init__ explicitly. self.__init__(state=self._state, data=data) + @asyncio.coroutine + def create_group(self, *recipients): + """|coro| + + Creates a group direct message with the recipients + provided. These recipients must be have a relationship + of type :attr:`RelationshipType.friend`. + + Bot accounts cannot create a group. + + Parameters + ----------- + \*recipients + An argument list of :class:`User` to have in + your group. + + Return + ------- + :class:`GroupChannel` + The new group channel. + + Raises + ------- + HTTPException + Failed to create the group direct message. + ClientException + Attempted to create a group with only one recipient. + This does not include yourself. + """ + + from .channel import GroupChannel + + if len(recipients) < 2: + raise ClientException('You must have two or more recipients to create a group.') + + users = [str(u.id) for u in recipients] + data = yield from self._state.http.create_group(self.id, users) + return GroupChannel(me=self, data=data, state=self._state) + class User(BaseUser, discord.abc.Messageable): """Represents a Discord user. |