mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 08:17:47 +00:00
Add Client.get_user_info to retrieve a User from ID.
This commit is contained in:
parent
7a2b944b72
commit
96ca7cafee
@ -2795,4 +2795,31 @@ class Client:
|
||||
description=data['description'], icon=data['icon'],
|
||||
owner=User(**data['owner']))
|
||||
|
||||
@asyncio.coroutine
|
||||
def get_user_info(self, user_id):
|
||||
"""|coro|
|
||||
|
||||
Retrieves a :class:`User` based on their ID. This can only
|
||||
be used by bot accounts. You do not have to share any servers
|
||||
with the user to get this information, however many operations
|
||||
do require that you do.
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
user_id: str
|
||||
The user's ID to fetch from.
|
||||
|
||||
Returns
|
||||
--------
|
||||
:class:`User`
|
||||
The user you requested.
|
||||
|
||||
Raises
|
||||
-------
|
||||
NotFound
|
||||
A user with this ID does not exist.
|
||||
HTTPException
|
||||
Fetching the user failed.
|
||||
"""
|
||||
data = yield from self.http.get_user_info(user_id)
|
||||
return User(**data)
|
||||
|
@ -515,3 +515,6 @@ class HTTPClient:
|
||||
except HTTPException as e:
|
||||
raise GatewayNotFound() from e
|
||||
return data.get('url') + '?encoding=json&v=6'
|
||||
|
||||
def get_user_info(self, user_id):
|
||||
return self.get('{0.USERS}/{1}'.format(self, user_id), bucket=_func_())
|
||||
|
Loading…
x
Reference in New Issue
Block a user