From 32f5e3d081fbccfe6d3353530291a2a67298bd02 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Mon, 20 May 2024 20:43:58 -0400 Subject: [PATCH 1/5] feat(Message): implement new types --- disnake/enums.py | 4 ++++ disnake/message.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/disnake/enums.py b/disnake/enums.py index 2fd3390c52..87d7b57f1a 100644 --- a/disnake/enums.py +++ b/disnake/enums.py @@ -255,6 +255,10 @@ class MessageType(Enum): stage_speaker = 29 stage_topic = 31 guild_application_premium_subscription = 32 + guild_incident_alert_mode_enabled = 36 + guild_incident_alert_mode_disabled = 37 + guild_incident_report_raid = 38 + guild_incident_report_false_alarm = 39 class PartyType(Enum): diff --git a/disnake/message.py b/disnake/message.py index 08d03da025..575c9b1c2c 100644 --- a/disnake/message.py +++ b/disnake/message.py @@ -1524,6 +1524,17 @@ def system_content(self) -> Optional[str]: ) return f"{self.author.name} upgraded {application_name} to premium for this server! 🎉" + if self.type is MessageType.guild_incident_alert_mode_enabled: + enabled_until = utils.parse_time(self.content) + return f"{self.author.name} enabled security actions until {enabled_until.strftime('%d/%m/%Y, %H:%M')}." + + if self.type is MessageType.guild_incident_alert_mode_disabled: + return f"{self.author.name} disabled security actions." + + if self.type is MessageType.guild_incident_report_raid: + guild_name = self.guild.name if self.guild else None + return f"{self.author.name} reported a raid in {guild_name}" + # in the event of an unknown or unsupported message type, we return nothing return None From 486baab5a94e0ba98e87d0e61f3937f964c9b620 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Mon, 20 May 2024 20:51:02 -0400 Subject: [PATCH 2/5] docs: add docs and changelog --- changelog/1197.feature.rst | 5 +++++ docs/api/messages.rst | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 changelog/1197.feature.rst diff --git a/changelog/1197.feature.rst b/changelog/1197.feature.rst new file mode 100644 index 0000000000..8b2535aed2 --- /dev/null +++ b/changelog/1197.feature.rst @@ -0,0 +1,5 @@ +Implement new :attr:`Message.type`s: + - :attr:`MessageType.guild_incident_alert_mode_enabled` + - :attr:`MessageType.guild_incident_alert_mode_disabled` + - :attr:`MessageType.guild_incident_report_raid` + - :attr:`MessageType.guild_incident_report_false_alarm` diff --git a/docs/api/messages.rst b/docs/api/messages.rst index 3031d955d9..85dcc207f3 100644 --- a/docs/api/messages.rst +++ b/docs/api/messages.rst @@ -348,6 +348,24 @@ MessageType The system message denoting that a guild member has subscribed to an application. .. versionadded:: 2.8 + .. attribute:: guild_incident_alert_mode_enabled + + The system message denoting that an admin enabled security actions. + + .. versionadded:: 2.10 + .. attribute:: guild_incident_alert_mode_disabled + + The system message denoting that an admin disabled security actions. + + .. versionadded:: 2.10 + .. attribute:: guild_incident_report_raid + + The system message denoting that an admin reported a raid. + + .. versionadded:: 2.10 + .. attribute:: guild_incident_report_false_alarm + + The system message denoting that a raid report was a false alarm. Events ------ From 290adfbd04ee7cbcc6a0d270cf6d76592532b389 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Mon, 20 May 2024 20:51:48 -0400 Subject: [PATCH 3/5] docs: add versionadded --- docs/api/messages.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api/messages.rst b/docs/api/messages.rst index 85dcc207f3..e0a7c8a513 100644 --- a/docs/api/messages.rst +++ b/docs/api/messages.rst @@ -367,6 +367,8 @@ MessageType The system message denoting that a raid report was a false alarm. + .. versionadded:: 2.10 + Events ------ From 8c5e0990f3496a14a0dd06500e9f59151e79b691 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Mon, 20 May 2024 20:53:47 -0400 Subject: [PATCH 4/5] docs: fix it --- changelog/1197.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/1197.feature.rst b/changelog/1197.feature.rst index 8b2535aed2..799118a434 100644 --- a/changelog/1197.feature.rst +++ b/changelog/1197.feature.rst @@ -1,4 +1,4 @@ -Implement new :attr:`Message.type`s: +Implement new :attr:`Message.type`\s: - :attr:`MessageType.guild_incident_alert_mode_enabled` - :attr:`MessageType.guild_incident_alert_mode_disabled` - :attr:`MessageType.guild_incident_report_raid` From 028594c84667f8f7be50949a52a2c1685516c211 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Tue, 21 May 2024 11:52:35 -0400 Subject: [PATCH 5/5] feat: add type 39 system content thanks shiftinv --- disnake/message.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/disnake/message.py b/disnake/message.py index 575c9b1c2c..7957799de6 100644 --- a/disnake/message.py +++ b/disnake/message.py @@ -1533,7 +1533,10 @@ def system_content(self) -> Optional[str]: if self.type is MessageType.guild_incident_report_raid: guild_name = self.guild.name if self.guild else None - return f"{self.author.name} reported a raid in {guild_name}" + return f"{self.author.name} reported a raid in {guild_name}." + + if self.type is MessageType.guild_incident_report_false_alarm: + return f"{self.author.name} resolved an Activity Alert." # in the event of an unknown or unsupported message type, we return nothing return None