aboutsummaryrefslogtreecommitdiff
path: root/discord/user.py
diff options
context:
space:
mode:
authorCapnS <[email protected]>2018-12-12 01:14:42 -0600
committerRapptz <[email protected]>2018-12-14 19:05:33 -0500
commit2c7c541f4e92c0f17def4f991603eb3de50eb07b (patch)
treebd0a61aba0024bf02816b3268382647d552b090a /discord/user.py
parent[commands] Remove message being required from Role/Member converters. (diff)
downloaddiscord.py-2c7c541f4e92c0f17def4f991603eb3de50eb07b.tar.xz
discord.py-2c7c541f4e92c0f17def4f991603eb3de50eb07b.zip
Added User.mutual_friends()
Diffstat (limited to 'discord/user.py')
-rw-r--r--discord/user.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/discord/user.py b/discord/user.py
index 38820d5a..78ed0491 100644
--- a/discord/user.py
+++ b/discord/user.py
@@ -555,6 +555,27 @@ class User(BaseUser, discord.abc.Messageable):
"""Returns the :class:`Relationship` with this user if applicable, ``None`` otherwise."""
return self._state.user.get_relationship(self.id)
+ async def mutual_friends(self):
+ """|coro|
+
+ Gets all mutual friends of this user. This can only be used by non-bot accounts
+
+ Returns
+ -------
+ List[:class:`User`]
+ The users that are mutual friends.
+
+ Raises
+ -------
+ Forbidden
+ Not allowed to get mutual friends of this user.
+ HTTPException
+ Getting mutual friends failed.
+ """
+ state = self._state
+ mutuals = await state.http.get_mutual_friends(self.id)
+ return [User(state=state, data=friend) for friend in mutuals]
+
def is_friend(self):
""":class:`bool`: Checks if the user is your friend."""
r = self.relationship