-
-
Notifications
You must be signed in to change notification settings - Fork 483
feat: Add support for Guild Incident Actions and Incidents Data parsing #2955
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
Open
Lumabots
wants to merge
17
commits into
Pycord-Development:master
Choose a base branch
from
Lumabots:incident-actions-
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+152
−2
Open
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e5ca2d1
feat: add incident management functionality to guilds
Lumabots 438dd0c
fix: remove deprecated type checking configuration for basedpyright
Lumabots ab78401
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 67fdcab
fix: rename incidents attribute to incidents_data to follow api
Lumabots bb033f6
Merge branch 'incident-actions-' of https://github.com/Lumabots/pycor…
Lumabots 9fd5c30
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f3e7c40
Update discord/http.py
Lumabots 356c343
Update discord/guild.py
Lumabots f45b897
Update discord/incidents.py
Lumabots 97a14e5
refactor(incidents): simplify datetime parsing using parse_time utility
Lumabots 068e2c7
removal of guild
Lumabots 1cfa614
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1d160c1
Update discord/guild.py
Lumabots 64965b3
fix(incidents): require data parameter in IncidentsData constructor
Lumabots 475a248
fix(guild): rename incidents attribute to incidents_data for clarity
Lumabots 89f3b57
Merge branch 'master' into incident-actions-
Lumabots c2bba6f
Update guild.py
Lumabots File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from __future__ import annotations | ||
|
||
import datetime | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from .guild import Guild | ||
from .types.guild import IncidentsData as IncidentsDataPayload | ||
|
||
__all__ = ("IncidentsData",) | ||
|
||
|
||
class IncidentsData: | ||
"""Represents the incidents data object for a guild. | ||
Attributes | ||
---------- | ||
Lumabots marked this conversation as resolved.
Show resolved
Hide resolved
|
||
invites_disabled_until: Optional[datetime.datetime] | ||
When invites will be enabled again as a :class:`datetime.datetime`, or ``None``. | ||
dms_disabled_until: Optional[datetime.datetime] | ||
When direct messages will be enabled again as a :class:`datetime.datetime`, or ``None``. | ||
dm_spam_detected_at: Optional[datetime.datetime] | ||
When DM spam was detected, or ``None``. | ||
raid_detected_at: Optional[datetime.datetime] | ||
When a raid was detected, or ``None``. | ||
""" | ||
|
||
__slots__ = ( | ||
"guild", | ||
"invites_disabled_until", | ||
"dms_disabled_until", | ||
"dm_spam_detected_at", | ||
"raid_detected_at", | ||
) | ||
|
||
def __init__(self, data: IncidentsDataPayload, guild: Guild | None = None): | ||
self.guild = guild | ||
|
||
self.invites_disabled_until: datetime.datetime | None = ( | ||
datetime.datetime.fromisoformat(s) | ||
if (s := data.get("invites_disabled_until")) | ||
else None | ||
) | ||
Lumabots marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
self.dms_disabled_until: datetime.datetime | None = ( | ||
datetime.datetime.fromisoformat(s) | ||
if (s := data.get("dms_disabled_until")) | ||
else None | ||
) | ||
|
||
self.dm_spam_detected_at: datetime.datetime | None = ( | ||
datetime.datetime.fromisoformat(s) | ||
if (s := data.get("dm_spam_detected_at")) | ||
else None | ||
) | ||
|
||
self.raid_detected_at: datetime.datetime | None = ( | ||
datetime.datetime.fromisoformat(s) | ||
if (s := data.get("raid_detected_at")) | ||
else None | ||
) | ||
|
||
def to_dict(self) -> IncidentsDataPayload: | ||
"""Converts this object back to a raw payload suitable for API use.""" | ||
Lumabots marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return { | ||
"invites_disabled_until": self.invites_disabled_until | ||
and self.invites_disabled_until.isoformat(), | ||
"dms_disabled_until": self.dms_disabled_until | ||
and self.dms_disabled_until.isoformat(), | ||
"dm_spam_detected_at": self.dm_spam_detected_at | ||
and self.dm_spam_detected_at.isoformat(), | ||
"raid_detected_at": self.raid_detected_at | ||
and self.raid_detected_at.isoformat(), | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.