Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Message): implement new types #1197

Merged
merged 6 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/1197.feature.rst
Original file line number Diff line number Diff line change
@@ -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`
4 changes: 4 additions & 0 deletions disnake/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions disnake/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,20 @@ 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}."

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

Expand Down
20 changes: 20 additions & 0 deletions docs/api/messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,26 @@ 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.

.. versionadded:: 2.10

Events
------
Expand Down
Loading