Skip to content

Commit fde7131

Browse files
SoheabowocadoRapptz
authored
Add missing guild incident fields
Co-authored-by: owocado <[email protected]> Co-authored-by: Danny <[email protected]>
1 parent 643a7f4 commit fde7131

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

discord/guild.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4435,6 +4435,28 @@ def dms_paused_until(self) -> Optional[datetime.datetime]:
44354435

44364436
return utils.parse_time(self._incidents_data.get('dms_disabled_until'))
44374437

4438+
@property
4439+
def dm_spam_detected_at(self) -> Optional[datetime.datetime]:
4440+
""":class:`datetime.datetime`: Returns the time when DM spam was detected in the guild.
4441+
4442+
.. versionadded:: 2.5
4443+
"""
4444+
if not self._incidents_data:
4445+
return None
4446+
4447+
return utils.parse_time(self._incidents_data.get('dm_spam_detected_at'))
4448+
4449+
@property
4450+
def raid_detected_at(self) -> Optional[datetime.datetime]:
4451+
"""Optional[:class:`datetime.datetime`]: Returns the time when a raid was detected in the guild.
4452+
4453+
.. versionadded:: 2.5
4454+
"""
4455+
if not self._incidents_data:
4456+
return None
4457+
4458+
return utils.parse_time(self._incidents_data.get('raid_detected_at'))
4459+
44384460
def invites_paused(self) -> bool:
44394461
""":class:`bool`: Whether invites are paused in the guild.
44404462
@@ -4451,6 +4473,26 @@ def dms_paused(self) -> bool:
44514473
.. versionadded:: 2.4
44524474
"""
44534475
if not self.dms_paused_until:
4454-
return False
4476+
return 'INVITES_DISABLED' in self.features
44554477

44564478
return self.dms_paused_until > utils.utcnow()
4479+
4480+
def is_dm_spam_detected(self) -> bool:
4481+
""":class:`bool`: Whether DM spam was detected in the guild.
4482+
4483+
.. versionadded:: 2.5
4484+
"""
4485+
if not self.dm_spam_detected_at:
4486+
return False
4487+
4488+
return self.dm_spam_detected_at > utils.utcnow()
4489+
4490+
def is_raid_detected(self) -> bool:
4491+
""":class:`bool`: Whether a raid was detected in the guild.
4492+
4493+
.. versionadded:: 2.5
4494+
"""
4495+
if not self.raid_detected_at:
4496+
return False
4497+
4498+
return self.raid_detected_at > utils.utcnow()

0 commit comments

Comments
 (0)