Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 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
5cd99f2
Apply suggestions from code review
Lulalaby Aug 30, 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 get thread archive duration more
efficiently. ([#2826](https://github.com/Pycord-Development/pycord/pull/2826))

### Fixed

Expand Down
14 changes: 13 additions & 1 deletion discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
InviteTarget,
SortOrder,
StagePrivacyLevel,
ThreadAutoArchiveDuration,
VideoQualityMode,
VoiceRegion,
try_enum,
Expand Down Expand Up @@ -1084,7 +1085,9 @@ async def edit(
sync_permissions: bool = ...,
category: CategoryChannel | None = ...,
slowmode_delay: int = ...,
default_auto_archive_duration: ThreadArchiveDuration = ...,
default_auto_archive_duration: (
ThreadArchiveDuration | ThreadAutoArchiveDuration
) = ...,
default_thread_slowmode_delay: int = ...,
default_sort_order: SortOrder = ...,
default_reaction_emoji: GuildEmoji | int | str | None = ...,
Expand Down Expand Up @@ -1130,6 +1133,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``.
**ThreadAutoArchiveDuration** enum can be used for better understanding.
default_thread_slowmode_delay: :class:`int`
The new default slowmode delay in seconds for threads created in this channel.

Expand Down Expand Up @@ -1173,6 +1177,14 @@ async def edit(self, *, reason=None, **options):
options["flags"] = ChannelFlags._from_value(self.flags.value)
options["flags"].require_tag = options.pop("require_tag")

if "default_auto_archive_duration" in options:
default_auto_archive_duration = options["default_auto_archive_duration"]
options["default_auto_archive_duration"] = (
default_auto_archive_duration
if isinstance(default_auto_archive_duration, (int, float))
else default_auto_archive_duration.value
)

payload = await self._edit(options, reason=reason)
if payload is not None:
# the payload will always be the proper channel payload
Expand Down
11 changes: 11 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from __future__ import annotations

import enum
import types
from collections import namedtuple
from typing import TYPE_CHECKING, Any, ClassVar, TypeVar, Union
Expand Down Expand Up @@ -78,6 +79,7 @@
"InteractionContextType",
"PollLayoutType",
"MessageReferenceType",
"ThreadAutoArchiveDuration",
)


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


class ThreadAutoArchiveDuration(enum.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
7 changes: 5 additions & 2 deletions discord/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from typing import TYPE_CHECKING, Callable, Iterable

from .abc import Messageable, _purge_messages_helper
from .enums import ChannelType, try_enum
from .enums import ChannelType, ThreadAutoArchiveDuration, try_enum
from .errors import ClientException
from .flags import ChannelFlags
from .mixins import Hashable
Expand Down Expand Up @@ -602,7 +602,9 @@ async def edit(
locked: bool = MISSING,
invitable: bool = MISSING,
slowmode_delay: int = MISSING,
auto_archive_duration: ThreadArchiveDuration = MISSING,
auto_archive_duration: (
ThreadAutoArchiveDuration | ThreadArchiveDuration
) = MISSING,
pinned: bool = MISSING,
applied_tags: list[ForumTag] = MISSING,
reason: str | None = None,
Expand Down Expand Up @@ -632,6 +634,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``.
**ThreadAutoArchiveDuration** enum can be used for better understanding.
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