Add application command permissions to audit log

This commit is contained in:
z03h
2022-05-01 15:59:57 -07:00
committed by GitHub
parent 5f0cf58b2e
commit 619bc50e5d
10 changed files with 374 additions and 113 deletions

View File

@ -36,6 +36,7 @@ __all__ = (
'Integration',
'StreamIntegration',
'BotIntegration',
'PartialIntegration',
)
if TYPE_CHECKING:
@ -49,6 +50,7 @@ if TYPE_CHECKING:
BotIntegration as BotIntegrationPayload,
IntegrationType,
IntegrationApplication as IntegrationApplicationPayload,
PartialIntegration as PartialIntegrationPayload,
)
@ -115,7 +117,7 @@ class Integration:
self._from_data(data)
def __repr__(self) -> str:
return f"<{self.__class__.__name__} id={self.id} name={self.name!r}>"
return f'<{self.__class__.__name__} id={self.id} name={self.name!r}>'
def _from_data(self, data: IntegrationPayload) -> None:
self.id: int = int(data['id'])
@ -362,6 +364,53 @@ class BotIntegration(Integration):
self.application: IntegrationApplication = IntegrationApplication(data=data['application'], state=self._state)
class PartialIntegration:
"""Represents a partial guild integration.
.. versionadded:: 2.0
Attributes
-----------
id: :class:`int`
The integration ID.
name: :class:`str`
The integration name.
guild: :class:`Guild`
The guild of the integration.
type: :class:`str`
The integration type (i.e. Twitch).
account: :class:`IntegrationAccount`
The account linked to this integration.
application_id: Optional[:class:`int`]
The id of the application this integration belongs to.
"""
__slots__ = (
'guild',
'_state',
'id',
'type',
'name',
'account',
'application_id',
)
def __init__(self, *, data: PartialIntegrationPayload, guild: Guild):
self.guild: Guild = guild
self._state: ConnectionState = guild._state
self._from_data(data)
def __repr__(self) -> str:
return f'<{self.__class__.__name__} id={self.id} name={self.name!r}>'
def _from_data(self, data: PartialIntegrationPayload) -> None:
self.id: int = int(data['id'])
self.type: IntegrationType = data['type']
self.name: str = data['name']
self.account: IntegrationAccount = IntegrationAccount(data['account'])
self.application_id: Optional[int] = _get_as_snowflake(data, 'application_id')
def _integration_factory(value: str) -> Tuple[Type[Integration], str]:
if value == 'discord':
return BotIntegration, value