Skip to content

Conversation

Lumabots
Copy link
Contributor

@Lumabots Lumabots commented Oct 14, 2025

Summary

This PR introduces full support for Discord’s Guild Incident Actions API and Incidents Data Object as defined in the Discord API documentation.

Key Features
• Implemented IncidentsData model to represent the guild’s current incident state:
• invites_disabled_until
• dms_disabled_until
• dm_spam_detected_at
• raid_detected_at
• Added ModifyIncidentsPayload type for modifying incident restrictions via REST.

Notes
• The incidents_data field may be omitted or null for guilds without active incidents.
• This update lays the groundwork for future automation or moderation features (e.g., automated incident reporting, DM lockdowns).

Example Usage

@bot.slash_command()
async def test(ctx: discord.ApplicationContext):
    guild = ctx.guild
    if guild is None:
        await ctx.respond("This command can only be used in a guild.")
        return
    if guild.incidents_data is None:
        await ctx.respond("This guild has no incidents data.")
        return
    time = datetime.datetime.now(datetime.UTC) + datetime.timedelta(hours=1)
    updated_data = await guild.modify_incident_actions(
        invites_disabled_until=time, dms_disabled_until=None
    )
    await ctx.respond(f"Updated incidents data: {updated_data.to_dict()}")

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@pycord-app
Copy link

pycord-app bot commented Oct 14, 2025

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/2955/head:pr-2955
git checkout pr-2955

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2955/head

@Lumabots Lumabots changed the title Incident actions feat: Add support for Guild Incident Actions and Incidents Data parsing Oct 14, 2025
@Lumabots Lumabots requested a review from Copilot October 14, 2025 13:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive support for Discord's Guild Incident Actions API, enabling automated moderation features for guilds experiencing spam or raid incidents.

  • Introduces IncidentsData model to represent guild incident states with timestamp fields for disabled invites/DMs and detected incidents
  • Adds modify_incident_actions method to the Guild class for programmatically managing incident restrictions
  • Implements HTTP endpoint integration for the /guilds/{guild_id}/incident-actions API route

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
discord/types/guild.py Adds TypedDict definitions for IncidentsData and ModifyIncidents payloads
discord/incidents.py New module containing IncidentsData class with datetime parsing and serialization
discord/http.py Implements HTTP client method for modify_guild_incident_actions API endpoint
discord/guild.py Integrates incidents_data attribute and modify_incident_actions method into Guild class
discord/init.py Exports incidents module in package imports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Lumabots and others added 2 commits October 14, 2025 15:36
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Lumouille <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Lumouille <[email protected]>
@Lumabots Lumabots requested a review from Copilot October 14, 2025 13:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Lumabots Lumabots requested a review from Copilot October 14, 2025 13:55
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Lumabots Lumabots requested a review from Copilot October 14, 2025 14:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Soheab <[email protected]>
Signed-off-by: Lumouille <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants