add try_user
This commit is contained in:
parent
7cb96f7ba4
commit
74713b05ee
@ -16,6 +16,7 @@ Custom Features
|
|||||||
- **Documentation URL:** https://enhanced-dpy.readthedocs.io/en/latest/index.html
|
- **Documentation URL:** https://enhanced-dpy.readthedocs.io/en/latest/index.html
|
||||||
- Added ``Guild.bots`` / ``Guild.humans``
|
- Added ``Guild.bots`` / ``Guild.humans``
|
||||||
- Added ``Bot.owner`` / ``Bot.owners``
|
- Added ``Bot.owner`` / ``Bot.owners``
|
||||||
|
- Added ``Client.try_user`` / ``Bot.try_user``
|
||||||
- Merged in ext-colors (https://github.com/MGardne8/DiscordPyColours)
|
- Merged in ext-colors (https://github.com/MGardne8/DiscordPyColours)
|
||||||
- Using Rapptz/discord.py/tree/neo-docs for documentation
|
- Using Rapptz/discord.py/tree/neo-docs for documentation
|
||||||
- Adding support for ``hex()`` to ``discord.Color``
|
- Adding support for ``hex()`` to ``discord.Color``
|
||||||
|
@ -1343,6 +1343,40 @@ class Client:
|
|||||||
data['rpc_origins'] = None
|
data['rpc_origins'] = None
|
||||||
return AppInfo(self._connection, data)
|
return AppInfo(self._connection, data)
|
||||||
|
|
||||||
|
async def try_user(self, user_id):
|
||||||
|
"""|coro|
|
||||||
|
|
||||||
|
Retrieves a :class:`~discord.User` based on their ID. This can only
|
||||||
|
be used by bot accounts.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
This will first attempt to get the user from the cache.
|
||||||
|
If that fails, it will make an API call.
|
||||||
|
For general usage, consider :meth:`get_user` instead.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
-----------
|
||||||
|
user_id: :class:`int`
|
||||||
|
The user's ID to fetch from.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
-------
|
||||||
|
:exc:`.NotFound`
|
||||||
|
A user with this ID does not exist.
|
||||||
|
:exc:`.HTTPException`
|
||||||
|
Fetching the user failed.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
:class:`~discord.User`
|
||||||
|
The user you requested.
|
||||||
|
"""
|
||||||
|
user = self.get_user(user_id)
|
||||||
|
if user is None:
|
||||||
|
user = await self.fetch_user(user_id)
|
||||||
|
return user
|
||||||
|
|
||||||
async def fetch_user(self, user_id):
|
async def fetch_user(self, user_id):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ Custom Features
|
|||||||
- **Documentation URL:** https://enhanced-dpy.readthedocs.io/en/latest/index.html
|
- **Documentation URL:** https://enhanced-dpy.readthedocs.io/en/latest/index.html
|
||||||
- Added ``Guild.bots`` / ``Guild.humans``
|
- Added ``Guild.bots`` / ``Guild.humans``
|
||||||
- Added ``Bot.owner`` / ``Bot.owners``
|
- Added ``Bot.owner`` / ``Bot.owners``
|
||||||
|
- Added ``Client.try_user`` / ``Bot.try_user``
|
||||||
- Merged in ext-colors (https://github.com/MGardne8/DiscordPyColours)
|
- Merged in ext-colors (https://github.com/MGardne8/DiscordPyColours)
|
||||||
- Using Rapptz/discord.py/tree/neo-docs for documentation
|
- Using Rapptz/discord.py/tree/neo-docs for documentation
|
||||||
- Adding support for ``hex()`` to ``discord.Color``
|
- Adding support for ``hex()`` to ``discord.Color``
|
||||||
|
Loading…
x
Reference in New Issue
Block a user