Browse Source

Docs are fun :(

pull/10109/head
dolfies 3 years ago
parent
commit
9fe7cfb474
  1. 1
      discord/__init__.py
  2. 7
      discord/abc.py
  3. 2
      discord/activity.py
  4. 4
      discord/appinfo.py
  5. 12
      discord/client.py
  6. 6
      discord/commands.py
  7. 4
      discord/errors.py
  8. 21
      discord/guild.py
  9. 2
      discord/guild_folder.py
  10. 2
      discord/member.py
  11. 2
      discord/message.py
  12. 3
      discord/scheduled_event.py
  13. 34
      discord/settings.py
  14. 2
      discord/team.py
  15. 6
      discord/utils.py
  16. 118
      docs/api.rst
  17. 8
      docs/ext/commands/api.rst

1
discord/__init__.py

@ -24,6 +24,7 @@ from .activity import *
from .appinfo import *
from .asset import *
from .audit_logs import *
from .calls import *
from .channel import *
from .client import *
from .colour import *

7
discord/abc.py

@ -458,7 +458,10 @@ class GuildChannel:
@property
def notification_settings(self) -> ChannelSettings:
""":class:`ChannelSettings`: Returns the notification settings for this channel"""
""":class:`~discord.ChannelSettings`: Returns the notification settings for this channel.
.. versionadded:: 2.0
"""
guild = self.guild
# guild.notification_settings will always be present at this point
return guild.notification_settings._channel_overrides.get(self.id) or ChannelSettings(guild.id, state=self._state) # type: ignore
@ -1768,7 +1771,7 @@ class Messageable:
List of command IDs to search for. If the command doesn't exist it won't be returned.
applications: :class:`bool`
Whether to include applications in the response. This defaults to ``False``.
application: Optional[:class:`Snowflake`]
application: Optional[:class:`~abc.Snowflake`]
Query commands only for this application.
Raises

2
discord/activity.py

@ -763,7 +763,7 @@ class CustomActivity(BaseActivity):
emoji: Optional[:class:`PartialEmoji`]
The emoji to pass to the activity, if any.
expires_at: Optional[:class:`datetime.datetime`]
When the custom activity will expire. This is only available from :attr:`discord.Settings.custom_activity`
When the custom activity will expire. This is only available from :attr:`UserSettings.custom_activity`
"""
__slots__ = ('name', 'emoji', 'expires_at')

4
discord/appinfo.py

@ -423,7 +423,7 @@ class Application(PartialApplication):
Whether the application requires a code grant or not.
flags: :class:`ApplicationFlags`
The flags of the application.
team: :class:`Snowflake`
team: :class:`~abc.Snowflake`
The team to transfer the application to.
Raises
@ -560,7 +560,7 @@ class InteractionApplication(Hashable):
Only available from :attr:`~Modal.application`.
command_count: Optional[:class:`int`]
The number of commands the application has.
Only available from :attr:`~ApplicationCommand.application`.
Only available from :attr:`~abc.ApplicationCommand.application`.
"""
__slots__ = (

12
discord/client.py

@ -1935,7 +1935,7 @@ class Client:
Returns
--------
:class:`~discord.User`
:class:`.User`
The user you requested.
"""
data = await self.http.get_user(user_id)
@ -1961,7 +1961,7 @@ class Client:
The ID of the user to fetch their profile for.
with_mutuals: :class:`bool`
Whether to fetch mutual guilds and friends.
This fills in :attr:`mutual_guilds` & :attr:`mutual_friends`.
This fills in :attr:`UserProfile.mutual_guilds` & :attr:`UserProfile.mutual_friends`.
fetch_note: :class:`bool`
Whether to pre-fetch the user's note.
@ -1976,7 +1976,7 @@ class Client:
Returns
--------
:class:`.Profile`
:class:`.UserProfile`
The profile of the user.
"""
state = self._connection
@ -2220,7 +2220,7 @@ class Client:
Returns
--------
List[:class:`PrivateChannel`]
List[:class:`.abc.PrivateChannel`]
All your private channels.
"""
state = self._connection
@ -2260,13 +2260,13 @@ class Client:
Creates a group direct message with the recipients
provided. These recipients must be have a relationship
of type :attr:`RelationshipType.friend`.
of type :attr:`.RelationshipType.friend`.
.. versionadded:: 2.0
Parameters
-----------
\*recipients: :class:`~abc.Snowflake`
\*recipients: :class:`~discord.abc.Snowflake`
An argument :class:`list` of :class:`User` to have in
your group.

6
discord/commands.py

@ -195,7 +195,7 @@ class BaseCommand(ApplicationCommand, Hashable):
@property
def target_channel(self) -> Optional[Messageable]:
"""Optional[:class:`Messageable`]: The channel this application command will be used on.
"""Optional[:class:`.abc.Messageable`]: The channel this application command will be used on.
You can set this in order to use this command in a different channel without re-fetching it.
"""
@ -324,7 +324,7 @@ class UserCommand(BaseCommand):
@property
def target_user(self) -> Optional[Snowflake]:
"""Optional[:class:`Snowflake`]: The user this application command will be used on.
"""Optional[:class:`~abc.Snowflake`]: The user this application command will be used on.
You can set this in order to use this command on a different user without re-fetching it.
"""
@ -586,7 +586,7 @@ class SubCommand(SlashMixin):
@property
def target_channel(self) -> Optional[Messageable]:
"""Optional[:class:`abc.Messageable`]: The channel this command will be used on.
"""Optional[:class:`.abc.Messageable`]: The channel this command will be used on.
You can set this in order to use this command on a different channel without re-fetching it.
"""

4
discord/errors.py

@ -191,7 +191,7 @@ class InvalidData(ClientException):
pass
class AuthFailure(ClientException):
class LoginFailure(ClientException):
"""Exception that's raised when the :meth:`Client.login` function
fails to log you in from improper credentials or some other misc.
failure.
@ -200,7 +200,7 @@ class AuthFailure(ClientException):
pass
LoginFailure = AuthFailure
AuthFailure = LoginFailure
class ConnectionClosed(ClientException):

21
discord/guild.py

@ -617,14 +617,19 @@ class Guild(Hashable):
""":class:`bool`: Returns whether you are a member of this guild.
May not be accurate for :class:`Guild`s fetched over HTTP.
.. versionadded:: 2.0
"""
if self.me or self.joined_at:
if (self.me and self.me.joined_at) or self.joined_at:
return True
return self._state.is_guild_evicted(self)
@property
def joined_at(self) -> Optional[datetime]:
""":class:`datetime.datetime`: Returns when you joined the guild."""
""":class:`datetime.datetime`: Returns when you joined the guild.
.. versionadded:: 2.0
"""
return utils.parse_time(self._joined_at)
@property
@ -1889,7 +1894,7 @@ class Guild(Hashable):
The ID of the member to fetch their profile for.
with_mutuals: :class:`bool`
Whether to fetch mutual guilds and friends.
This fills in :attr:`mutual_guilds` & :attr:`mutual_friends`.
This fills in :attr:`MemberProfile.mutual_guilds` & :attr:`MemberProfile.mutual_friends`.
fetch_note: :class:`bool`
Whether to pre-fetch the user's note.
@ -3556,7 +3561,7 @@ class Guild(Hashable):
Parameters
-----------
channel: :abc.Snowflake`
channel: :class:`~abc.Snowflake`
The channel to request members from.
Raises
@ -3598,14 +3603,14 @@ class Guild(Hashable):
.. versionadded:: 2.0
.. note::
If you are the owner, have either of :attr:`Permissions.adminstrator`,
:attr:`Permission.kick_members`, :attr:`Permission.ban_members`, or :attr:`Permission.manage_roles`,
If you are the owner, have either of :attr:`~Permissions.adminstrator`,
:attr:`~Permissions.kick_members`, :attr:`~Permissions.ban_members`, or :attr:`~Permissions.manage_roles`,
permissions will be fetched through OPcode 8 (this includes offline members).
Else, they will be scraped from the member sidebar.
Parameters
-----------
channels: List[:abc.Snowflake`]
channels: List[:class:`~abc.Snowflake`]
A list of up to 5 channels to request members from. More channels make it faster.
This only applies when scraping from the member sidebar.
cache: :class:`bool`
@ -3684,7 +3689,7 @@ class Guild(Hashable):
.. versionadded:: 1.4
subscribe: :class:`bool`
Whether to subscribe to the resulting members. This will keep their info and presence updated.
This defaults to ``False``.
This requires another request, and defaults to ``False``.
.. versionadded:: 2.0

2
discord/guild_folder.py

@ -123,7 +123,7 @@ class GuildFolder:
@property
def color(self) -> Optional[Colour]:
"""Optional[:class:`Color`] The color of the folder.
"""Optional[:class:`Colour`] The color of the folder.
This is an alias for :attr:`colour`.
"""

2
discord/member.py

@ -1147,7 +1147,7 @@ class Member(discord.abc.Messageable, discord.abc.Connectable, _UserTag):
List of command IDs to search for. If the command doesn't exist it won't be returned.
applications: :class:`bool`
Whether to include applications in the response. This defaults to ``False``.
application: Optional[:class:`Snowflake`]
application: Optional[:class:`~abc.Snowflake`]
Query commands only for this application.
Raises

2
discord/message.py

@ -2019,7 +2019,7 @@ class Message(PartialMessage, Hashable):
List of command IDs to search for. If the command doesn't exist it won't be returned.
applications: :class:`bool`
Whether to include applications in the response. This defaults to ``False``.
application: Optional[:class:`Snowflake`]
application: Optional[:class:`~abc.Snowflake`]
Query commands only for this application.
Raises

3
discord/scheduled_event.py

@ -481,9 +481,6 @@ class ScheduledEvent(Hashable):
Retrieves all :class:`User` that are subscribed to this event.
This requires :attr:`Intents.members` to get information about members
other than yourself.
Raises
-------
HTTPException

34
discord/settings.py

@ -409,7 +409,17 @@ class MuteConfig:
class ChannelSettings:
"""Represents a channel's notification settings."""
"""Represents a channel's notification settings.
Attributes
----------
level: :class:`NotificationLevel`
The notification level for the channel.
muted: :class:`MuteConfig`
The mute configuration for the channel.
collapsed: :class:`bool`
Unknown.
"""
if TYPE_CHECKING:
_channel_id: int
@ -431,7 +441,7 @@ class ChannelSettings:
@property
def channel(self) -> Optional[GuildChannel]:
"""Optional[:class:`GuildChannel`]: Returns the channel these settings are for."""
"""Optional[:class:`.abc.GuildChannel`]: Returns the channel these settings are for."""
guild = self._state._get_guild(self._guild_id)
return guild and guild.get_channel(self._channel_id)
@ -500,7 +510,25 @@ class ChannelSettings:
class GuildSettings:
"""Represents a guild's notification settings."""
"""Represents a guild's notification settings.
Attributes
----------
level: :class:`NotificationLevel`
The notification level for the guild.
muted: :class:`MuteConfig`
The mute configuration for the guild.
suppress_everyone: :class:`bool`
Whether to suppress @everyone/@here notifications.
suppress_roles: :class:`bool`
Whether to suppress role notifications.
hide_muted_channels: :class:`bool`
Whether to hide muted channels.
mobile_push_notifications: :class:`bool`
Whether to enable mobile push notifications.
version: :class:`int`
The version of the guild's settings.
"""
if TYPE_CHECKING:
_channel_overrides: Dict[int, ChannelSettings]

2
discord/team.py

@ -145,7 +145,7 @@ class Team(Hashable):
The name of the team.
icon: Optional[:class:`bytes`]
The icon of the team.
owner: :class:`Snowflake`
owner: :class:`~abc.Snowflake`
The team's owner.
Raises

6
discord/utils.py

@ -1176,11 +1176,11 @@ def set_target(
Parameters
-----------
items: Iterable[:class:`ApplicationCommand`]
items: Iterable[:class:`.abc.ApplicationCommand`]
A list of items to set the target for.
channel: Optional[:class:`Messageable`]
channel: Optional[:class:`.abc.Messageable`]
The channel to target.
message: Optional[:class:`Message`]
message: Optional[:class:`.Message`]
The message to target.
user: Optional[:class:`~abc.Snowflake`]
The user to target.

118
docs/api.rst

@ -45,6 +45,14 @@ Client
.. automethod:: Client.event()
:decorator:
CaptchaHandler
~~~~~~~~~~~~~~
.. attribute:: CaptchaHandler
.. autoclass:: CaptchaHandler
:members:
Voice Related
---------------
@ -379,13 +387,13 @@ Client
.. function:: on_guild_settings_update(before, after)
Called when a :class:`Guild`'s :class:`GuildSettings` updates, for example:
Called when a :class:`.Guild`'s :class:`.GuildSettings` updates, for example:
- Muted guild
- Changed guild notification settings
- etc
Note that you can get the guild from :attr:`GuildSettings.guild`.
Note that you can get the guild from :attr:`.GuildSettings.guild`.
.. versionadded:: 2.0
@ -406,7 +414,7 @@ Client
.. function:: on_connections_update()
Called when your account connections are updated.
The updated connections are not provided and must be fetched by :func:`Client.connections`.
The updated connections are not provided and must be fetched by :func:`.Client.connections`.
.. versionadded:: 2.0
@ -445,8 +453,8 @@ Calls
.. function:: on_call_update(before, after)
Called when a :class:`Call` is updated, e.g. when a member is added
or another person is rung.
Called when a :class:`PrivateCall` or :class:`GroupCall` is updated,
e.g. when a member is added or another person is rung.
:param before: The previous call.
:type before: :class:`Relationship`
@ -856,14 +864,6 @@ Reactions
To get the :class:`Message` being reacted, access it via :attr:`Reaction.message`.
.. note::
This doesn't require :attr:`Intents.members` within a guild context,
but due to Discord not providing updated user information in a direct message
it's required for direct messages to receive this event.
Consider using :func:`on_raw_reaction_add` if you need this and do not otherwise want
to enable the members intent.
:param reaction: The current state of the reaction.
:type reaction: :class:`Reaction`
:param user: The user who added the reaction.
@ -879,8 +879,6 @@ Reactions
To get the message being reacted, access it via :attr:`Reaction.message`.
This requires both :attr:`Intents.reactions` and :attr:`Intents.members` to be enabled.
.. note::
Consider using :func:`on_raw_reaction_remove` if you need this and do not want
@ -1382,6 +1380,20 @@ of :class:`enum.Enum`.
.. versionadded:: 2.0
.. class:: InviteType
Specifies the type of :class:`Invite`.
.. attribute:: guild
A guild invite.
.. attribute:: group_dm
A group DM invite.
.. attribute:: friend
A friend invite.
.. class:: UserFlags
Represents Discord User flags.
@ -1497,6 +1509,20 @@ of :class:`enum.Enum`.
.. versionadded:: 1.5
.. class:: HypeSquadHouse
Specifies the HypeSquad house a user belongs to.
.. attribute:: bravery
The "Bravery" house.
.. attribute:: brilliance
The "Brilliance" house.
.. attribute:: balance
The "Balance" house.
.. class:: VerificationLevel
Specifies a :class:`Guild`\'s verification level, which is the criteria in
@ -2877,6 +2903,22 @@ of :class:`enum.Enum`.
Represents the Discord Nitro with no Nitro-exclusive games.
.. class:: StickerAnimationOptions
Represents the options found in ``Settings > Accessibility > Stickers`` in the Discord client.
.. attribute:: always
Always animate stickers.
.. attribute:: on_interaction
Animate stickers when they are interacted with.
.. attribute:: never
Never animate stickers.
.. class:: Theme
Represents the theme synced across all Discord clients.
@ -4122,6 +4164,11 @@ Settings
.. autoclass:: ChannelSettings()
:members:
.. attributetable:: Tracking
.. autoclass:: Tracking()
:members:
.. attributetable:: GuildFolder
.. autoclass:: GuildFolder()
@ -4275,7 +4322,7 @@ Sticker
:members:
GuildChannel
~~~~~~~~~~~~~~
~~~~~~~~~~~~~
.. attributetable:: CategoryChannel
@ -4316,7 +4363,7 @@ GuildChannel
:inherited-members:
PrivateChannel
~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~
.. attributetable:: DMChannel
@ -4339,7 +4386,7 @@ PrivateChannel
:async-with:
PartialMessageable
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~
.. attributetable:: PartialMessageable
@ -4373,6 +4420,25 @@ StageInstance
.. autoclass:: StageInstance()
:members:
Call
~~~~
.. attributetable:: PrivateCall
.. autoclass:: PrivateCall()
:members:
.. attributetable:: GroupCall
.. autoclass:: GroupCall()
:members:
:inherited-members:
.. attributetable:: CallMessage
.. autoclass:: CallMessage()
:members:
Message
~~~~~~~~
@ -4410,6 +4476,22 @@ Reaction
.. autoclass:: Reaction()
:members:
Interaction
~~~~~~~~~~~~
.. attributetable:: Interaction
.. autoclass:: Interaction()
:members:
Modal
~~~~~
.. attributetable:: Modal
.. autoclass:: Modal()
:members:
ApplicationCommand
~~~~~~~~~~~~~~~~~~

8
docs/ext/commands/api.rst

@ -322,6 +322,14 @@ Checks
.. _ext_commands_api_context:
Cooldown
---------
.. attributetable:: discord.ext.commands.Cooldown
.. autoclass:: discord.ext.commands.Cooldown
:members:
Context
--------

Loading…
Cancel
Save