Browse Source

Docs are fun 😭

pull/10109/head
dolfies 3 years ago
parent
commit
13d7bafd64
  1. 2
      discord/abc.py
  2. 2
      discord/appinfo.py
  3. 2
      discord/calls.py
  4. 7
      discord/client.py
  5. 4
      discord/commands.py
  6. 23
      discord/guild.py
  7. 2
      discord/user.py
  8. 2
      discord/utils.py
  9. 189
      docs/api.rst
  10. 2
      docs/index.rst
  11. 2
      docs/migrating_from_dpy.rst

2
discord/abc.py

@ -1771,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:`~abc.Snowflake`]
application: Optional[:class:`~discord.abc.Snowflake`]
Query commands only for this application.
Raises

2
discord/appinfo.py

@ -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:`~abc.ApplicationCommand.application`.
Only available from :attr:`~discord.abc.ApplicationCommand.application`.
"""
__slots__ = (

2
discord/calls.py

@ -93,7 +93,7 @@ class CallMessage:
@property
def channel(self) -> _PrivateChannel:
r""":class:`PrivateChannel`\: The private channel associated with this message."""
""":class:`.abc.PrivateChannel`: The private channel associated with this message."""
return self.message.channel # type: ignore # Can only be a private channel here
@property

7
discord/client.py

@ -573,9 +573,6 @@ class Client:
Raises
-------
GatewayNotFound
If the gateway to connect to Discord is not found. Usually if this
is thrown then there is a Discord API outage.
ConnectionClosed
The websocket connection has been terminated.
"""
@ -1675,7 +1672,7 @@ class Client:
if attr is not MISSING:
lurking = not attr
elif (new_guild := self._connection._get_guild(guild.id)) is not None:
lurking = not new_guild.joined
lurking = not new_guild.is_joined()
await self.http.leave_guild(guild.id, lurking=lurking)
@ -1961,7 +1958,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:`UserProfile.mutual_guilds` & :attr:`UserProfile.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.

4
discord/commands.py

@ -51,7 +51,7 @@ __all__ = (
@runtime_checkable
class ApplicationCommand(Protocol):
"""An ABC that represents a useable application command.
"""An ABC that represents a usable application command.
The following implement this ABC:
@ -67,7 +67,7 @@ class ApplicationCommand(Protocol):
The command's name.
description: :class:`str`
The command's description, if any.
type: :class:`AppCommandType`
type: :class:`.enums.AppCommandType`
The type of application command.
"""

23
discord/guild.py

@ -342,6 +342,7 @@ class Guild(Hashable):
def __init__(self, *, data: Union[GuildPayload, GuildPreviewPayload], state: ConnectionState) -> None:
self._chunked = False
self._cs_joined = None
self._roles: Dict[int, Role] = {}
self._channels: Dict[int, GuildChannel] = {}
self._members: Dict[int, Member] = {}
@ -612,14 +613,20 @@ class Guild(Hashable):
self_id = self._state.self_id
return self.get_member(self_id) # type: ignore # The self member is *always* cached
@utils.cached_slot_property('_cs_joined')
def joined(self) -> bool:
""":class:`bool`: Returns whether you are a member of this guild.
def is_joined(self) -> bool:
"""Returns whether you are a member of this guild.
May not be accurate for :class:`Guild`s fetched over HTTP.
May not be accurate for :class:`Guild` s fetched over HTTP.
.. versionadded:: 2.0
Returns
-------
:class:`bool`
Whether you are a member of this guild.
"""
if self._cs_joined is not None:
return self._cs_joined
if (self.me and self.me.joined_at) or self.joined_at:
return True
return self._state.is_guild_evicted(self)
@ -1544,7 +1551,7 @@ class Guild(Hashable):
HTTPException
Leaving the guild failed.
"""
await self._state.http.leave_guild(self.id, lurking=not self.joined)
await self._state.http.leave_guild(self.id, lurking=not self.is_joined())
async def delete(self) -> None:
"""|coro|
@ -1894,7 +1901,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:`MemberProfile.mutual_guilds` & :attr:`MemberProfile.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.
@ -3566,7 +3573,7 @@ class Guild(Hashable):
Raises
-------
ClientException:
ClientException
This guild cannot be chunked or chunking failed.
Guild is no longer available.
@ -3603,7 +3610,7 @@ class Guild(Hashable):
.. versionadded:: 2.0
.. note::
If you are the owner, have either of :attr:`~Permissions.adminstrator`,
If you are the owner, have either of :attr:`~Permissions.administrator`,
: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.

