Skip to content

Commit 31f5e12

Browse files
JustaSqu1dpre-commit-ci[bot]Lulalaby
authored
feat: add missing AppInfo attributes (#2520)
* feat: add missing AppInfo attributes * fix: add `install_params` to slots * docs: add related documentation * style(pre-commit): auto fixes from pre-commit.com hooks * fix: typing * docs: fix spacing * style(pre-commit): auto fixes from pre-commit.com hooks * fix: add AppInstallParams to `__all__` * fix: invalid scopes typehint * fix: docs types formatting * docs: add changelog entry * style(pre-commit): auto fixes from pre-commit.com hooks * feat: deprecate `AppInfo.summary` * style(pre-commit): auto fixes from pre-commit.com hooks * docs: fix changelog to adhere to conventions * fix: properly deprecate `summary` * docs: fix `tags` typing * style(pre-commit): auto fixes from pre-commit.com hooks * docs: fix summary formatting --------- Signed-off-by: JustaSqu1d <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lala Sabathil <[email protected]>
1 parent eb3ac6b commit 31f5e12

File tree

4 files changed

+134
-15
lines changed

4 files changed

+134
-15
lines changed

CHANGELOG.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ These changes are available on the `master` branch, but have not yet been releas
1212

1313
⚠️ **This Version Removes Support For Python 3.8** ⚠️
1414

15+
### Added
16+
17+
- Added `Guild.fetch_role` method.
18+
([#2528](https://github.com/Pycord-Development/pycord/pull/2528))
19+
- Added the following `AppInfo` attributes: `approximate_guild_count`,
20+
`approximate_user_install_count`, `custom_install_url`, `install_params`,
21+
`interactions_endpoint_url`, `redirect_uris`, `role_connections_verification_url`, and
22+
`tags`. ([#2520](https://github.com/Pycord-Development/pycord/pull/2520))
23+
- Added `Member.guild_banner` and `Member.display_banner` properties.
24+
([#2556](https://github.com/Pycord-Development/pycord/pull/2556))
25+
1526
### Changed
1627

1728
- Renamed `cover` property of `ScheduledEvent` and `cover` argument of
@@ -20,20 +31,15 @@ These changes are available on the `master` branch, but have not yet been releas
2031
- ⚠️ **This Version Removes Support For Python 3.8** ⚠️
2132
([#2521](https://github.com/Pycord-Development/pycord/pull/2521))
2233

23-
### Added
34+
### Deprecated
2435

25-
- Added `Guild.fetch_role` method.
26-
([#2528](https://github.com/Pycord-Development/pycord/pull/2528))
27-
- Added `Member.guild_banner` and `Member.display_banner` properties.
28-
([#2556](https://github.com/Pycord-Development/pycord/pull/2556))
36+
- Deprecated `AppInfo.summary` in favor of `AppInfo.description`.
37+
([#2520](https://github.com/Pycord-Development/pycord/pull/2520))
2938

3039
### Fixed
3140

3241
- Fixed `EntitlementIterator` behavior with `limit > 100`.
3342
([#2555](https://github.com/Pycord-Development/pycord/pull/2555))
34-
35-
### Fixed
36-
3743
- Fixed missing `stacklevel` parameter in `warn_deprecated` function call inside
3844
`@utils.deprecated`. ([#2500](https://github.com/Pycord-Development/pycord/pull/2500))
3945
- Fixed the typehint in `ConnectionState._polls` to reflect actual behavior, changing it

discord/appinfo.py

+110-7
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,21 @@
2929

3030
from . import utils
3131
from .asset import Asset
32+
from .permissions import Permissions
3233

3334
if TYPE_CHECKING:
3435
from .guild import Guild
3536
from .state import ConnectionState
3637
from .types.appinfo import AppInfo as AppInfoPayload
38+
from .types.appinfo import AppInstallParams as AppInstallParamsPayload
3739
from .types.appinfo import PartialAppInfo as PartialAppInfoPayload
3840
from .types.appinfo import Team as TeamPayload
3941
from .user import User
4042

4143
__all__ = (
4244
"AppInfo",
4345
"PartialAppInfo",
46+
"AppInstallParams",
4447
)
4548

4649

@@ -70,11 +73,6 @@ class AppInfo:
7073
grant flow to join.
7174
rpc_origins: Optional[List[:class:`str`]]
7275
A list of RPC origin URLs, if RPC is enabled.
73-
summary: :class:`str`
74-
If this application is a game sold on Discord,
75-
this field will be the summary field for the store page of its primary SKU.
76-
77-
.. versionadded:: 1.3
7876
7977
verify_key: :class:`str`
8078
The hex encoded key for verification in interactions and the
@@ -110,6 +108,48 @@ class AppInfo:
110108
The application's privacy policy URL, if set.
111109
112110
.. versionadded:: 2.0
111+
112+
approximate_guild_count: Optional[:class:`int`]
113+
The approximate count of guilds to which the app has been added, if any.
114+
115+
.. versionadded:: 2.7
116+
117+
approximate_user_install_count: Optional[:class:`int`]
118+
The approximate count of users who have installed the application, if any.
119+
120+
.. versionadded:: 2.7
121+
122+
redirect_uris: Optional[List[:class:`str`]]
123+
The list of redirect URIs for the application, if set.
124+
125+
.. versionadded:: 2.7
126+
127+
interactions_endpoint_url: Optional[:class:`str`]
128+
The interactions endpoint URL for the application, if set.
129+
130+
.. versionadded:: 2.7
131+
132+
role_connections_verification_url: Optional[:class:`str`]
133+
The role connection verification URL for the application, if set.
134+
135+
.. versionadded:: 2.7
136+
137+
install_params: Optional[List[:class:`AppInstallParams`]]
138+
The settings for the application's default in-app authorization link, if set.
139+
140+
.. versionadded:: 2.7
141+
142+
tags: Optional[List[:class:`str`]]
143+
The list of tags describing the content and functionality of the app, if set.
144+
145+
Maximium of 5 tags.
146+
147+
.. versionadded:: 2.7
148+
149+
custom_install_url: Optional[:class:`str`]
150+
The default custom authorization URL for the application, if set.
151+
152+
.. versionadded:: 2.7
113153
"""
114154

115155
__slots__ = (
@@ -122,7 +162,7 @@ class AppInfo:
122162
"bot_require_code_grant",
123163
"owner",
124164
"_icon",
125-
"summary",
165+
"_summary",
126166
"verify_key",
127167
"team",
128168
"guild_id",
@@ -131,6 +171,14 @@ class AppInfo:
131171
"_cover_image",
132172
"terms_of_service_url",
133173
"privacy_policy_url",
174+
"approximate_guild_count",
175+
"approximate_user_install_count",
176+
"redirect_uris",
177+
"interactions_endpoint_url",
178+
"role_connections_verification_url",
179+
"install_params",
180+
"tags",
181+
"custom_install_url",
134182
)
135183

136184
def __init__(self, state: ConnectionState, data: AppInfoPayload):
@@ -149,7 +197,7 @@ def __init__(self, state: ConnectionState, data: AppInfoPayload):
149197
team: TeamPayload | None = data.get("team")
150198
self.team: Team | None = Team(state, team) if team else None
151199

152-
self.summary: str = data["summary"]
200+
self._summary: str = data["summary"]
153201
self.verify_key: str = data["verify_key"]
154202

155203
self.guild_id: int | None = utils._get_as_snowflake(data, "guild_id")
@@ -161,6 +209,24 @@ def __init__(self, state: ConnectionState, data: AppInfoPayload):
161209
self._cover_image: str | None = data.get("cover_image")
162210
self.terms_of_service_url: str | None = data.get("terms_of_service_url")
163211
self.privacy_policy_url: str | None = data.get("privacy_policy_url")
212+
self.approximate_guild_count: int | None = data.get("approximate_guild_count")
213+
self.approximate_user_install_count: int | None = data.get(
214+
"approximate_user_install_count"
215+
)
216+
self.redirect_uris: list[str] | None = data.get("redirect_uris", [])
217+
self.interactions_endpoint_url: str | None = data.get(
218+
"interactions_endpoint_url"
219+
)
220+
self.role_connections_verification_url: str | None = data.get(
221+
"role_connections_verification_url"
222+
)
223+
224+
install_params = data.get("install_params")
225+
self.install_params: AppInstallParams | None = (
226+
AppInstallParams(install_params) if install_params else None
227+
)
228+
self.tags: list[str] | None = data.get("tags", [])
229+
self.custom_install_url: str | None = data.get("custom_install_url")
164230

165231
def __repr__(self) -> str:
166232
return (
@@ -195,6 +261,23 @@ def guild(self) -> Guild | None:
195261
"""
196262
return self._state._get_guild(self.guild_id)
197263

264+
@property
265+
def summary(self) -> str | None:
266+
"""If this application is a game sold on Discord,
267+
this field will be the summary field for the store page of its primary SKU.
268+
269+
It currently returns an empty string.
270+
271+
.. versionadded:: 1.3
272+
.. deprecated:: 2.7
273+
"""
274+
utils.warn_deprecated(
275+
"summary",
276+
"description",
277+
reference="https://discord.com/developers/docs/resources/application#application-object-application-structure",
278+
)
279+
return self._summary
280+
198281

199282
class PartialAppInfo:
200283
"""Represents a partial AppInfo given by :func:`~discord.abc.GuildChannel.create_invite`
@@ -257,3 +340,23 @@ def icon(self) -> Asset | None:
257340
if self._icon is None:
258341
return None
259342
return Asset._from_icon(self._state, self.id, self._icon, path="app")
343+
344+
345+
class AppInstallParams:
346+
"""Represents the settings for the custom authorization URL of an application.
347+
348+
.. versionadded:: 2.7
349+
350+
Attributes
351+
----------
352+
scopes: List[:class:`str`]
353+
The list of OAuth2 scopes for adding the application to a guild.
354+
permissions: :class:`Permissions`
355+
The permissions to request for the bot role in the guild.
356+
"""
357+
358+
__slots__ = ("scopes", "permissions")
359+
360+
def __init__(self, data: AppInstallParamsPayload) -> None:
361+
self.scopes: list[str] = data.get("scopes", [])
362+
self.permissions: Permissions = Permissions(int(data["permissions"]))

discord/types/appinfo.py

+5
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ class PartialAppInfo(BaseAppInfo):
5959
rpc_origins: NotRequired[list[str]]
6060
cover_image: NotRequired[str]
6161
flags: NotRequired[int]
62+
63+
64+
class AppInstallParams(TypedDict):
65+
scopes: list[str]
66+
permissions: str

docs/api/application_info.rst

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ Application Info
1313
.. autoclass:: PartialAppInfo()
1414
:members:
1515

16+
.. attributetable:: AppInstallParams
17+
18+
.. autoclass:: AppInstallParams()
19+
:members:
20+
1621
.. attributetable:: Team
1722

1823
.. autoclass:: Team()

0 commit comments

Comments
 (0)