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 9 commits into
base: master
Choose a base branch
from

Conversation

BOXERRMD
Copy link

@BOXERRMD BOXERRMD commented Jul 8, 2025

Add an enumeration ThreadAutoArchiveDuration to get time before the thread was archived.

The selected enumeration value is automatically retrieved. You can always set the archiving time as a number without using this enumeration.

Summary

This pull request doesn't make any corrections to the code, but adds an enumeration to help find the available thread archive times.
It's not necessarily necessary, but it makes the code easier to read and understand.

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

Add an enumeration ThreadAutoArchiveDuration to get time before the thread was archived.

The selected enumeration value is automatically retrieved. You can always set the archiving time as a number without using this enumeration.
Copy link
Contributor

@Paillat-dev Paillat-dev left a comment

Choose a reason for hiding this comment

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

I don't really see the benefit of this.

@BOXERRMD
Copy link
Author

BOXERRMD commented Jul 8, 2025

It just brings more understanding to the code. Yes, the modification isn't necessarily important, but it avoids having numbers that can be boring to read, and gives a better understanding of the time provided. You can even use enumeration to enable interactive modification with a bot without having to put in the four possibilities and just use enumeration.
(I'm trying to defend my idea because I had this problem at one point and I had to ask on the discord support to find out what archiving times were available :') )

discord/enums.py Outdated
@@ -1078,6 +1079,15 @@ class SubscriptionStatus(Enum):
inactive = 2


class ThreadAutoArchiveDuration(Enum):
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use IntEnum here you don't have to do all of the shenanigans with .value

Copy link
Author

Choose a reason for hiding this comment

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

oh, interesting
thanks for the tips ^^
I can make change and commit for check ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah sure

Copy link
Author

Choose a reason for hiding this comment

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

I have make changes

Comment on lines 1180 to 1187
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
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
)

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**ThreadAutoArchiveDuration** enum can be used for better understanding.
:class:`ThreadAutoArchiveDuration` can be used alternatively.

discord/enums.py Outdated
@@ -1078,6 +1080,15 @@ class SubscriptionStatus(Enum):
inactive = 2


class ThreadAutoArchiveDuration(enum.IntEnum):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class ThreadAutoArchiveDuration(enum.IntEnum):
class ThreadArchiveDuration(enum.IntEnum):

Rename it here and then use from ... import ThreadArchiveDuration as ThreadArchiveDurationEnum

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**ThreadAutoArchiveDuration** enum can be used for better understanding.
:class:`ThreadAutoArchiveDuration` can be used alternatively.

@BOXERRMD
Copy link
Author

BOXERRMD commented Jul 8, 2025

I have apply changes ! :D

Copy link
Contributor

@Paillat-dev Paillat-dev left a comment

Choose a reason for hiding this comment

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

Also, please add the enum to the docs in https://github.com/Pycord-Development/pycord/blob/master/docs/api/enums.rst
Look at the other enums in the file and reproduce how they are declared.

@@ -39,6 +39,9 @@
InviteTarget,
SortOrder,
StagePrivacyLevel,
)
from .enums import ThreadArchiveDuration as ThreadAutoArchiveDuration
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from .enums import ThreadArchiveDuration as ThreadAutoArchiveDuration
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum

I think it's better if you import it as ThreadArchiveDurationEnum

discord/enums.py Outdated
@@ -25,6 +25,7 @@

from __future__ import annotations

import enum
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import enum
from enum import IntEnum

discord/enums.py Outdated
@@ -1078,6 +1080,15 @@ class SubscriptionStatus(Enum):
inactive = 2


class ThreadArchiveDuration(enum.IntEnum):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class ThreadArchiveDuration(enum.IntEnum):
class ThreadArchiveDuration(IntEnum):

@Dorukyum
Copy link
Member

Dorukyum commented Jul 8, 2025

I find this not very necessary. See the documentation and the type ThreadArchiveDuration.

ThreadArchiveDuration = Literal[60, 1440, 4320, 10080]

@BOXERRMD
Copy link
Author

BOXERRMD commented Jul 8, 2025

I find that just the figures as shown remain rather unclear about the actual time given. The addition I'm proposing doesn't add anything vital, but I think it makes the code easier to understand, without being compulsory.

@Paillat-dev
Copy link
Contributor

Paillat-dev commented Jul 8, 2025

I find this not very necessary.

Same to be fair, but as long as it's just an Enum class I feel like the changes are acceptable, unlike the original proposition which added too much verbosity. Although this is not strictly necessary.

pre-commit-ci bot and others added 2 commits July 8, 2025 16:11
Co-authored-by: Paillat <jeremiecotti@ik.me>
Signed-off-by: BOXER <130167557+BOXERRMD@users.noreply.github.com>
Co-authored-by: Paillat <jeremiecotti@ik.me>
Signed-off-by: BOXER <130167557+BOXERRMD@users.noreply.github.com>
@BOXERRMD
Copy link
Author

BOXERRMD commented Jul 8, 2025

👍 I have make changes !

Copy link
Contributor

@Paillat-dev Paillat-dev left a comment

Choose a reason for hiding this comment

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

As fare as code quality goes, lgtm.

From a usefulness perspective, I don't think this is strictly necessary but I feel like it's a plus to have.

@Dorukyum Dorukyum self-requested a review July 10, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants