Browse Source

Add missing interaction application fields

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

45
discord/application.py

@ -87,6 +87,7 @@ if TYPE_CHECKING:
EmbeddedActivityPlatform as EmbeddedActivityPlatformValues, EmbeddedActivityPlatform as EmbeddedActivityPlatformValues,
EmbeddedActivityPlatformConfig as EmbeddedActivityPlatformConfigPayload, EmbeddedActivityPlatformConfig as EmbeddedActivityPlatformConfigPayload,
GlobalActivityStatistics as GlobalActivityStatisticsPayload, GlobalActivityStatistics as GlobalActivityStatisticsPayload,
InteractionsVersion,
Manifest as ManifestPayload, Manifest as ManifestPayload,
ManifestLabel as ManifestLabelPayload, ManifestLabel as ManifestLabelPayload,
PartialApplication as PartialApplicationPayload, PartialApplication as PartialApplicationPayload,
@ -1956,7 +1957,10 @@ class PartialApplication(Hashable):
existing = getattr(self, 'team', None) existing = getattr(self, 'team', None)
team = data.get('team') team = data.get('team')
self.team = Team(state=state, data=team) if team else existing if existing and team:
existing._update(team)
else:
self.team = Team(state=state, data=team) if team else existing
if self.team and not self.owner: if self.team and not self.owner:
# We can create a team user from the team data # We can create a team user from the team data
@ -2300,6 +2304,15 @@ class Application(PartialApplication):
.. versionadded:: 2.1 .. versionadded:: 2.1
interactions_endpoint_url: Optional[:class:`str`] interactions_endpoint_url: Optional[:class:`str`]
The URL interactions will be sent to, if set. The URL interactions will be sent to, if set.
interactions_version: :class:`int`
The interactions version to use. Different versions have different payloads and supported features.
.. versionadded:: 2.1
interactions_event_types: List[:class:`str`]
The interaction event types to subscribe to.
Requires a valid :attr:`interactions_endpoint_url` and :attr:`interactions_version` 2 or higher.
.. versionadded:: 2.1
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.
@ -2313,8 +2326,8 @@ class Application(PartialApplication):
The approval state of the RPC usage application. The approval state of the RPC usage application.
discoverability_state: :class:`ApplicationDiscoverabilityState` discoverability_state: :class:`ApplicationDiscoverabilityState`
The state of the application in the application directory. The state of the application in the application directory.
approximate_guild_count: Optional[:class:`int`] approximate_guild_count: :class:`int`
The approximate number of guilds this application is in, if available. The approximate number of guilds this application is in.
.. versionadded:: 2.1 .. versionadded:: 2.1
""" """
@ -2323,6 +2336,8 @@ class Application(PartialApplication):
'owner', 'owner',
'redirect_uris', 'redirect_uris',
'interactions_endpoint_url', 'interactions_endpoint_url',
'interactions_version',
'interactions_event_types',
'role_connections_verification_url', 'role_connections_verification_url',
'bot', 'bot',
'disabled', 'disabled',
@ -2349,6 +2364,8 @@ class Application(PartialApplication):
self.quarantined: bool = data.get('bot_quarantined', False) self.quarantined: bool = data.get('bot_quarantined', False)
self.redirect_uris: List[str] = data.get('redirect_uris', []) self.redirect_uris: List[str] = data.get('redirect_uris', [])
self.interactions_endpoint_url: Optional[str] = data.get('interactions_endpoint_url') self.interactions_endpoint_url: Optional[str] = data.get('interactions_endpoint_url')
self.interactions_version: InteractionsVersion = data.get('interactions_version', 1)
self.interactions_event_types: List[str] = data.get('interactions_event_types', [])
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.verification_state = try_enum(ApplicationVerificationState, data['verification_state']) self.verification_state = try_enum(ApplicationVerificationState, data['verification_state'])
@ -2356,7 +2373,7 @@ class Application(PartialApplication):
self.rpc_application_state = try_enum(RPCApplicationState, data.get('rpc_application_state', 0)) self.rpc_application_state = try_enum(RPCApplicationState, data.get('rpc_application_state', 0))
self.discoverability_state = try_enum(ApplicationDiscoverabilityState, data.get('discoverability_state', 1)) self.discoverability_state = try_enum(ApplicationDiscoverabilityState, data.get('discoverability_state', 1))
self._discovery_eligibility_flags = data.get('discovery_eligibility_flags', 0) self._discovery_eligibility_flags = data.get('discovery_eligibility_flags', 0)
self.approximate_guild_count: Optional[int] = data.get('approximate_guild_count') self.approximate_guild_count: int = data.get('approximate_guild_count', 0)
state = self._state state = self._state
@ -2401,6 +2418,8 @@ class Application(PartialApplication):
privacy_policy_url: Optional[str] = MISSING, privacy_policy_url: Optional[str] = MISSING,
deeplink_uri: Optional[str] = MISSING, deeplink_uri: Optional[str] = MISSING,
interactions_endpoint_url: Optional[str] = MISSING, interactions_endpoint_url: Optional[str] = MISSING,
interactions_version: InteractionsVersion = MISSING,
interactions_event_types: Sequence[str] = MISSING,
role_connections_verification_url: Optional[str] = MISSING, role_connections_verification_url: Optional[str] = MISSING,
redirect_uris: Sequence[str] = MISSING, redirect_uris: Sequence[str] = MISSING,
rpc_origins: Sequence[str] = MISSING, rpc_origins: Sequence[str] = MISSING,
@ -2444,6 +2463,15 @@ class Application(PartialApplication):
.. versionadded:: 2.1 .. versionadded:: 2.1
interactions_endpoint_url: Optional[:class:`str`] interactions_endpoint_url: Optional[:class:`str`]
The URL interactions will be sent to, if set. The URL interactions will be sent to, if set.
interactions_version: :class:`int`
The interactions version to use. Different versions have different payloads and supported features.
.. versionadded:: 2.1
interactions_event_types: List[:class:`str`]
The interaction event types to subscribe to.
Requires a valid :attr:`interactions_endpoint_url` and :attr:`interactions_version` 2 or higher.
.. versionadded:: 2.1
role_connections_verification_url: Optional[:class:`str`] role_connections_verification_url: Optional[:class:`str`]
The connection verification URL for the application. The connection verification URL for the application.
@ -2508,12 +2536,16 @@ class Application(PartialApplication):
payload['deeplink_uri'] = deeplink_uri or '' payload['deeplink_uri'] = deeplink_uri or ''
if interactions_endpoint_url is not MISSING: if interactions_endpoint_url is not MISSING:
payload['interactions_endpoint_url'] = interactions_endpoint_url or '' payload['interactions_endpoint_url'] = interactions_endpoint_url or ''
if interactions_version is not MISSING:
payload['interactions_version'] = interactions_version
if interactions_event_types is not MISSING:
payload['interactions_event_types'] = interactions_event_types or []
if role_connections_verification_url is not MISSING: if role_connections_verification_url is not MISSING:
payload['role_connections_verification_url'] = role_connections_verification_url or '' payload['role_connections_verification_url'] = role_connections_verification_url or ''
if redirect_uris is not MISSING: if redirect_uris is not MISSING:
payload['redirect_uris'] = redirect_uris payload['redirect_uris'] = redirect_uris or []
if rpc_origins is not MISSING: if rpc_origins is not MISSING:
payload['rpc_origins'] = rpc_origins payload['rpc_origins'] = rpc_origins or []
if public is not MISSING: if public is not MISSING:
if self.bot: if self.bot:
payload['bot_public'] = public payload['bot_public'] = public
@ -2549,7 +2581,6 @@ class Application(PartialApplication):
await self._state.http.transfer_application(self.id, team.id) await self._state.http.transfer_application(self.id, team.id)
data = await self._state.http.edit_application(self.id, payload) data = await self._state.http.edit_application(self.id, payload)
self._update(data) self._update(data)
async def fetch_bot(self) -> ApplicationBot: async def fetch_bot(self) -> ApplicationBot:

5
discord/types/application.py

@ -106,12 +106,15 @@ class ApplicationDiscoverability(TypedDict):
bad_commands: List[ApplicationCommand] bad_commands: List[ApplicationCommand]
InteractionsVersion = Literal[1, 2]
class Application(PartialApplication, IntegrationApplication): class Application(PartialApplication, IntegrationApplication):
bot_disabled: NotRequired[bool] bot_disabled: NotRequired[bool]
bot_quarantined: NotRequired[bool] bot_quarantined: NotRequired[bool]
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: InteractionsVersion
interactions_event_types: List[str] interactions_event_types: List[str]
verification_state: int verification_state: int
store_application_state: int store_application_state: int

Loading…
Cancel
Save