diff --git a/discord/abc.py b/discord/abc.py index 9244200a9..9b7c5d7eb 100644 --- a/discord/abc.py +++ b/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 diff --git a/discord/appinfo.py b/discord/appinfo.py index 8478adc22..e409a80b4 100644 --- a/discord/appinfo.py +++ b/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__ = ( diff --git a/discord/calls.py b/discord/calls.py index d4f662062..99a09a864 100644 --- a/discord/calls.py +++ b/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 diff --git a/discord/client.py b/discord/client.py index b4f2500d8..a83737e6c 100644 --- a/discord/client.py +++ b/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. diff --git a/discord/commands.py b/discord/commands.py index 335980e07..9c1e6c2d5 100644 --- a/discord/commands.py +++ b/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. """ diff --git a/discord/guild.py b/discord/guild.py index 521178aab..856ec8532 100644 --- a/discord/guild.py +++ b/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. diff --git a/discord/user.py b/discord/user.py index 63da96f96..7c8e65347 100644 --- a/discord/user.py +++ b/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. diff --git a/discord/utils.py b/discord/utils.py index b932ddc78..54e732e4e 100644 --- a/discord/utils.py +++ b/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 = {} diff --git a/docs/api.rst b/docs/api.rst index 1b77f8ff1..43b92b3b5 100644 --- a/docs/api.rst +++ b/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 diff --git a/docs/index.rst b/docs/index.rst index 0a9e9c953..04ea780c2 100644 --- a/docs/index.rst +++ b/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:** Many examples are available in the :resource:`repository ` | **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. diff --git a/docs/migrating_from_dpy.rst b/docs/migrating_from_dpy.rst index bbfcb497b..2e070da7c 100644 --- a/docs/migrating_from_dpy.rst +++ b/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.