From 6ae4d711e36ee02e273039f7af9b0cbfabc54a3b Mon Sep 17 00:00:00 2001 From: Andrin <65789180+Puncher1@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:45:44 +0100 Subject: [PATCH] Add new incident message types Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com> --- discord/enums.py | 4 ++++ discord/message.py | 14 ++++++++++++++ discord/types/message.py | 35 ++++++++++++++++++++++++++++++++++- docs/api.rst | 24 ++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/discord/enums.py b/discord/enums.py index c45d2b86c..880e6a10e 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -309,6 +309,10 @@ class MessageType(Enum): stage_raise_hand = 30 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 SpeakingState(Enum): diff --git a/discord/message.py b/discord/message.py index ecbec1c49..f7f74573c 100644 --- a/discord/message.py +++ b/discord/message.py @@ -2245,6 +2245,20 @@ class Message(PartialMessage, Hashable): if self.type is MessageType.guild_application_premium_subscription: return f'{self.author.name} upgraded {self.application.name if self.application else "a deleted application"} to premium for this server!' + if self.type is MessageType.guild_incident_alert_mode_enabled: + dt = utils.parse_time(self.content) + dt_content = utils.format_dt(dt) + return f'{self.author.name} enabled security actions until {dt_content}.' + + 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: + return f'{self.author.name} reported a raid in {self.guild}.' + + if self.type is MessageType.guild_incident_report_false_alarm: + return f'{self.author.name} reported a false alarm in {self.guild}.' + # Fallback for unknown message types return self.content diff --git a/discord/types/message.py b/discord/types/message.py index f9432a04c..fa1a558a4 100644 --- a/discord/types/message.py +++ b/discord/types/message.py @@ -111,7 +111,40 @@ class RoleSubscriptionData(TypedDict): MessageType = Literal[ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 14, + 15, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 36, + 37, + 38, + 39, ] diff --git a/docs/api.rst b/docs/api.rst index f12107d5e..9fe8484ae 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1956,6 +1956,30 @@ of :class:`enum.Enum`. A friend invite. + .. attribute:: guild_incident_alert_mode_enabled + + The system message sent when security actions is enabled. + + .. versionadded:: 2.4 + + .. attribute:: guild_incident_alert_mode_disabled + + The system message sent when security actions is disabled. + + .. versionadded:: 2.4 + + .. attribute:: guild_incident_report_raid + + The system message sent when a raid is reported. + + .. versionadded:: 2.4 + + .. attribute:: guild_incident_report_false_alarm + + The system message sent when a false alarm is reported. + + .. versionadded:: 2.4 + .. class:: UserFlags Represents Discord User flags.