Skip to content

Commit 54884c3

Browse files
BOXERRMDpre-commit-ci[bot]Paillat-devLulalabyplun1331
authored
feat: add ThreadAutoArchiveDuration enum (#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]>
1 parent ba8e438 commit 54884c3

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-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 support for selects and text displays in modals.

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,
@@ -1097,7 +1100,9 @@ async def edit(
10971100
sync_permissions: bool = ...,
10981101
category: CategoryChannel | None = ...,
10991102
slowmode_delay: int = ...,
1100-
default_auto_archive_duration: ThreadArchiveDuration = ...,
1103+
default_auto_archive_duration: (
1104+
ThreadArchiveDuration | ThreadArchiveDurationEnum
1105+
) = ...,
11011106
default_thread_slowmode_delay: int = ...,
11021107
default_sort_order: SortOrder = ...,
11031108
default_reaction_emoji: GuildEmoji | int | str | None = ...,
@@ -1143,6 +1148,7 @@ async def edit(self, *, reason=None, **options):
11431148
default_auto_archive_duration: :class:`int`
11441149
The new default auto archive duration in minutes for threads created in this channel.
11451150
Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
1151+
:class:`ThreadArchiveDuration` can be used alternatively.
11461152
default_thread_slowmode_delay: :class:`int`
11471153
The new default slowmode delay in seconds for threads created in this channel.
11481154

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 collections import namedtuple
30+
from enum import IntEnum
3031
from typing import TYPE_CHECKING, Any, ClassVar, TypeVar, Union
3132

3233
__all__ = (
@@ -78,6 +79,7 @@
7879
"InteractionContextType",
7980
"PollLayoutType",
8081
"MessageReferenceType",
82+
"ThreadArchiveDuration",
8183
"SubscriptionStatus",
8284
"SeparatorSpacingSize",
8385
)
@@ -1088,6 +1090,15 @@ class SubscriptionStatus(Enum):
10881090
inactive = 2
10891091

10901092

1093+
class ThreadArchiveDuration(IntEnum):
1094+
"""The time set until a thread is automatically archived."""
1095+
1096+
one_hour = 60
1097+
one_day = 1440
1098+
three_days = 4320
1099+
one_week = 10080
1100+
1101+
10911102
class SeparatorSpacingSize(Enum):
10921103
"""A separator component's spacing size."""
10931104

discord/threads.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@
2828
from typing import TYPE_CHECKING, Callable, Iterable
2929

3030
from .abc import Messageable, _purge_messages_helper
31-
from .enums import ChannelType, try_enum
31+
from .enums import (
32+
ChannelType,
33+
)
34+
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
35+
from .enums import (
36+
try_enum,
37+
)
3238
from .errors import ClientException
3339
from .flags import ChannelFlags
3440
from .mixins import Hashable
@@ -602,7 +608,9 @@ async def edit(
602608
locked: bool = MISSING,
603609
invitable: bool = MISSING,
604610
slowmode_delay: int = MISSING,
605-
auto_archive_duration: ThreadArchiveDuration = MISSING,
611+
auto_archive_duration: (
612+
ThreadArchiveDuration | ThreadArchiveDurationEnum
613+
) = MISSING,
606614
pinned: bool = MISSING,
607615
applied_tags: list[ForumTag] = MISSING,
608616
reason: str | None = None,
@@ -632,6 +640,7 @@ async def edit(
632640
auto_archive_duration: :class:`int`
633641
The new duration in minutes before a thread is automatically archived for inactivity.
634642
Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
643+
:class:`ThreadArchiveDuration` can be used alternatively.
635644
slowmode_delay: :class:`int`
636645
Specifies the slowmode rate limit for user in this thread, in seconds.
637646
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)