mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-23 11:26:51 +00:00
Convert Webhook targets in AuditlogEntry
This commit is contained in:
parent
fdf03d4bca
commit
2247ffd9b5
@ -74,6 +74,7 @@ if TYPE_CHECKING:
|
|||||||
from .types.automod import AutoModerationTriggerMetadata, AutoModerationAction
|
from .types.automod import AutoModerationTriggerMetadata, AutoModerationAction
|
||||||
from .user import User
|
from .user import User
|
||||||
from .app_commands import AppCommand
|
from .app_commands import AppCommand
|
||||||
|
from .webhook import Webhook
|
||||||
|
|
||||||
TargetType = Union[
|
TargetType = Union[
|
||||||
Guild,
|
Guild,
|
||||||
@ -89,6 +90,9 @@ if TYPE_CHECKING:
|
|||||||
Object,
|
Object,
|
||||||
PartialIntegration,
|
PartialIntegration,
|
||||||
AutoModRule,
|
AutoModRule,
|
||||||
|
ScheduledEvent,
|
||||||
|
Webhook,
|
||||||
|
AppCommand,
|
||||||
None,
|
None,
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -580,6 +584,7 @@ class AuditLogEntry(Hashable):
|
|||||||
integrations: Mapping[int, PartialIntegration],
|
integrations: Mapping[int, PartialIntegration],
|
||||||
app_commands: Mapping[int, AppCommand],
|
app_commands: Mapping[int, AppCommand],
|
||||||
automod_rules: Mapping[int, AutoModRule],
|
automod_rules: Mapping[int, AutoModRule],
|
||||||
|
webhooks: Mapping[int, Webhook],
|
||||||
data: AuditLogEntryPayload,
|
data: AuditLogEntryPayload,
|
||||||
guild: Guild,
|
guild: Guild,
|
||||||
):
|
):
|
||||||
@ -589,6 +594,7 @@ class AuditLogEntry(Hashable):
|
|||||||
self._integrations: Mapping[int, PartialIntegration] = integrations
|
self._integrations: Mapping[int, PartialIntegration] = integrations
|
||||||
self._app_commands: Mapping[int, AppCommand] = app_commands
|
self._app_commands: Mapping[int, AppCommand] = app_commands
|
||||||
self._automod_rules: Mapping[int, AutoModRule] = automod_rules
|
self._automod_rules: Mapping[int, AutoModRule] = automod_rules
|
||||||
|
self._webhooks: Mapping[int, Webhook] = webhooks
|
||||||
self._from_data(data)
|
self._from_data(data)
|
||||||
|
|
||||||
def _from_data(self, data: AuditLogEntryPayload) -> None:
|
def _from_data(self, data: AuditLogEntryPayload) -> None:
|
||||||
@ -845,3 +851,9 @@ class AuditLogEntry(Hashable):
|
|||||||
|
|
||||||
def _convert_target_auto_moderation(self, target_id: int) -> Union[AutoModRule, Object]:
|
def _convert_target_auto_moderation(self, target_id: int) -> Union[AutoModRule, Object]:
|
||||||
return self._automod_rules.get(target_id) or Object(target_id, type=AutoModRule)
|
return self._automod_rules.get(target_id) or Object(target_id, type=AutoModRule)
|
||||||
|
|
||||||
|
def _convert_target_webhook(self, target_id: int) -> Union[Webhook, Object]:
|
||||||
|
# circular import
|
||||||
|
from .webhook import Webhook
|
||||||
|
|
||||||
|
return self._webhooks.get(target_id) or Object(target_id, type=Webhook)
|
||||||
|
@ -3860,6 +3860,7 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
# avoid circular import
|
# avoid circular import
|
||||||
from .app_commands import AppCommand
|
from .app_commands import AppCommand
|
||||||
|
from .webhook import Webhook
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
retrieve = 100 if limit is None else min(limit, 100)
|
retrieve = 100 if limit is None else min(limit, 100)
|
||||||
@ -3886,6 +3887,9 @@ class Guild(Hashable):
|
|||||||
)
|
)
|
||||||
automod_rule_map = {rule.id: rule for rule in automod_rules}
|
automod_rule_map = {rule.id: rule for rule in automod_rules}
|
||||||
|
|
||||||
|
webhooks = (Webhook.from_state(data=raw_webhook, state=self._state) for raw_webhook in data.get('webhooks', []))
|
||||||
|
webhook_map = {webhook.id: webhook for webhook in webhooks}
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
for count, raw_entry in enumerate(raw_entries, 1):
|
for count, raw_entry in enumerate(raw_entries, 1):
|
||||||
@ -3899,6 +3903,7 @@ class Guild(Hashable):
|
|||||||
integrations=integration_map,
|
integrations=integration_map,
|
||||||
app_commands=app_command_map,
|
app_commands=app_command_map,
|
||||||
automod_rules=automod_rule_map,
|
automod_rules=automod_rule_map,
|
||||||
|
webhooks=webhook_map,
|
||||||
guild=self,
|
guild=self,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1108,6 +1108,7 @@ class ConnectionState(Generic[ClientT]):
|
|||||||
integrations={},
|
integrations={},
|
||||||
app_commands={},
|
app_commands={},
|
||||||
automod_rules={},
|
automod_rules={},
|
||||||
|
webhooks={},
|
||||||
data=data,
|
data=data,
|
||||||
guild=guild,
|
guild=guild,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user