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_)