added versionadded

This commit is contained in:
iDutchy 2020-10-21 17:44:46 -05:00
parent 2b5490d4cb
commit 3521ae985a
7 changed files with 64 additions and 8 deletions

View File

@ -27,6 +27,7 @@ Custom Features
- Added ``Intents.from_list``
- Added support for ``int()`` to ``discord.User``, ``discord.Member``, ``discord.Emoji``, ``discord.Role``, ``discord.Guild``, ``discord.Message``, ``discord.TextChannel``, ``discord.VoiceChannel``, ``discord.CategoryChannel``, ``discord.Attachment`` and ``discord.Message``. This will return their id
- Added support for ``str()`` to ``discord.Message``. This will return the message content
- Added ``Guild.try_member``
Key Features
-------------
@ -46,10 +47,10 @@ To install the library without full voice support, you can just run the followin
.. code:: sh
# Linux/macOS
python3 -m pip install -U git+https://github.com/iDutchy/discord.py
python3 -m pip install -U enhanced-dpy
# Windows
py -3 -m pip install -U git+https://github.com/iDutchy/discord.py
py -3 -m pip install -U enhanced-dpy
To install the development version, do the following:

View File

@ -144,7 +144,9 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
@property
def can_send(self):
""":class:`bool`: Checks if the bot can send messages"""
""":class:`bool`: Checks if the bot can send messages
.. versionadded:: 1.5.0.1"""
return self.guild.me.guild_permissions.send_messages
def permissions_for(self, member):

View File

@ -226,6 +226,8 @@ class Client:
remove the need to set the color per embed, but can still be overridden by setting a
color while creating an instance of an embed.
.. versionadded:: 1.5.0.1
Attributes
-----------
ws
@ -294,6 +296,8 @@ class Client:
This will raise a TypeError if an improper format was passed.
.. versionadded:: 1.5.0.1
Parameters
-----------
color: Union[:class:`.Colour`, :class:`int`]
@ -1410,6 +1414,8 @@ class Client:
Retrieves a :class:`~discord.User` based on their ID. This can only
be used by bot accounts.
.. versionadded:: 1.5.0.1
.. note::
This will first attempt to get the user from the cache.

View File

@ -128,14 +128,18 @@ class BotBase(GroupMixin):
@property
def owner(self):
""":class:`discord.User`: The owner, retrieved from owner_id. In case of improper caching, this can return None"""
""":class:`discord.User`: The owner, retrieved from owner_id. In case of improper caching, this can return None
.. versionadded:: 1.5.0.1"""
if not self.owner_id or self.owner_ids:
raise AttributeError('No owner_id specified or you used owner_ids. If you used owner_ids, please refer to `Bot.owners`')
return self.get_user(self.owner_id)
@property
def owners(self):
"""List[:class:`discord.User`]: The owners, retrieved from owner_ids. In case of improper caching, this list may not contain all owners."""
"""List[:class:`discord.User`]: The owners, retrieved from owner_ids. In case of improper caching, this list may not contain all owners.
.. versionadded:: 1.5.0.1"""
if not self.owner_ids or self.owner_id:
raise TypeError('No owner_ids specified or you used owner_id. If you used owner_id, please refer to `Bot.owner`')
owners = []

View File

@ -405,7 +405,9 @@ class Intents(BaseFlags):
@classmethod
def from_list(cls, intents_list):
"""A factory method that creates a :class:`Intents` with everything enabled
that has been passed in the list."""
that has been passed in the list.
.. versionadded:: 1.5.0.1"""
for item in intents_list:
if item not in cls.VALID_FLAGS.keys():
intents_list.remove(item)

View File

@ -520,12 +520,16 @@ class Guild(Hashable):
@property
def bots(self):
"""List[:class:`Member`]: A list of bots that belong to this guild."""
"""List[:class:`Member`]: A list of bots that belong to this guild.
.. versionadded:: 1.5.0.1"""
return list(m for m in self._members.values() if m.bot)
@property
def humans(self):
"""List[:class:`Member`]: A list of humans that belong to this guild."""
"""List[:class:`Member`]: A list of humans that belong to this guild.
.. versionadded:: 1.5.0.1"""
return list(m for m in self._members.values() if not m.bot)
def get_member(self, user_id):
@ -1293,6 +1297,42 @@ class Guild(Hashable):
"""
return MemberIterator(self, limit=limit, after=after)
async def try_member(self, member_id):
"""|coro|
Retreives a :class:`Member` from a guild ID, and a member ID.
.. versionadded:: 1.5.1.2
.. note::
This will first attempt to get the member from the cache.
If that fails, it will make an API call.
This method is an API call. For general usage, consider :meth:`get_member` instead.
Parameters
-----------
member_id: :class:`int`
The member's ID to fetch from.
Raises
-------
Forbidden
You do not have access to the guild.
HTTPException
Fetching the member failed.
Returns
--------
:class:`Member`
The member from the member ID.
"""
member = self.get_member(member_id)
if member is None:
member = await self.fetch_member(member_id)
return member
async def fetch_member(self, member_id):
"""|coro|

View File

@ -32,6 +32,7 @@ Custom Features
- Added ``Intents.from_list``
- Added support for ``int()`` to ``discord.User``, ``discord.Member``, ``discord.Emoji``, ``discord.Role``, ``discord.Guild``, ``discord.Message``, ``discord.TextChannel``, ``discord.VoiceChannel``, ``discord.CategoryChannel``, ``discord.Attachment`` and ``discord.Message``. This will return their id
- Added support for ``str()`` to ``discord.Message``. This will return the message content
- Added ``Guild.try_member``
Features
--------