Browse Source

Set allow_list for fetched AutoModRules

pull/8301/head
z03h 3 years ago
committed by GitHub
parent
commit
ca1365d7ef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      discord/audit_logs.py
  2. 2
      discord/automod.py

8
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]:

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

Loading…
Cancel
Save