mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-02 00:00:02 +00:00
Set allow_list for fetched AutoModRules
This commit is contained in:
parent
99d2ecac54
commit
ca1365d7ef
@ -188,15 +188,15 @@ def _guild_hash_transformer(path: str) -> Callable[[AuditLogEntry, Optional[str]
|
|||||||
def _transform_automod_trigger_metadata(
|
def _transform_automod_trigger_metadata(
|
||||||
entry: AuditLogEntry, data: AutoModerationTriggerMetadata
|
entry: AuditLogEntry, data: AutoModerationTriggerMetadata
|
||||||
) -> Optional[AutoModTrigger]:
|
) -> Optional[AutoModTrigger]:
|
||||||
if data is None:
|
if not data:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# discord doesn't provide the type of the trigger
|
# discord doesn't provide the type of the trigger
|
||||||
# have to infer from the data and present keys
|
# have to infer from the data and present keys
|
||||||
if 'presets' in data:
|
if 'presets' in data:
|
||||||
return AutoModTrigger(presets=AutoModPresets._from_value(data['presets'])) # type: ignore
|
return AutoModTrigger(presets=AutoModPresets._from_value(data['presets']), allow_list=data.get('allow_list')) # type: ignore
|
||||||
|
elif 'keyword_filter' in data:
|
||||||
return AutoModTrigger(**data)
|
return AutoModTrigger(keyword_filter=data['keyword_filter']) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def _transform_automod_actions(entry: AuditLogEntry, data: List[AutoModerationAction]) -> List[AutoModRuleAction]:
|
def _transform_automod_actions(entry: AuditLogEntry, data: List[AutoModerationAction]) -> List[AutoModRuleAction]:
|
||||||
|
@ -166,7 +166,7 @@ class AutoModTrigger:
|
|||||||
if type_ is AutoModRuleTriggerType.keyword:
|
if type_ is AutoModRuleTriggerType.keyword:
|
||||||
return cls(keyword_filter=data['keyword_filter']) # type: ignore # unable to typeguard due to outer payload
|
return cls(keyword_filter=data['keyword_filter']) # type: ignore # unable to typeguard due to outer payload
|
||||||
elif type_ is AutoModRuleTriggerType.keyword_preset:
|
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:
|
else:
|
||||||
return cls(type=type_)
|
return cls(type=type_)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user