From fde7131d26bfa431a476a8a64ea3ae9f18bf2683 Mon Sep 17 00:00:00 2001 From: Soheab <33902984+Soheab@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:30:18 +0200 Subject: [PATCH] Add missing guild incident fields Co-authored-by: owocado <24418520+owocado@users.noreply.github.com> Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com> --- discord/guild.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/discord/guild.py b/discord/guild.py index 5296faa07..07a072d1f 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -4435,6 +4435,28 @@ class Guild(Hashable): return utils.parse_time(self._incidents_data.get('dms_disabled_until')) + @property + def dm_spam_detected_at(self) -> Optional[datetime.datetime]: + """:class:`datetime.datetime`: Returns the time when DM spam was detected in the guild. + + .. versionadded:: 2.5 + """ + if not self._incidents_data: + return None + + return utils.parse_time(self._incidents_data.get('dm_spam_detected_at')) + + @property + def raid_detected_at(self) -> Optional[datetime.datetime]: + """Optional[:class:`datetime.datetime`]: Returns the time when a raid was detected in the guild. + + .. versionadded:: 2.5 + """ + if not self._incidents_data: + return None + + return utils.parse_time(self._incidents_data.get('raid_detected_at')) + def invites_paused(self) -> bool: """:class:`bool`: Whether invites are paused in the guild. @@ -4451,6 +4473,26 @@ class Guild(Hashable): .. versionadded:: 2.4 """ if not self.dms_paused_until: - return False + return 'INVITES_DISABLED' in self.features return self.dms_paused_until > utils.utcnow() + + def is_dm_spam_detected(self) -> bool: + """:class:`bool`: Whether DM spam was detected in the guild. + + .. versionadded:: 2.5 + """ + if not self.dm_spam_detected_at: + return False + + return self.dm_spam_detected_at > utils.utcnow() + + def is_raid_detected(self) -> bool: + """:class:`bool`: Whether a raid was detected in the guild. + + .. versionadded:: 2.5 + """ + if not self.raid_detected_at: + return False + + return self.raid_detected_at > utils.utcnow()