From ca1365d7ef10d302e8730f583e2d1ac568cd7b65 Mon Sep 17 00:00:00 2001 From: z03h <7235242+z03h@users.noreply.github.com> Date: Wed, 3 Aug 2022 17:23:58 -0700 Subject: [PATCH] Set allow_list for fetched AutoModRules --- discord/audit_logs.py | 8 ++++---- discord/automod.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index e64534b82..902e9d7d5 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -188,15 +188,15 @@ def _guild_hash_transformer(path: str) -> Callable[[AuditLogEntry, Optional[str] def _transform_automod_trigger_metadata( entry: AuditLogEntry, data: AutoModerationTriggerMetadata ) -> Optional[AutoModTrigger]: - if data is None: + if not data: return None # discord doesn't provide the type of the trigger # have to infer from the data and present keys if 'presets' in data: - return AutoModTrigger(presets=AutoModPresets._from_value(data['presets'])) # type: ignore - - return AutoModTrigger(**data) + return AutoModTrigger(presets=AutoModPresets._from_value(data['presets']), allow_list=data.get('allow_list')) # type: ignore + elif 'keyword_filter' in data: + return AutoModTrigger(keyword_filter=data['keyword_filter']) # type: ignore def _transform_automod_actions(entry: AuditLogEntry, data: List[AutoModerationAction]) -> List[AutoModRuleAction]: diff --git a/discord/automod.py b/discord/automod.py index d39288e35..3f3d5f3d6 100644 --- a/discord/automod.py +++ b/discord/automod.py @@ -166,7 +166,7 @@ class AutoModTrigger: if type_ is AutoModRuleTriggerType.keyword: return cls(keyword_filter=data['keyword_filter']) # type: ignore # unable to typeguard due to outer payload elif type_ is AutoModRuleTriggerType.keyword_preset: - return cls(presets=AutoModPresets._from_value(data['presets'])) # type: ignore # unable to typeguard due to outer payload + return cls(presets=AutoModPresets._from_value(data['presets']), allow_list=data.get('allow_list')) # type: ignore # unable to typeguard due to outer payload else: return cls(type=type_)