Skip to content

Commit

Permalink
Add new incident message types
Browse files Browse the repository at this point in the history
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
  • Loading branch information
Puncher1 and Rapptz committed Dec 18, 2023
1 parent 9db0dad commit 08ef42f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
4 changes: 4 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,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):
Expand Down
14 changes: 14 additions & 0 deletions discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,20 @@ def system_content(self) -> str:
if self.type is MessageType.stage_topic:
return f'{self.author.name} changed Stage topic: **{self.content}**.'

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 ''

Expand Down
35 changes: 34 additions & 1 deletion discord/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,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,
]


Expand Down
24 changes: 24 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,30 @@ of :class:`enum.Enum`.

.. versionadded:: 2.2

.. 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.
Expand Down

0 comments on commit 08ef42f

Please sign in to comment.