From 098b5eed487652d21177ba5adfb6843e8bd5d638 Mon Sep 17 00:00:00 2001 From: Sacul Date: Wed, 23 Jul 2025 17:01:07 +0800 Subject: [PATCH 01/15] Add support for automod_quarantined_guild_tag member flag --- discord/flags.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/discord/flags.py b/discord/flags.py index 59a4909b8557..1e55f90b328d 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -2094,6 +2094,15 @@ def automod_quarantined_username(self): """ return 1 << 7 + @flag_value + def automod_quarantined_guild_tag(self): + """:class:`bool`: Returns ``True`` if the member's guild tag has been + blocked by AutoMod. + + .. versionadded:: 2.6 + """ + return 1 << 10 + @flag_value def dm_settings_upsell_acknowledged(self): """:class:`bool`: Returns ``True`` if the member has dismissed the DM settings upsell. @@ -2102,7 +2111,6 @@ def dm_settings_upsell_acknowledged(self): """ return 1 << 9 - @fill_with_flags() class AttachmentFlags(BaseFlags): r"""Wraps up the Discord Attachment flags From 2f586eee56787ab8cc4164d9206462626d3cf638 Mon Sep 17 00:00:00 2001 From: Sacul Date: Wed, 23 Jul 2025 17:15:48 +0800 Subject: [PATCH 02/15] Fixed the linting --- discord/flags.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/flags.py b/discord/flags.py index 1e55f90b328d..0709cc973de1 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -2111,6 +2111,7 @@ def dm_settings_upsell_acknowledged(self): """ return 1 << 9 + @fill_with_flags() class AttachmentFlags(BaseFlags): r"""Wraps up the Discord Attachment flags From 5bb41b193a75d12b6bcd773a71e49b4accadbf13 Mon Sep 17 00:00:00 2001 From: Sacul Date: Wed, 23 Jul 2025 18:06:34 +0800 Subject: [PATCH 03/15] Update documentation for the automod_quarantine_member attribute in AuditLogAction --- docs/api.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/api.rst b/docs/api.rst index 781a47b24a36..91d557410e83 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -3055,6 +3055,23 @@ of :class:`enum.Enum`. .. versionadded:: 2.1 + .. attribute:: automod_quarantine_member + + An automod rule quarantined a member. + + When this is the action, the type of :attr:`~AuditLogEntry.target` is + a :class:`Member` with the ID of the person who triggered the automod rule. + + When this is the action, the type of :attr:`~AuditLogEntry.extra` is + set to an unspecified proxy object with 2 attributes: + + - ``automod_rule_name``: The name of the automod rule that was triggered. + - ``automod_rule_trigger_type``: A :class:`AutoModRuleTriggerType` representation of the rule type that was triggered. + + When this is the action, :attr:`AuditLogEntry.changes` is empty. + + .. versionadded:: 2.6 + .. attribute:: creator_monetization_request_created A request to monetize the server was created. From f5f1183641bbf880371585b580d5f09ebe6fd54f Mon Sep 17 00:00:00 2001 From: Sacul Date: Wed, 23 Jul 2025 18:09:27 +0800 Subject: [PATCH 04/15] Update enums.py --- discord/enums.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/discord/enums.py b/discord/enums.py index acc78012014f..2625311ebdff 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -398,6 +398,7 @@ class AuditLogAction(Enum): automod_block_message = 143 automod_flag_message = 144 automod_timeout_member = 145 + automod_quarantine_member = 146 creator_monetization_request_created = 150 creator_monetization_terms_accepted = 151 # fmt: on @@ -460,6 +461,7 @@ def category(self) -> Optional[AuditLogActionCategory]: AuditLogAction.automod_block_message: None, AuditLogAction.automod_flag_message: None, AuditLogAction.automod_timeout_member: None, + AuditLogAction.automod_quarantine_member: None, AuditLogAction.creator_monetization_request_created: None, AuditLogAction.creator_monetization_terms_accepted: None, AuditLogAction.soundboard_sound_create: AuditLogActionCategory.create, From 36d6804269412f3697613eaeadbef680ed581a46 Mon Sep 17 00:00:00 2001 From: Sacul Date: Wed, 23 Jul 2025 18:10:58 +0800 Subject: [PATCH 05/15] Update audit_logs.py --- discord/audit_logs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 40166f5489cb..ffca4de1e8fa 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -744,6 +744,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: self.action is enums.AuditLogAction.automod_block_message or self.action is enums.AuditLogAction.automod_flag_message or self.action is enums.AuditLogAction.automod_timeout_member + or self.action is enums.AuditLogAction.automod_quarantine_member ): channel_id = utils._get_as_snowflake(extra, 'channel_id') channel = None From 996d4519dec69ba5950cc0dfa7461a3ba7a50356 Mon Sep 17 00:00:00 2001 From: Sacul Date: Wed, 23 Jul 2025 18:21:51 +0800 Subject: [PATCH 06/15] Update audit_log.py --- discord/types/audit_log.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/types/audit_log.py b/discord/types/audit_log.py index c9d3056959af..cc4ad8363a27 100644 --- a/discord/types/audit_log.py +++ b/discord/types/audit_log.py @@ -97,6 +97,7 @@ 143, 144, 145, + 146, 150, 151, ] From b68cc16e8bd01f57961bb32fd01d32ecab93772c Mon Sep 17 00:00:00 2001 From: Sacul Date: Thu, 24 Jul 2025 20:44:20 +0800 Subject: [PATCH 07/15] Update enums.py --- discord/enums.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/enums.py b/discord/enums.py index 2625311ebdff..5b81c6d6a3c0 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -508,7 +508,7 @@ def target_type(self) -> Optional[str]: return 'integration_or_app_command' elif 139 < v < 143: return 'auto_moderation' - elif v < 146: + elif v < 147: return 'user' elif v < 152: return 'creator_monetization' From 7bec5ba39ce41e1e9e146485686258536e52f8b2 Mon Sep 17 00:00:00 2001 From: Sacul Date: Fri, 25 Jul 2025 14:33:04 +0800 Subject: [PATCH 08/15] Changed to `user` to stay consistent with Api naming --- discord/enums.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord/enums.py b/discord/enums.py index 5b81c6d6a3c0..5ee07044c732 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -398,7 +398,7 @@ class AuditLogAction(Enum): automod_block_message = 143 automod_flag_message = 144 automod_timeout_member = 145 - automod_quarantine_member = 146 + automod_quarantine_user = 146 creator_monetization_request_created = 150 creator_monetization_terms_accepted = 151 # fmt: on @@ -461,7 +461,7 @@ def category(self) -> Optional[AuditLogActionCategory]: AuditLogAction.automod_block_message: None, AuditLogAction.automod_flag_message: None, AuditLogAction.automod_timeout_member: None, - AuditLogAction.automod_quarantine_member: None, + AuditLogAction.automod_quarantine_user: None, AuditLogAction.creator_monetization_request_created: None, AuditLogAction.creator_monetization_terms_accepted: None, AuditLogAction.soundboard_sound_create: AuditLogActionCategory.create, From d7af3d0b09ff8c2f4d62041c41defad8fb7e7548 Mon Sep 17 00:00:00 2001 From: Sacul Date: Fri, 25 Jul 2025 14:34:54 +0800 Subject: [PATCH 09/15] Update audit_logs.py --- discord/audit_logs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index ffca4de1e8fa..e5c16c1677a5 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -744,7 +744,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: self.action is enums.AuditLogAction.automod_block_message or self.action is enums.AuditLogAction.automod_flag_message or self.action is enums.AuditLogAction.automod_timeout_member - or self.action is enums.AuditLogAction.automod_quarantine_member + or self.action is enums.AuditLogAction.automod_quarantine_user ): channel_id = utils._get_as_snowflake(extra, 'channel_id') channel = None From 2ea10f4e73fa2c31f52416a5866f3dc7f0e9fc45 Mon Sep 17 00:00:00 2001 From: Sacul Date: Fri, 25 Jul 2025 14:38:24 +0800 Subject: [PATCH 10/15] Changed `automod_quarantine_member` to `automod_quarantine_user` --- docs/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 91d557410e83..00878f393347 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -3055,7 +3055,7 @@ of :class:`enum.Enum`. .. versionadded:: 2.1 - .. attribute:: automod_quarantine_member + .. attribute:: automod_quarantine_user An automod rule quarantined a member. From c98f3061ea2b32d714d251837141077fdbf032e9 Mon Sep 17 00:00:00 2001 From: Sacul Date: Sat, 26 Jul 2025 06:45:36 +0800 Subject: [PATCH 11/15] Creates a `_AuditLogProxyAutoModActionQuarantineUser` Class without a channel attribute as `automod_quarantine_user` does not have a channel attribute --- discord/audit_logs.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index e5c16c1677a5..2ba3835d6b19 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -614,6 +614,11 @@ class _AuditLogProxyAutoModAction(_AuditLogProxy): channel: Optional[Union[abc.GuildChannel, Thread]] +class _AuditLogProxyAutoModActionQuarantineUser(_AuditLogProxy): + automod_rule_name: str + automod_rule_trigger_type: str + + class _AuditLogProxyMemberKickOrMemberRoleUpdate(_AuditLogProxy): integration_type: Optional[str] @@ -704,6 +709,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: _AuditLogProxyStageInstanceAction, _AuditLogProxyMessageBulkDelete, _AuditLogProxyAutoModAction, + _AuditLogProxyAutoModActionQuarantineUser, _AuditLogProxyMemberKickOrMemberRoleUpdate, Member, User, None, PartialIntegration, Role, Object @@ -744,7 +750,6 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: self.action is enums.AuditLogAction.automod_block_message or self.action is enums.AuditLogAction.automod_flag_message or self.action is enums.AuditLogAction.automod_timeout_member - or self.action is enums.AuditLogAction.automod_quarantine_user ): channel_id = utils._get_as_snowflake(extra, 'channel_id') channel = None @@ -760,7 +765,13 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: ), channel=channel, ) - + elif self.action is enums.AuditLogAction.automod_quarantine_user: + self.extra = _AuditLogProxyAutoModActionQuarantineUser( + automod_rule_name=extra['auto_moderation_rule_name'], + automod_rule_trigger_type=enums.try_enum( + enums.AutoModRuleTriggerType, extra['auto_moderation_rule_trigger_type'] + ) + ) elif self.action.name.startswith('overwrite_'): # the overwrite_ actions have a dict with some information instance_id = int(extra['id']) From dcec4ae8ce5de88fe8059e46c829998fb2e92de7 Mon Sep 17 00:00:00 2001 From: Sacul Date: Sat, 26 Jul 2025 06:52:22 +0800 Subject: [PATCH 12/15] Update audit_logs.py --- discord/audit_logs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 2ba3835d6b19..617ebaace601 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -765,6 +765,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: ), channel=channel, ) + elif self.action is enums.AuditLogAction.automod_quarantine_user: self.extra = _AuditLogProxyAutoModActionQuarantineUser( automod_rule_name=extra['auto_moderation_rule_name'], From a5d4d50eadbb4f99b2af95aa2c7264f4afefda3b Mon Sep 17 00:00:00 2001 From: Sacul Date: Sat, 26 Jul 2025 07:15:46 +0800 Subject: [PATCH 13/15] Update audit_logs.py --- discord/audit_logs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 617ebaace601..1c958f5bd8b0 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -765,7 +765,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: ), channel=channel, ) - + elif self.action is enums.AuditLogAction.automod_quarantine_user: self.extra = _AuditLogProxyAutoModActionQuarantineUser( automod_rule_name=extra['auto_moderation_rule_name'], From 30de14e05669f2e68c3440c359270efcc3872329 Mon Sep 17 00:00:00 2001 From: Sacul Date: Sat, 26 Jul 2025 07:26:18 +0800 Subject: [PATCH 14/15] Update audit_logs.py --- discord/audit_logs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 1c958f5bd8b0..80c8a557e44a 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -765,7 +765,6 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: ), channel=channel, ) - elif self.action is enums.AuditLogAction.automod_quarantine_user: self.extra = _AuditLogProxyAutoModActionQuarantineUser( automod_rule_name=extra['auto_moderation_rule_name'], @@ -773,6 +772,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: enums.AutoModRuleTriggerType, extra['auto_moderation_rule_trigger_type'] ) ) + elif self.action.name.startswith('overwrite_'): # the overwrite_ actions have a dict with some information instance_id = int(extra['id']) From 8168aa66aad4997ab5e32811fd26bddc6307a291 Mon Sep 17 00:00:00 2001 From: Sacul Date: Sat, 26 Jul 2025 07:37:21 +0800 Subject: [PATCH 15/15] Finally lol --- discord/audit_logs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 80c8a557e44a..2c0fd610fb87 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -770,7 +770,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None: automod_rule_name=extra['auto_moderation_rule_name'], automod_rule_trigger_type=enums.try_enum( enums.AutoModRuleTriggerType, extra['auto_moderation_rule_trigger_type'] - ) + ), ) elif self.action.name.startswith('overwrite_'):