Browse Source

Add missing application fields

pull/10109/head
dolfies 2 years ago
parent
commit
cc0a0e82c1
  1. 45
      discord/application.py
  2. 25
      discord/types/application.py

45
discord/application.py

@ -409,7 +409,7 @@ class ThirdPartySKU:
Attributes Attributes
----------- -----------
application: :class:`PartialApplication` application: Union[:class:`PartialApplication`, :class:`IntegrationApplication`]
The application that the SKU belongs to. The application that the SKU belongs to.
distributor: :class:`Distributor` distributor: :class:`Distributor`
The distributor of the SKU. The distributor of the SKU.
@ -421,7 +421,7 @@ class ThirdPartySKU:
__slots__ = ('application', 'distributor', 'id', 'sku_id') __slots__ = ('application', 'distributor', 'id', 'sku_id')
def __init__(self, *, data: ThirdPartySKUPayload, application: PartialApplication): def __init__(self, *, data: ThirdPartySKUPayload, application: Union[PartialApplication, IntegrationApplication]):
self.application = application self.application = application
self.distributor: Distributor = try_enum(Distributor, data['distributor']) self.distributor: Distributor = try_enum(Distributor, data['distributor'])
self.id: Optional[str] = data.get('id') self.id: Optional[str] = data.get('id')
@ -1870,6 +1870,7 @@ class PartialApplication(Hashable):
self._icon: Optional[str] = data.get('icon') self._icon: Optional[str] = data.get('icon')
self._cover_image: Optional[str] = data.get('cover_image') self._cover_image: Optional[str] = data.get('cover_image')
self._splash: Optional[str] = data.get('splash')
self.terms_of_service_url: Optional[str] = data.get('terms_of_service_url') self.terms_of_service_url: Optional[str] = data.get('terms_of_service_url')
self.privacy_policy_url: Optional[str] = data.get('privacy_policy_url') self.privacy_policy_url: Optional[str] = data.get('privacy_policy_url')
@ -1957,6 +1958,16 @@ class PartialApplication(Hashable):
return None return None
return Asset._from_icon(self._state, self.id, self._cover_image, path='app') return Asset._from_icon(self._state, self.id, self._cover_image, path='app')
@property
def splash(self) -> Optional[Asset]:
"""Optional[:class:`Asset`]: Retrieves the application's splash, if any.
.. versionadded:: 2.1
"""
if self._splash is None:
return None
return Asset._from_icon(self._state, self.id, self._splash, path='app')
@property @property
def flags(self) -> ApplicationFlags: def flags(self) -> ApplicationFlags:
""":class:`ApplicationFlags`: The flags of this application.""" """:class:`ApplicationFlags`: The flags of this application."""
@ -3582,8 +3593,12 @@ class IntegrationApplication(Hashable):
The application name. The application name.
bot: Optional[:class:`User`] bot: Optional[:class:`User`]
The bot attached to the application, if any. The bot attached to the application, if any.
description: Optional[:class:`str`] description: :class:`str`
The application description. The application description.
deeplink_uri: Optional[:class:`str`]
The application's deeplink URI, if set.
.. versionadded:: 2.1
type: Optional[:class:`ApplicationType`] type: Optional[:class:`ApplicationType`]
The type of application. The type of application.
primary_sku_id: Optional[:class:`int`] primary_sku_id: Optional[:class:`int`]
@ -3592,6 +3607,10 @@ class IntegrationApplication(Hashable):
role_connections_verification_url: Optional[:class:`str`] role_connections_verification_url: Optional[:class:`str`]
The application's connection verification URL which will render the application as The application's connection verification URL which will render the application as
a verification method in the guild's role verification configuration. a verification method in the guild's role verification configuration.
third_party_skus: List[:class:`ThirdPartySKU`]
A list of third party platforms the SKU is available at.
.. versionadded:: 2.1
""" """
__slots__ = ( __slots__ = (
@ -3600,11 +3619,14 @@ class IntegrationApplication(Hashable):
'name', 'name',
'bot', 'bot',
'description', 'description',
'deeplink_uri',
'type', 'type',
'primary_sku_id', 'primary_sku_id',
'role_connections_verification_url', 'role_connections_verification_url',
'third_party_skus',
'_icon', '_icon',
'_cover_image', '_cover_image',
'_splash',
) )
def __init__(self, *, state: ConnectionState, data: BaseApplicationPayload): def __init__(self, *, state: ConnectionState, data: BaseApplicationPayload):
@ -3618,13 +3640,18 @@ class IntegrationApplication(Hashable):
self.id: int = int(data['id']) self.id: int = int(data['id'])
self.name: str = data['name'] self.name: str = data['name']
self.description: str = data.get('description') or '' self.description: str = data.get('description') or ''
self.deeplink_uri: Optional[str] = data.get('deeplink_uri')
self.type: Optional[ApplicationType] = try_enum(ApplicationType, data['type']) if 'type' in data else None self.type: Optional[ApplicationType] = try_enum(ApplicationType, data['type']) if 'type' in data else None
self._icon: Optional[str] = data.get('icon') self._icon: Optional[str] = data.get('icon')
self._cover_image: Optional[str] = data.get('cover_image') self._cover_image: Optional[str] = data.get('cover_image')
self.bot: Optional[User] = self._state.create_user(data['bot']) if 'bot' in data else None # type: ignore self._splash: Optional[str] = data.get('splash')
self.bot: Optional[User] = self._state.create_user(data['bot']) if 'bot' in data else None
self.primary_sku_id: Optional[int] = utils._get_as_snowflake(data, 'primary_sku_id') self.primary_sku_id: Optional[int] = utils._get_as_snowflake(data, 'primary_sku_id')
self.role_connections_verification_url: Optional[str] = data.get('role_connections_verification_url') self.role_connections_verification_url: Optional[str] = data.get('role_connections_verification_url')
self.third_party_skus: List[ThirdPartySKU] = [
ThirdPartySKU(data=t, application=self) for t in data.get('third_party_skus', [])
]
def __repr__(self) -> str: def __repr__(self) -> str:
return f'<IntegrationApplication id={self.id} name={self.name!r}>' return f'<IntegrationApplication id={self.id} name={self.name!r}>'
@ -3651,6 +3678,16 @@ class IntegrationApplication(Hashable):
return None return None
return Asset._from_icon(self._state, self.id, self._cover_image, path='app') return Asset._from_icon(self._state, self.id, self._cover_image, path='app')
@property
def splash(self) -> Optional[Asset]:
"""Optional[:class:`Asset`]: Retrieves the application's splash, if any.
.. versionadded:: 2.1
"""
if self._splash is None:
return None
return Asset._from_icon(self._state, self.id, self._splash, path='app')
@property @property
def primary_sku_url(self) -> Optional[str]: def primary_sku_url(self) -> Optional[str]:
""":class:`str`: The URL to the primary SKU of the application, if any.""" """:class:`str`: The URL to the primary SKU of the application, if any."""

