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

Add missing guild incident fields #9808

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 42 additions & 0 deletions discord/guild.py
Expand Up @@ -4416,6 +4416,28 @@ def dms_paused_until(self) -> Optional[datetime.datetime]:

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.4
"""
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.4
"""
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.

Expand All @@ -4435,3 +4457,23 @@ def dms_paused(self) -> bool:
return False

return self.dms_paused_until > utils.utcnow()

def dm_spam_detected(self) -> bool:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def dm_spam_detected(self) -> bool:
def is_dm_spam_detected(self) -> bool:

""":class:`bool`: Whether DM spam was detected in the guild.

.. versionadded:: 2.4
"""
if not self.dm_spam_detected_at:
return False

return self.dm_spam_detected_at > utils.utcnow()

def raid_detected(self) -> bool:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def raid_detected(self) -> bool:
def is_raid_detected(self) -> bool:

""":class:`bool`: Whether a raid was detected in the guild.

.. versionadded:: 2.4
"""
if not self.raid_detected_at:
return False

return self.raid_detected_at > utils.utcnow()