Add TextChannel.default_auto_archive_duration

This commit is contained in:
Rapptz 2021-08-02 04:36:02 -04:00
parent 0cc67e58ed
commit 58ca9e9932
3 changed files with 13 additions and 1 deletions

View File

@ -127,6 +127,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
.. note:: .. note::
To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead. To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead.
default_auto_archive_duration: :class:`int`
The default auto archive duration in minutes for threads created in this channel.
.. versionadded:: 2.0
""" """
__slots__ = ( __slots__ = (
@ -142,6 +146,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
'_overwrites', '_overwrites',
'_type', '_type',
'last_message_id', 'last_message_id',
'default_auto_archive_duration',
) )
def __init__(self, *, state: ConnectionState, guild: Guild, data: TextChannelPayload): def __init__(self, *, state: ConnectionState, guild: Guild, data: TextChannelPayload):
@ -171,6 +176,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
self.nsfw: bool = data.get('nsfw', False) self.nsfw: bool = data.get('nsfw', False)
# Does this need coercion into `int`? No idea yet. # Does this need coercion into `int`? No idea yet.
self.slowmode_delay: int = data.get('rate_limit_per_user', 0) self.slowmode_delay: int = data.get('rate_limit_per_user', 0)
self.default_auto_archive_duration: ThreadArchiveDuration = data.get('default_auto_archive_duration', 1440)
self._type: int = data.get('type', self._type) self._type: int = data.get('type', self._type)
self.last_message_id: Optional[int] = utils._get_as_snowflake(data, 'last_message_id') self.last_message_id: Optional[int] = utils._get_as_snowflake(data, 'last_message_id')
self._fill_overwrites(data) self._fill_overwrites(data)
@ -250,6 +256,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
sync_permissions: bool = ..., sync_permissions: bool = ...,
category: Optional[CategoryChannel] = ..., category: Optional[CategoryChannel] = ...,
slowmode_delay: int = ..., slowmode_delay: int = ...,
default_auto_archive_duration: ThreadArchiveDuration = ...,
type: ChannelType = ..., type: ChannelType = ...,
overwrites: Mapping[Union[Role, Member, Snowflake], PermissionOverwrite] = ..., overwrites: Mapping[Union[Role, Member, Snowflake], PermissionOverwrite] = ...,
) -> None: ) -> None:
@ -301,6 +308,9 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
overwrites: :class:`Mapping` overwrites: :class:`Mapping`
A :class:`Mapping` of target (either a role or a member) to A :class:`Mapping` of target (either a role or a member) to
:class:`PermissionOverwrite` to apply to the channel. :class:`PermissionOverwrite` to apply to the channel.
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``.
Raises Raises
------ ------

View File

@ -823,6 +823,7 @@ class HTTPClient:
'archived', 'archived',
'auto_archive_duration', 'auto_archive_duration',
'locked', 'locked',
'default_auto_archive_duration',
) )
payload = {k: v for k, v in options.items() if k in valid_keys} payload = {k: v for k, v in options.items() if k in valid_keys}
return self.request(r, reason=reason, json=payload) return self.request(r, reason=reason, json=payload)

View File

@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
from typing import List, Literal, Optional, TypedDict, Union from typing import List, Literal, Optional, TypedDict, Union
from .user import PartialUser from .user import PartialUser
from .snowflake import Snowflake from .snowflake import Snowflake
from .threads import ThreadMetadata, ThreadMember from .threads import ThreadMetadata, ThreadMember, ThreadArchiveDuration
OverwriteType = Literal[0, 1] OverwriteType = Literal[0, 1]
@ -63,6 +63,7 @@ class _TextChannelOptional(TypedDict, total=False):
last_message_id: Optional[Snowflake] last_message_id: Optional[Snowflake]
last_pin_timestamp: str last_pin_timestamp: str
rate_limit_per_user: int rate_limit_per_user: int
default_auto_archive_duration: ThreadArchiveDuration
class TextChannel(_BaseGuildChannel, _TextChannelOptional): class TextChannel(_BaseGuildChannel, _TextChannelOptional):