|
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, |
|
68 | 69 | from .errors import ClientException, InvalidArgument, InvalidData |
69 | 70 | from .file import File |
70 | 71 | from .flags import SystemChannelFlags |
| 72 | +from .incidents import IncidentsData |
71 | 73 | from .integrations import Integration, _integration_factory |
72 | 74 | from .invite import Invite |
73 | 75 | from .iterators import ( |
|
113 | 115 | from .template import Template |
114 | 116 | from .types.guild import Ban as BanPayload |
115 | 117 | from .types.guild import Guild as GuildPayload |
116 | | - from .types.guild import GuildFeature, MFALevel |
| 118 | + from .types.guild import ( |
| 119 | + GuildFeature, |
| 120 | + MFALevel, |
| 121 | + ) |
| 122 | + from .types.guild import ModifyIncidents as ModifyIncidentsPayload |
117 | 123 | from .types.member import Member as MemberPayload |
118 | 124 | from .types.threads import Thread as ThreadPayload |
119 | 125 | from .types.voice import GuildVoiceState |
@@ -289,6 +295,7 @@ class Guild(Hashable): |
289 | 295 | "approximate_member_count", |
290 | 296 | "approximate_presence_count", |
291 | 297 | "_sounds", |
| 298 | + "incidents_data", |
292 | 299 | ) |
293 | 300 |
|
294 | 301 | _PREMIUM_GUILD_LIMITS: ClassVar[dict[int | None, _GuildLimit]] = { |
@@ -526,6 +533,13 @@ def _from_data(self, guild: GuildPayload) -> None: |
526 | 533 | sound = SoundboardSound(state=state, http=state.http, data=sound) |
527 | 534 | self._add_sound(sound) |
528 | 535 |
|
| 536 | + incidents_payload = guild.get("incidents_data") |
| 537 | + self.incidents_data: IncidentsData | None = ( |
| 538 | + IncidentsData(data=incidents_payload) |
| 539 | + if incidents_payload is not None |
| 540 | + else None |
| 541 | + ) |
| 542 | + |
529 | 543 | def _add_sound(self, sound: SoundboardSound) -> None: |
530 | 544 | self._sounds[sound.id] = sound |
531 | 545 | self._state._add_sound(sound) |
@@ -4232,6 +4246,52 @@ async def edit_onboarding( |
4232 | 4246 | new = await self._state.http.edit_onboarding(self.id, fields, reason=reason) |
4233 | 4247 | return Onboarding(data=new, guild=self) |
4234 | 4248 |
|
| 4249 | + async def modify_incident_actions( |
| 4250 | + self, |
| 4251 | + *, |
| 4252 | + invites_disabled_until: datetime.datetime | None = MISSING, |
| 4253 | + dms_disabled_until: datetime.datetime | None = MISSING, |
| 4254 | + reason: str | None = MISSING, |
| 4255 | + ) -> IncidentsData: |
| 4256 | + """|coro| |
| 4257 | +
|
| 4258 | + Modify the guild's incident actions, controlling when invites or DMs |
| 4259 | + are re-enabled after being temporarily disabled. Requires |
| 4260 | + the :attr:`~Permissions.manage_guild` permission. |
| 4261 | +
|
| 4262 | + Parameters |
| 4263 | + ---------- |
| 4264 | + invites_disabled_until: Optional[:class:`datetime.datetime`] |
| 4265 | + The ISO8601 timestamp indicating when invites will be enabled again, |
| 4266 | + or ``None`` to enable invites immediately. |
| 4267 | + dms_disabled_until: Optional[:class:`datetime.datetime`] |
| 4268 | + The ISO8601 timestamp indicating when DMs will be enabled again, |
| 4269 | + or ``None`` to enable DMs immediately. |
| 4270 | + reason: Optional[:class:`str`] |
| 4271 | + The reason for this action, used for the audit log. |
| 4272 | +
|
| 4273 | + Returns |
| 4274 | + ------- |
| 4275 | + :class:`IncidentsData` |
| 4276 | + The updated incidents data for the guild. |
| 4277 | + """ |
| 4278 | + |
| 4279 | + fields: ModifyIncidentsPayload = {} |
| 4280 | + if invites_disabled_until is not MISSING: |
| 4281 | + fields["invites_disabled_until"] = ( |
| 4282 | + invites_disabled_until and invites_disabled_until.isoformat() |
| 4283 | + ) |
| 4284 | + |
| 4285 | + if dms_disabled_until is not MISSING: |
| 4286 | + fields["dms_disabled_until"] = ( |
| 4287 | + dms_disabled_until and dms_disabled_until.isoformat() |
| 4288 | + ) |
| 4289 | + |
| 4290 | + new = await self._state.http.modify_guild_incident_actions( |
| 4291 | + self.id, fields, reason=reason |
| 4292 | + ) |
| 4293 | + return IncidentsData(data=new) |
| 4294 | + |
4235 | 4295 | async def delete_auto_moderation_rule( |
4236 | 4296 | self, |
4237 | 4297 | id: int, |
|
0 commit comments