25
discord/types/application.py

@ -27,6 +27,7 @@ from __future__ import annotations
from typing import Dict, List, Literal, Optional, TypedDict, Union from typing import Dict, List, Literal, Optional, TypedDict, Union
from typing_extensions import NotRequired from typing_extensions import NotRequired
from .command import ApplicationCommand
from .guild import PartialGuild from .guild import PartialGuild
from .snowflake import Snowflake from .snowflake import Snowflake
from .team import Team from .team import Team
@ -46,27 +47,29 @@ class Secret(TypedDict):
secret: str secret: str
class BaseApplication(TypedDict): class _BaseApplication(TypedDict):
id: Snowflake id: Snowflake
name: str name: str
description: str description: str
icon: Optional[str] icon: Optional[str]
cover_image: NotRequired[Optional[str]] cover_image: NotRequired[str]
splash: NotRequired[str]
type: Optional[int] type: Optional[int]
primary_sku_id: NotRequired[Snowflake] primary_sku_id: NotRequired[Snowflake]
summary: NotRequired[Literal['']] summary: NotRequired[Literal['']]
deeplink_uri: NotRequired[str]
third_party_skus: NotRequired[List[ThirdPartySKU]]
class RoleConnectionApplication(BaseApplication): class BaseApplication(_BaseApplication):
bot: NotRequired[PartialUser] bot: NotRequired[PartialUser]
class IntegrationApplication(BaseApplication): class IntegrationApplication(BaseApplication):
bot: NotRequired[APIUser]
role_connections_verification_url: NotRequired[Optional[str]] role_connections_verification_url: NotRequired[Optional[str]]
class PartialApplication(BaseApplication): class PartialApplication(_BaseApplication):
owner: NotRequired[APIUser] # Not actually ever present in partial app owner: NotRequired[APIUser] # Not actually ever present in partial app
team: NotRequired[Team] team: NotRequired[Team]
verify_key: str verify_key: str
@ -93,18 +96,17 @@ class PartialApplication(BaseApplication):
embedded_activity_config: NotRequired[EmbeddedActivityConfig] embedded_activity_config: NotRequired[EmbeddedActivityConfig]
guild: NotRequired[PartialGuild] guild: NotRequired[PartialGuild]
install_params: NotRequired[ApplicationInstallParams] install_params: NotRequired[ApplicationInstallParams]
deeplink_uri: NotRequired[str]
store_listing_sku_id: NotRequired[Snowflake] store_listing_sku_id: NotRequired[Snowflake]
executables: NotRequired[List[ApplicationExecutable]] executables: NotRequired[List[ApplicationExecutable]]
third_party_skus: NotRequired[List[ThirdPartySKU]]
class ApplicationDiscoverability(TypedDict): class ApplicationDiscoverability(TypedDict):
discoverability_state: int discoverability_state: int
discovery_eligibility_flags: int discovery_eligibility_flags: int
bad_commands: List[ApplicationCommand]
class Application(PartialApplication, IntegrationApplication, ApplicationDiscoverability): class Application(PartialApplication, IntegrationApplication):
redirect_uris: List[str] redirect_uris: List[str]
interactions_endpoint_url: Optional[str] interactions_endpoint_url: Optional[str]
interactions_version: Literal[1, 2] interactions_version: Literal[1, 2]
@ -113,7 +115,10 @@ class Application(PartialApplication, IntegrationApplication, ApplicationDiscove
store_application_state: int store_application_state: int
rpc_application_state: int rpc_application_state: int
creator_monetization_state: int creator_monetization_state: int
role_connections_verification_url: NotRequired[Optional[str]] discoverability_state: int
discovery_eligibility_flags: int
monetization_state: int
monetization_eligibility_flags: int
approximate_guild_count: NotRequired[int] approximate_guild_count: NotRequired[int]
@ -304,7 +309,7 @@ class PartialRoleConnection(TypedDict):
class RoleConnection(PartialRoleConnection): class RoleConnection(PartialRoleConnection):
application: RoleConnectionApplication application: BaseApplication
application_metadata: List[RoleConnectionMetadata] application_metadata: List[RoleConnectionMetadata]

Loading…
Cancel
Save