mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 16:51:59 +00:00
Added User.mutual_friends()
This commit is contained in:
parent
bda690c32f
commit
2c7c541f4e
@ -769,6 +769,9 @@ class HTTPClient:
|
||||
def get_user_profile(self, user_id):
|
||||
return self.request(Route('GET', '/users/{user_id}/profile', user_id=user_id))
|
||||
|
||||
def get_mutual_friends(self, user_id):
|
||||
return self.request(Route('GET', '/users/{user_id}/relationships', user_id=user_id))
|
||||
|
||||
def change_hypesquad_house(self, house_id):
|
||||
payload = {'house_id': house_id}
|
||||
return self.request(Route('POST', '/hypesquad/online'), json=payload)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user