diff --git a/CHANGELOG.md b/CHANGELOG.md index 718642108d..5a90c5b47f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,7 +66,9 @@ These changes are available on the `master` branch, but have not yet been releas - Added `User.nameplate` property. ([#2817](https://github.com/Pycord-Development/pycord/pull/2817)) - Added role gradients support with `Role.colours` and the `RoleColours` class. - ([#2818](https://github.com/Pycord-Development/pycord/pull/2818)) + ([#2818](https://github.com/Pycord-Development/pycord/pull/2818 +- Added `ThreadAutoArchiveDuration` enum to improve clarity of thread archive durations. + ([#2826](https://github.com/Pycord-Development/pycord/pull/2826)) ### Fixed diff --git a/discord/channel.py b/discord/channel.py index de589a5502..52269d757a 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -48,6 +48,9 @@ InviteTarget, SortOrder, StagePrivacyLevel, +) +from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum +from .enums import ( VideoQualityMode, VoiceRegion, try_enum, @@ -1097,7 +1100,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 = ..., @@ -1143,6 +1148,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. default_thread_slowmode_delay: :class:`int` The new default slowmode delay in seconds for threads created in this channel. diff --git a/discord/enums.py b/discord/enums.py index a8affc8a8b..a601802d16 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -27,6 +27,7 @@ import types from collections import namedtuple +from enum import IntEnum from typing import TYPE_CHECKING, Any, ClassVar, TypeVar, Union __all__ = ( @@ -78,6 +79,7 @@ "InteractionContextType", "PollLayoutType", "MessageReferenceType", + "ThreadArchiveDuration", "SubscriptionStatus", "SeparatorSpacingSize", ) @@ -1088,6 +1090,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 + + class SeparatorSpacingSize(Enum): """A separator component's spacing size.""" diff --git a/discord/threads.py b/discord/threads.py index 0e1675a1bd..33414806b7 100644 --- a/discord/threads.py +++ b/discord/threads.py @@ -28,7 +28,13 @@ 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 @@ -602,7 +608,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, @@ -632,6 +640,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. 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``. diff --git a/docs/api/enums.rst b/docs/api/enums.rst index 1210990717..34ac6ed5b9 100644 --- a/docs/api/enums.rst +++ b/docs/api/enums.rst @@ -2521,6 +2521,30 @@ of :class:`enum.Enum`. 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. + + .. class:: SeparatorSpacingSize Represents the padding size around a separator component.