-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
base: master
Are you sure you want to change the base?
feat: add ThreadAutoArchiveDuration enum #2826
Conversation
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.
There was a problem hiding this 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.
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. |
discord/enums.py
Outdated
@@ -1078,6 +1079,15 @@ class SubscriptionStatus(Enum): | |||
inactive = 2 | |||
|
|||
|
|||
class ThreadAutoArchiveDuration(Enum): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have make changes
discord/channel.py
Outdated
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 | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | |
) |
discord/threads.py
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ThreadAutoArchiveDuration(enum.IntEnum): | |
class ThreadArchiveDuration(enum.IntEnum): |
Rename it here and then use from ... import ThreadArchiveDuration as ThreadArchiveDurationEnum
discord/channel.py
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**ThreadAutoArchiveDuration** enum can be used for better understanding. | |
:class:`ThreadAutoArchiveDuration` can be used alternatively. |
I have apply changes ! :D |
There was a problem hiding this 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.
discord/channel.py
Outdated
@@ -39,6 +39,9 @@ | |||
InviteTarget, | |||
SortOrder, | |||
StagePrivacyLevel, | |||
) | |||
from .enums import ThreadArchiveDuration as ThreadAutoArchiveDuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import enum | |
from enum import IntEnum |
discord/enums.py
Outdated
@@ -1078,6 +1080,15 @@ class SubscriptionStatus(Enum): | |||
inactive = 2 | |||
|
|||
|
|||
class ThreadArchiveDuration(enum.IntEnum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ThreadArchiveDuration(enum.IntEnum): | |
class ThreadArchiveDuration(IntEnum): |
I find this not very necessary. See the documentation and the type pycord/discord/types/threads.py Line 36 in 1c65fc8
|
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. |
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. |
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>
👍 I have make changes ! |
There was a problem hiding this 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.
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
examples, ...).
Checklist
type: ignore
comments were used, a comment is also left explaining why.