Document that the cache retrieval functions require an int ID.
Closes #2285
This commit is contained in:
parent
45375364b7
commit
18fe2035ef
@ -658,31 +658,62 @@ class Client:
|
|||||||
return list(self._connection._users.values())
|
return list(self._connection._users.values())
|
||||||
|
|
||||||
def get_channel(self, id):
|
def get_channel(self, id):
|
||||||
"""Optional[Union[:class:`.abc.GuildChannel`, :class:`.abc.PrivateChannel`]]: Returns a channel with the
|
"""Returns a channel with the given ID.
|
||||||
given ID.
|
|
||||||
|
|
||||||
If not found, returns ``None``.
|
Parameters
|
||||||
|
-----------
|
||||||
|
id: :class:`int`
|
||||||
|
The ID to search for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
Optional[Union[:class:`.abc.GuildChannel`, :class:`.abc.PrivateChannel`]]
|
||||||
|
The returned channel or ``None`` if not found.
|
||||||
"""
|
"""
|
||||||
return self._connection.get_channel(id)
|
return self._connection.get_channel(id)
|
||||||
|
|
||||||
def get_guild(self, id):
|
def get_guild(self, id):
|
||||||
"""Optional[:class:`.Guild`]: Returns a guild with the given ID.
|
"""Returns a guild with the given ID.
|
||||||
|
|
||||||
If not found, returns ``None``.
|
Parameters
|
||||||
|
-----------
|
||||||
|
id: :class:`int`
|
||||||
|
The ID to search for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
Optional[:class:`.Guild`]
|
||||||
|
The guild or ``None`` if not found.
|
||||||
"""
|
"""
|
||||||
return self._connection._get_guild(id)
|
return self._connection._get_guild(id)
|
||||||
|
|
||||||
def get_user(self, id):
|
def get_user(self, id):
|
||||||
"""Optional[:class:`~discord.User`]: Returns a user with the given ID.
|
"""Returns a user with the given ID.
|
||||||
|
|
||||||
If not found, returns ``None``.
|
Parameters
|
||||||
|
-----------
|
||||||
|
id: :class:`int`
|
||||||
|
The ID to search for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
Optional[:class:`~discord.User`]
|
||||||
|
The user or ``None`` if not found.
|
||||||
"""
|
"""
|
||||||
return self._connection.get_user(id)
|
return self._connection.get_user(id)
|
||||||
|
|
||||||
def get_emoji(self, id):
|
def get_emoji(self, id):
|
||||||
"""Optional[:class:`.Emoji`]: Returns an emoji with the given ID.
|
"""Returns an emoji with the given ID.
|
||||||
|
|
||||||
If not found, returns ``None``.
|
Parameters
|
||||||
|
-----------
|
||||||
|
id: :class:`int`
|
||||||
|
The ID to search for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
Optional[:class:`.Emoji`]
|
||||||
|
The custom emoji or ``None`` if not found.
|
||||||
"""
|
"""
|
||||||
return self._connection.get_emoji(id)
|
return self._connection.get_emoji(id)
|
||||||
|
|
||||||
|
@ -522,7 +522,18 @@ class Guild(Hashable):
|
|||||||
return as_list
|
return as_list
|
||||||
|
|
||||||
def get_channel(self, channel_id):
|
def get_channel(self, channel_id):
|
||||||
"""Returns a :class:`abc.GuildChannel` with the given ID. If not found, returns None."""
|
"""Returns a channel with the given ID.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
-----------
|
||||||
|
channel_id: :class:`int`
|
||||||
|
The ID to search for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
Optional[:class:`.abc.GuildChannel`]
|
||||||
|
The returned channel or ``None`` if not found.
|
||||||
|
"""
|
||||||
return self._channels.get(channel_id)
|
return self._channels.get(channel_id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -562,7 +573,18 @@ class Guild(Hashable):
|
|||||||
return list(self._members.values())
|
return list(self._members.values())
|
||||||
|
|
||||||
def get_member(self, user_id):
|
def get_member(self, user_id):
|
||||||
"""Returns a :class:`Member` with the given ID. If not found, returns None."""
|
"""Returns a member with the given ID.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
-----------
|
||||||
|
user_id: :class:`int`
|
||||||
|
The ID to search for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
Optional[:class:`Member`]
|
||||||
|
The member or ``None`` if not found.
|
||||||
|
"""
|
||||||
return self._members.get(user_id)
|
return self._members.get(user_id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -580,7 +602,18 @@ class Guild(Hashable):
|
|||||||
return sorted(self._roles.values())
|
return sorted(self._roles.values())
|
||||||
|
|
||||||
def get_role(self, role_id):
|
def get_role(self, role_id):
|
||||||
"""Returns a :class:`Role` with the given ID. If not found, returns None."""
|
"""Returns a role with the given ID.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
-----------
|
||||||
|
role_id: :class:`int`
|
||||||
|
The ID to search for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
--------
|
||||||
|
Optional[:class:`Role`]
|
||||||
|
The role or ``None`` if not found.
|
||||||
|
"""
|
||||||
return self._roles.get(role_id)
|
return self._roles.get(role_id)
|
||||||
|
|
||||||
@utils.cached_slot_property('_default_role')
|
@utils.cached_slot_property('_default_role')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user