Skip to content

feat: add ThreadAutoArchiveDuration enum #2826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3679443
feat: add ThreadAutoArchiveDuration enum
BOXERRMD Jul 8, 2025
1424acf
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2025
a7d46af
feat: make change after write enum.IntEnum
BOXERRMD Jul 8, 2025
3747633
feat: make change after speak on github
BOXERRMD Jul 8, 2025
bd5c404
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2025
be7b9bf
feat: Apply changes and add doc
BOXERRMD Jul 8, 2025
a24912a
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2025
4593a84
Update CHANGELOG.md
BOXERRMD Jul 8, 2025
595aaeb
Update docs/api/enums.rst
BOXERRMD Jul 8, 2025
979f6c1
Merge branch 'master' into Add_tread_archive_duration_enum
BOXERRMD Aug 2, 2025
fecbf54
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2025
6145605
Update discord/threads.py
Lulalaby Aug 3, 2025
ed8dce1
Update discord/channel.py
Lulalaby Aug 3, 2025
e37c7f7
Merge branch 'master' into Add_tread_archive_duration_enum
Lulalaby Aug 3, 2025
ad88445
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2025
68a6cdc
Merge branch 'master' into Add_tread_archive_duration_enum
Lumabots Aug 3, 2025
b53eab8
Update CHANGELOG.md
Dorukyum Aug 15, 2025
9f64f20
Update CHANGELOG.md
BOXERRMD Aug 15, 2025
6c62744
Update discord/enums.py
BOXERRMD Aug 15, 2025
1a32255
Update discord/threads.py
BOXERRMD Aug 15, 2025
e6906ed
Merge branch 'master' into Add_tread_archive_duration_enum
BOXERRMD Aug 15, 2025
7419df8
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
- Added `discord.Interaction.created_at`.
([#2801](https://github.com/Pycord-Development/pycord/pull/2801))
- Added `ThreadAutoArchiveDuration` enum to improve clarity of thread archive durations.
([#2826](https://github.com/Pycord-Development/pycord/pull/2826))

### Fixed

Expand Down
8 changes: 7 additions & 1 deletion discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
InviteTarget,
SortOrder,
StagePrivacyLevel,
)
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
from .enums import (
VideoQualityMode,
VoiceRegion,
try_enum,
Expand Down Expand Up @@ -1084,7 +1087,9 @@ async def edit(
sync_permissions: bool = ...,
category: CategoryChannel | None = ...,
slowmode_delay: int = ...,
default_auto_archive_duration: ThreadArchiveDuration = ...,
default_auto_archive_duration: (
ThreadArchiveDuration | ThreadArchiveDurationEnum
) = ...,
default_thread_slowmode_delay: int = ...,
default_sort_order: SortOrder = ...,
default_reaction_emoji: GuildEmoji | int | str | None = ...,
Expand Down Expand Up @@ -1130,6 +1135,7 @@ async def edit(self, *, reason=None, **options):
default_auto_archive_duration: :class:`int`
The new default auto archive duration in minutes for threads created in this channel.
Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
:class:`ThreadAutoArchiveDuration` can be used alternatively.
Copy link
Member

Choose a reason for hiding this comment

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

This makes the type a union

Copy link
Author

Choose a reason for hiding this comment

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

👌

default_thread_slowmode_delay: :class:`int`
The new default slowmode delay in seconds for threads created in this channel.

Expand Down
11 changes: 11 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import types
from collections import namedtuple
from enum import IntEnum
from typing import TYPE_CHECKING, Any, ClassVar, TypeVar, Union

__all__ = (
Expand Down Expand Up @@ -78,6 +79,7 @@
"InteractionContextType",
"PollLayoutType",
"MessageReferenceType",
"ThreadArchiveDuration",
)


Expand Down Expand Up @@ -1078,6 +1080,15 @@ class SubscriptionStatus(Enum):
inactive = 2


class ThreadArchiveDuration(IntEnum):
"""Time set before the thread is auto archived"""

one_hour = 60
one_day = 1440
three_days = 4320
one_week = 10080


T = TypeVar("T")


Expand Down
9 changes: 7 additions & 2 deletions discord/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
from typing import TYPE_CHECKING, Callable, Iterable

from .abc import Messageable, _purge_messages_helper
from .enums import ChannelType, try_enum
from .enums import ChannelType
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
from .enums import try_enum
from .errors import ClientException
from .flags import ChannelFlags
from .mixins import Hashable
Expand Down Expand Up @@ -602,7 +604,9 @@ async def edit(
locked: bool = MISSING,
invitable: bool = MISSING,
slowmode_delay: int = MISSING,
auto_archive_duration: ThreadArchiveDuration = MISSING,
auto_archive_duration: (
ThreadArchiveDurationEnum | ThreadArchiveDuration
) = MISSING,
pinned: bool = MISSING,
applied_tags: list[ForumTag] = MISSING,
reason: str | None = None,
Expand Down Expand Up @@ -632,6 +636,7 @@ async def edit(
auto_archive_duration: :class:`int`
The new duration in minutes before a thread is automatically archived for inactivity.
Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
:class:`ThreadAutoArchiveDuration` can be used alternatively.
Copy link
Member

Choose a reason for hiding this comment

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

This makes the type a union

Copy link
Author

Choose a reason for hiding this comment

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

👌

slowmode_delay: :class:`int`
Specifies the slowmode rate limit for user in this thread, in seconds.
A value of ``0`` disables slowmode. The maximum value possible is ``21600``.
Expand Down
23 changes: 23 additions & 0 deletions docs/api/enums.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2519,3 +2519,26 @@ of :class:`enum.Enum`.
.. attribute:: inactive

The subscription is inactive and the subscription owner is not being charged.


.. class:: ThreadArchiveDuration

Represents the time before a thread is archived.

.. versionadded:: 2.7

.. attribute:: one_hour

Indicates that the thread will be archived after 1 hour of inactivity.

.. attribute:: one_day

Indicates that the thread will be archived after 1 day of inactivity.

.. attribute:: three_days

Indicates that the thread will be archived after 3 days of inactivity.

.. attribute:: one_week

Indicates that the thread will be archived after 1 week of inactivity.
Loading