thread docs

This commit is contained in:
grey-cat-1908 2022-04-02 09:09:29 +03:00
parent 1e2e07d2fc
commit 4b12db9008
4 changed files with 105 additions and 5 deletions

View file

@ -89,3 +89,37 @@ UnavailableGuild
.. attributetable:: UnavailableGuild
.. autoclass:: UnavailableGuild()
Thread
------
Thread
~~~~~~
.. attributetable:: Thread
.. autoclass:: Thread()
:exclude-members: start_thread_without_message
:inherited-members:
ThreadMember
~~~~~~~~~~~~~
.. attributetable:: ThreadMember
.. autoclass:: ThreadMember()
:inherited-members:
ThreadMetadata
~~~~~~~~~~~~~
.. attributetable:: ThreadMetadata
.. autoclass:: ThreadMetadata()
:inherited-members:
ThreadsList
~~~~~~~~~~~~~
.. attributetable:: ThreadsList
.. autoclass:: ThreadsList()
:inherited-members:

View file

@ -3,3 +3,4 @@
from .guild import *
from .channel import *
from .thread import *

View file

@ -11,6 +11,7 @@ from typing import List, Any, Optional, AsyncIterator, Union, Dict, overload
from ...utils import Snowflake, Timestamp
from ...utils import APIModelBase
from ...utils.types import APINullable
from .thread import ThreadMember, ThreadMetadata
class ChannelType(IntEnum):
@ -133,7 +134,7 @@ class Channel(APIModelBase):
The camera video quality mode of the voice channel, 1 when not present
message_count: :class:`int`
An approximate count of messages in a thread, stops counting at 50
thread_metadata: :class:`typing.Any`
thread_metadata: :class:`~melisa.models.guild.thread.ThreadMetadata`
Thread-specific fields not needed by other channels
member: :class:`typing.Any`
Thread member object for the current user,
@ -169,7 +170,7 @@ class Channel(APIModelBase):
video_quality_mode: APINullable[int] = None
message_count: APINullable[int] = None
member_count: APINullable[int] = None
thread_metadata: APINullable[List] = None
thread_metadata: APINullable[ThreadMetadata] = None
member: APINullable[List] = None
default_auto_archive_duration: APINullable[int] = None
permissions: APINullable[str] = None
@ -252,8 +253,7 @@ class MessageableChannel(Channel):
"""|coro|
Creates a new thread that is not connected to an existing message.
The created thread defaults to a ``GUILD_PRIVATE_THREAD``*.
Returns a Channel on success.
The created thread defaults to a ``GUILD_PRIVATE_THREAD``.
Creating a private thread requires the server to be boosted.
The guild features will indicate if that is possible for the guild.
@ -645,7 +645,7 @@ class ThreadsList(APIModelBase):
"""
threads: List[Thread]
members: List
members: List[ThreadMember]
has_more: APINullable[bool] = None

View file

@ -0,0 +1,65 @@
# Copyright MelisaDev 2022 - Present
# Full MIT License can be found in `LICENSE.txt` at the project root.
from __future__ import annotations
from dataclasses import dataclass
from ...utils.api_model import APIModelBase
from ...utils.types import APINullable
from ...utils.snowflake import Snowflake
from ...utils.timestamp import Timestamp
@dataclass(repr=False)
class ThreadMetadata(APIModelBase):
"""
Represents a Discord Thread Metadata object
Attributes
----------
archived: :class:`bool`
Whether the thread is archived
auto_archive_duration: :class:`int`
Duration in minutes to automatically archive the thread after recent activity,
can be set to: 60, 1440, 4320, 10080
archive_timestamp: :class:`~melisa.utils.timestamp.Timestamp`
Timestamp when the thread's archive status was last changed,
used for calculating recent activity
locked: :class:`bool`
Whether the thread is locked; when a thread is locked,
only users with ``MANAGE_THREADS`` can unarchive it
invitable: Optional[:class:`bool`]
Whether non-moderators can add other non-moderators to a thread;
only available on private threads
create_timestamp: Optional[:class:`~melisa.utils.timestamp.Timestamp`]
Timestamp when the thread was created; only populated for threads created after 2022-01-09
"""
archived: bool
auto_archive_duration: int
archive_timestamp: Timestamp
locked: bool
invitable: APINullable[bool] = None
create_timestamp: APINullable[Timestamp] = None
@dataclass(repr=False)
class ThreadMember(APIModelBase):
"""Represents a Discord Thread Member object
Attributes
----------
id: Optional[:class:`~melisa.utils.snowflake.Snowflake`]
The id of the thread
user_id: Optional[:class:`~melisa.utils.snowflake.Snowflake`]
The id of the user
join_timestamp: :class:`~melisa.utils.timestamp.Timestamp`
The time the current user last joined the thread
flags: :class:`int`
Any user-thread settings, currently only used for notifications
"""
join_timestamp: Timestamp
flags: int
id: APINullable[Snowflake] = None
user_id: APINullable[Snowflake] = None