2
discord/user.py

@ -1083,7 +1083,7 @@ class User(BaseUser, discord.abc.Connectable, discord.abc.Messageable):
------------
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.

2
discord/utils.py

@ -1182,7 +1182,7 @@ def set_target(
The channel to target.
message: Optional[:class:`.Message`]
The message to target.
user: Optional[:class:`~abc.Snowflake`]
user: Optional[:class:`~discord.abc.Snowflake`]
The user to target.
"""
attrs = {}

189
docs/api.rst

@ -48,7 +48,7 @@ Client
CaptchaHandler
~~~~~~~~~~~~~~
.. attribute:: CaptchaHandler
.. attributetable:: CaptchaHandler
.. autoclass:: CaptchaHandler
:members:
@ -371,7 +371,7 @@ Client
.. function:: on_settings_update(before, after)
Called when your :class:`Settings` updates, for example:
Called when your :class:`UserSettings` updates, for example:
- Changed theme
- Changed custom activity
@ -381,19 +381,19 @@ Client
.. versionadded:: 2.0
:param before: The settings prior to being updated.
:type before: :class:`Settings`
:type before: :class:`UserSettings`
:param after: The settings after being updated.
:type after: :class:`Settings`
:type after: :class:`SettiUserSettingsngs`
.. 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
- Muted guild or channel
- Changed 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
@ -414,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 :meth:`Client.connections`.
.. versionadded:: 2.0
@ -2408,30 +2408,30 @@ of :class:`enum.Enum`.
Represents the membership state of a :class:`TeamMember`.
    .. container:: operations
.. versionadded:: 1.3
        .. versionadded:: 2.0
.. container:: operations
        .. describe:: x == y
.. versionadded:: 2.0
            Checks if two membership states are equal.
        .. describe:: x != y
      .. describe:: x == y
            Checks if two membership states are not equal.
        .. describe:: x > y
          Checks if two application states are equal.
      .. describe:: x != y
            Checks if a membership state is higher than another.
        .. describe:: x < y
          Checks if two application states are not equal.
      .. describe:: x > y
            Checks if a membership state is lower than another.
        .. describe:: x >= y
          Checks if a application state is higher than another.
      .. describe:: x < y
            Checks if a membership state is higher or equal to another.
        .. describe:: x <= y
          Checks if a application state is lower than another.
      .. describe:: x >= y
            Checks if a membership state is lower or equal to another.
          Checks if a application state is higher or equal to another.
      .. describe:: x <= y
.. versionadded:: 1.3
          Checks if a application state is lower or equal to another.
.. attribute:: invited
@ -2467,30 +2467,28 @@ of :class:`enum.Enum`.
Represents the verification application state of a :class:`Application`.
    .. container:: operations
        .. versionadded:: 2.0
.. versionadded:: 2.0
        .. describe:: x == y
.. container:: operations
            Checks if two application states are equal.
        .. describe:: x != y
      .. describe:: x == y
            Checks if two application states are not equal.
        .. describe:: x > y
          Checks if two application states are equal.
      .. describe:: x != y
            Checks if a application state is higher than another.
        .. describe:: x < y
          Checks if two application states are not equal.
      .. describe:: x > y
            Checks if a application state is lower than another.
        .. describe:: x >= y
          Checks if a application state is higher than another.
      .. describe:: x < y
            Checks if a application state is higher or equal to another.
        .. describe:: x <= y
          Checks if a application state is lower than another.
      .. describe:: x >= y
            Checks if a application state is lower or equal to another.
          Checks if a application state is higher or equal to another.
      .. describe:: x <= y
.. versionadded:: 2.0
          Checks if a application state is lower or equal to another.
.. attribute:: ineligible
@ -2512,30 +2510,28 @@ of :class:`enum.Enum`.
Represents the commerce application state of a :class:`Application`.
    .. container:: operations
        .. versionadded:: 2.0
.. versionadded:: 2.0
        .. describe:: x == y
.. container:: operations
            Checks if two application states are equal.
        .. describe:: x != y
      .. describe:: x == y
            Checks if two application states are not equal.
        .. describe:: x > y
          Checks if two application states are equal.
      .. describe:: x != y
            Checks if a application state is higher than another.
        .. describe:: x < y
          Checks if two application states are not equal.
      .. describe:: x > y
            Checks if a application state is lower than another.
        .. describe:: x >= y
          Checks if a application state is higher than another.
      .. describe:: x < y
            Checks if a application state is higher or equal to another.
        .. describe:: x <= y
          Checks if a application state is lower than another.
      .. describe:: x >= y
            Checks if a application state is lower or equal to another.
          Checks if a application state is higher or equal to another.
      .. describe:: x <= y
.. versionadded:: 2.0
          Checks if a application state is lower or equal to another.
.. attribute:: none
@ -2565,30 +2561,28 @@ of :class:`enum.Enum`.
Represents the RPC application state of a :class:`Application`.
    .. container:: operations
        .. versionadded:: 2.0
.. versionadded:: 2.0
        .. describe:: x == y
.. container:: operations
            Checks if two application states are equal.
        .. describe:: x != y
      .. describe:: x == y
            Checks if two application states are not equal.
        .. describe:: x > y
          Checks if two application states are equal.
      .. describe:: x != y
            Checks if a application state is higher than another.
        .. describe:: x < y
          Checks if two application states are not equal.
      .. describe:: x > y
            Checks if a application state is lower than another.
        .. describe:: x >= y
          Checks if a application state is higher than another.
      .. describe:: x < y
            Checks if a application state is higher or equal to another.
        .. describe:: x <= y
          Checks if a application state is lower than another.
      .. describe:: x >= y
            Checks if a application state is lower or equal to another.
          Checks if a application state is higher or equal to another.
      .. describe:: x <= y
.. versionadded:: 2.0
          Checks if a application state is lower or equal to another.
.. attribute:: disabled
@ -4492,6 +4486,42 @@ Modal
.. autoclass:: Modal()
:members:
Component
~~~~~~~~~~
.. attributetable:: Component
.. autoclass:: Component()
:members:
.. attributetable:: ActionRow
.. autoclass:: ActionRow()
:members:
.. attributetable:: Button
.. autoclass:: Button()
:members:
:inherited-members:
.. attributetable:: SelectMenu
.. autoclass:: SelectMenu()
:members:
:inherited-members:
.. attributetable:: SelectOption
.. autoclass:: SelectOption()
:members:
.. attributetable:: TextInput
.. autoclass:: TextInput()
:members:
:inherited-members:
ApplicationCommand
~~~~~~~~~~~~~~~~~~
@ -4580,7 +4610,20 @@ Widget
:members:
:inherited-members:
Raw events
WelcomeScreen
~~~~~~~~~~~~~~
.. attributetable:: WelcomeScreen
.. autoclass:: WelcomeScreen()
:members:
.. attributetable:: WelcomeChannel
.. autoclass:: WelcomeChannel()
:members:
Raw Events
~~~~~~~~~~~
.. attributetable:: RawMessageDeleteEvent

2
docs/index.rst

@ -24,7 +24,7 @@ Is this your first time using the library? This is the place to get started!
- **Migrating from discord.py:** :doc:`migrating_from_dpy`
- **First steps:** :doc:`intro` | :doc:`quickstart` | :doc:`logging`
- **Working with Discord:** :doc:`token`
- **Examples:** Many examples are available in the :resource:`repository <examples>`.
- **Examples:** Many examples are available in the :resource:`repository <examples>`
| **Obligatory note:**
| Automating user accounts is against the Discord ToS. If what you are trying to do is accomplishable with a bot account, please use one.

2
docs/migrating_from_dpy.rst

@ -72,7 +72,7 @@ Additionally, while you can subscribe to 5 channels/request, the channels need t
You may have already noticed a few problems with this:
1. You'll get spammed with ``member_add/remove``s whenever someone changes position in the member sidebar.
1. You'll get spammed with ``member_add/remove`` s whenever someone changes position in the member sidebar.
2. For guilds with >1,000 members you don't receive offline members. So, you won't know if an offline member is kicked, or an invisible member joins/leaves. You also won't know if someone came online or joined. Or, if someone went offline or left.
| #1 is mostly solveable with a bit of parsing, but #2 is a huge problem.

Loading…
Cancel
Save