From 0cd24b73f729d6aa07fc558b148c2bddfe637a0d Mon Sep 17 00:00:00 2001 From: z03h <7235242+z03h@users.noreply.github.com> Date: Sat, 14 Jan 2023 04:59:42 -0800 Subject: [PATCH] Fix trigger missing regex_filter and allow_list in audit log --- discord/audit_logs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 0c797a0c8..29b472144 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -239,10 +239,6 @@ def _transform_automod_trigger_metadata( except Exception: pass - # If cannot get trigger type from the rule and data is empty, then cannot determine trigger type - if not data: - return None - # Try to infer trigger type from available keys in data if 'presets' in data: return AutoModTrigger( @@ -251,9 +247,16 @@ def _transform_automod_trigger_metadata( allow_list=data.get('allow_list'), ) elif 'keyword_filter' in data: - return AutoModTrigger(type=enums.AutoModRuleTriggerType.keyword, keyword_filter=data['keyword_filter']) # type: ignore + return AutoModTrigger( + type=enums.AutoModRuleTriggerType.keyword, + keyword_filter=data['keyword_filter'], # type: ignore + allow_list=data.get('allow_list'), + regex_patterns=data.get('regex_patterns'), + ) elif 'mention_total_limit' in data: return AutoModTrigger(type=enums.AutoModRuleTriggerType.mention_spam, mention_limit=data['mention_total_limit']) # type: ignore + else: + return AutoModTrigger(type=enums.AutoModRuleTriggerType.spam) def _transform_automod_actions(entry: AuditLogEntry, data: List[AutoModerationAction]) -> List[AutoModRuleAction]: