Skip to content

Commit 90ba570

Browse files
BOXERRMDPaillat-dev
authored andcommitted
feat: add ThreadAutoArchiveDuration enum (Pycord-Development#2826)
Signed-off-by: BOXER <[email protected]> Signed-off-by: Lala Sabathil <[email protected]> Signed-off-by: Lala Sabathil <[email protected]> Signed-off-by: Dorukyum <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Paillat <[email protected]> Co-authored-by: Lala Sabathil <[email protected]> Co-authored-by: plun1331 <[email protected]> Co-authored-by: Lala Sabathil <[email protected]> Co-authored-by: Lumouille <[email protected]> Co-authored-by: Dorukyum <[email protected]> Co-authored-by: Copilot <[email protected]> (cherry picked from commit 54884c3) Signed-off-by: Paillat-dev <[email protected]>
1 parent dd6688d commit 90ba570

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ These changes are available on the `master` branch, but have not yet been releas
6767
([#2817](https://github.com/Pycord-Development/pycord/pull/2817))
6868
- Added role gradients support with `Role.colours` and the `RoleColours` class.
6969
([#2818](https://github.com/Pycord-Development/pycord/pull/2818))
70+
- Added `ThreadArchiveDuration` enum to improve clarity of thread archive durations.
71+
([#2826](https://github.com/Pycord-Development/pycord/pull/2826))
7072
- Added `Interaction.attachment_size_limit`.
7173
([#2854](https://github.com/Pycord-Development/pycord/pull/2854))
7274
- Added `AuditLogDiff.communication_disabled_until`.

discord/channel.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
InviteTarget,
4949
SortOrder,
5050
StagePrivacyLevel,
51+
)
52+
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
53+
from .enums import (
5154
VideoQualityMode,
5255
VoiceRegion,
5356
try_enum,
@@ -1052,7 +1055,9 @@ async def edit(
10521055
sync_permissions: bool = ...,
10531056
category: CategoryChannel | None = ...,
10541057
slowmode_delay: int = ...,
1055-
default_auto_archive_duration: ThreadArchiveDuration = ...,
1058+
default_auto_archive_duration: (
1059+
ThreadArchiveDuration | ThreadArchiveDurationEnum
1060+
) = ...,
10561061
default_thread_slowmode_delay: int = ...,
10571062
default_sort_order: SortOrder = ...,
10581063
default_reaction_emoji: GuildEmoji | int | str | None = ...,
@@ -1098,6 +1103,7 @@ async def edit(self, *, reason=None, **options):
10981103
default_auto_archive_duration: :class:`int`
10991104
The new default auto archive duration in minutes for threads created in this channel.
11001105
Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
1106+
:class:`ThreadArchiveDuration` can be used alternatively.
11011107
default_thread_slowmode_delay: :class:`int`
11021108
The new default slowmode delay in seconds for threads created in this channel.
11031109

discord/enums.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import types
2929
from enum import Enum as EnumBase
30+
from enum import IntEnum
3031
from typing import Any, Self, TypeVar, Union
3132

3233
E = TypeVar("E", bound="Enum")
@@ -80,6 +81,7 @@
8081
"InteractionContextType",
8182
"PollLayoutType",
8283
"MessageReferenceType",
84+
"ThreadArchiveDuration",
8385
"SubscriptionStatus",
8486
"SeparatorSpacingSize",
8587
)
@@ -1009,6 +1011,15 @@ class SubscriptionStatus(Enum):
10091011
inactive = 2
10101012

10111013

1014+
class ThreadArchiveDuration(IntEnum):
1015+
"""The time set until a thread is automatically archived."""
1016+
1017+
one_hour = 60
1018+
one_day = 1440
1019+
three_days = 4320
1020+
one_week = 10080
1021+
1022+
10121023
class SeparatorSpacingSize(Enum):
10131024
"""A separator component's spacing size."""
10141025

discord/threads.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
from discord import utils
3131

3232
from .abc import Messageable, _purge_messages_helper
33-
from .enums import ChannelType, try_enum
33+
from .enums import (
34+
ChannelType,
35+
)
36+
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
37+
from .enums import (
38+
try_enum,
39+
)
3440
from .errors import ClientException
3541
from .flags import ChannelFlags
3642
from .mixins import Hashable
@@ -575,7 +581,7 @@ async def edit(
575581
locked: bool | utils.Undefined = MISSING,
576582
invitable: bool | utils.Undefined = MISSING,
577583
slowmode_delay: int | utils.Undefined = MISSING,
578-
auto_archive_duration: ThreadArchiveDuration | utils.Undefined = MISSING,
584+
auto_archive_duration: ThreadArchiveDuration | ThreadArchiveDurationEnum | utils.Undefined = MISSING,
579585
pinned: bool | utils.Undefined = MISSING,
580586
applied_tags: list[ForumTag] | utils.Undefined = MISSING,
581587
reason: str | None = None,
@@ -605,6 +611,7 @@ async def edit(
605611
auto_archive_duration: :class:`int`
606612
The new duration in minutes before a thread is automatically archived for inactivity.
607613
Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
614+
:class:`ThreadArchiveDuration` can be used alternatively.
608615
slowmode_delay: :class:`int`
609616
Specifies the slowmode rate limit for user in this thread, in seconds.
610617
A value of ``0`` disables slowmode. The maximum value possible is ``21600``.

docs/api/enums.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,30 @@ of :class:`enum.Enum`.
25212521
The subscription is inactive and the subscription owner is not being charged.
25222522
25232523
2524+
2525+
.. class:: ThreadArchiveDuration
2526+
2527+
Represents the time before a thread is archived.
2528+
2529+
.. versionadded:: 2.7
2530+
2531+
.. attribute:: one_hour
2532+
2533+
Indicates that the thread will be archived after 1 hour of inactivity.
2534+
2535+
.. attribute:: one_day
2536+
2537+
Indicates that the thread will be archived after 1 day of inactivity.
2538+
2539+
.. attribute:: three_days
2540+
2541+
Indicates that the thread will be archived after 3 days of inactivity.
2542+
2543+
.. attribute:: one_week
2544+
2545+
Indicates that the thread will be archived after 1 week of inactivity.
2546+
2547+
25242548
.. class:: SeparatorSpacingSize
25252549
25262550
Represents the padding size around a separator component.

0 commit comments

Comments
 (0)