|
26 | 26 | from __future__ import annotations |
27 | 27 |
|
28 | 28 | import copy |
| 29 | +import datetime |
29 | 30 | import unicodedata |
30 | 31 | from typing import ( |
31 | 32 | TYPE_CHECKING, |
|
80 | 81 | from .mixins import Hashable |
81 | 82 | from .monetization import Entitlement |
82 | 83 | from .onboarding import Onboarding |
| 84 | +from .incidents import IncidentsData |
83 | 85 | from .permissions import PermissionOverwrite |
84 | 86 | from .role import Role, RoleColours |
85 | 87 | from .scheduled_events import ScheduledEvent, ScheduledEventLocation |
|
111 | 113 | from .state import ConnectionState |
112 | 114 | from .template import Template |
113 | 115 | from .types.guild import Ban as BanPayload |
114 | | - from .types.guild import Guild as GuildPayload |
| 116 | + from .types.guild import ( |
| 117 | + Guild as GuildPayload, |
| 118 | + IncidentsData as IncidentsDataPayload, |
| 119 | + ) |
115 | 120 | from .types.guild import GuildFeature, MFALevel |
116 | 121 | from .types.member import Member as MemberPayload |
117 | 122 | from .types.threads import Thread as ThreadPayload |
@@ -290,6 +295,7 @@ class Guild(Hashable): |
290 | 295 | "approximate_member_count", |
291 | 296 | "approximate_presence_count", |
292 | 297 | "_sounds", |
| 298 | + "incidents", |
293 | 299 | ) |
294 | 300 |
|
295 | 301 | _PREMIUM_GUILD_LIMITS: ClassVar[dict[int | None, _GuildLimit]] = { |
@@ -569,6 +575,13 @@ def _from_data(self, guild: GuildPayload) -> None: |
569 | 575 | sound = SoundboardSound(state=state, http=state.http, data=sound) |
570 | 576 | self._add_sound(sound) |
571 | 577 |
|
| 578 | + incidents_payload = guild.get("incidents_data") |
| 579 | + self.incidents: IncidentsData | None = ( |
| 580 | + IncidentsData(data=incidents_payload, guild=self) |
| 581 | + if incidents_payload is not None |
| 582 | + else None |
| 583 | + ) |
| 584 | + |
572 | 585 | def _add_sound(self, sound: SoundboardSound) -> None: |
573 | 586 | self._sounds[sound.id] = sound |
574 | 587 | self._state._add_sound(sound) |
@@ -4405,6 +4418,52 @@ async def edit_onboarding( |
4405 | 4418 | new = await self._state.http.edit_onboarding(self.id, fields, reason=reason) |
4406 | 4419 | return Onboarding(data=new, guild=self) |
4407 | 4420 |
|
| 4421 | + async def modify_incident_actions( |
| 4422 | + self, |
| 4423 | + *, |
| 4424 | + invites_disabled_until: datetime.datetime | None = MISSING, |
| 4425 | + dms_disabled_until: datetime.datetime | None = MISSING, |
| 4426 | + reason: str | None = MISSING, |
| 4427 | + ) -> IncidentsData: |
| 4428 | + """|coro| |
| 4429 | +
|
| 4430 | + Modify the guild's incident actions (invites or DMs disabled until a |
| 4431 | + given ISO8601 timestamp). Supplying ``None`` disables the respective |
| 4432 | + action. Requires :attr:`~Permissions.manage_guild`. |
| 4433 | +
|
| 4434 | + Parameters |
| 4435 | + ---------- |
| 4436 | + invites_disabled_until: Optional[:class:`str`] |
| 4437 | + ISO8601 timestamp indicating when invites will be enabled again, or |
| 4438 | + ``None`` to disable. |
| 4439 | + dms_disabled_until: Optional[:class:`str`] |
| 4440 | + ISO8601 timestamp indicating when DMs will be enabled again, or |
| 4441 | + ``None`` to disable. |
| 4442 | + reason: Optional[:class:`str`] |
| 4443 | + Audit log reason. |
| 4444 | +
|
| 4445 | + Returns |
| 4446 | + ------- |
| 4447 | + :class:`IncidentsData` |
| 4448 | + The updated incidents data for the guild. |
| 4449 | + """ |
| 4450 | + |
| 4451 | + fields: IncidentsDataPayload = {} |
| 4452 | + if invites_disabled_until is not MISSING: |
| 4453 | + fields["invites_disabled_until"] = ( |
| 4454 | + invites_disabled_until and invites_disabled_until.isoformat() |
| 4455 | + ) |
| 4456 | + |
| 4457 | + if dms_disabled_until is not MISSING: |
| 4458 | + fields["dms_disabled_until"] = ( |
| 4459 | + dms_disabled_until and dms_disabled_until.isoformat() |
| 4460 | + ) |
| 4461 | + |
| 4462 | + new = await self._state.http.modify_guild_incident_actions( |
| 4463 | + self.id, fields, reason=reason |
| 4464 | + ) |
| 4465 | + return IncidentsData(data=new, guild=self) |
| 4466 | + |
4408 | 4467 | async def delete_auto_moderation_rule( |
4409 | 4468 | self, |
4410 | 4469 | id: int, |
|
0 commit comments