list active threads guild method

This commit is contained in:
grey-cat-1908 2022-04-02 08:40:54 +03:00
parent 530e65a2c3
commit 1e2e07d2fc
2 changed files with 28 additions and 2 deletions

View file

@ -646,7 +646,7 @@ class ThreadsList(APIModelBase):
threads: List[Thread]
members: List
has_more: Optional[bool]
has_more: APINullable[bool] = None
# noinspection PyTypeChecker

View file

@ -7,7 +7,7 @@ from dataclasses import dataclass
from enum import IntEnum, Enum
from typing import List, Any, Optional, overload
from .channel import Channel, ChannelType, channel_types_for_converting
from .channel import Channel, ChannelType, channel_types_for_converting, ThreadsList
from ...utils import Snowflake, Timestamp
from ...utils import APIModelBase
from ...utils.types import APINullable
@ -219,6 +219,8 @@ class GuildFeatures(Enum):
Guild has access to set 384kbps bitrate in voice (previously VIP voice servers)
WELCOME_SCREEN_ENABLED:
Guild has enabled the welcome screen
EXPOSED_TO_ACTIVITIES_WTP_EXPERIMENT:
Unkown. Found during testing. Not listed in Discord API docs.
"""
ANIMATED_ICON = "ANIMATED_ICON"
@ -510,6 +512,30 @@ class Guild(APIModelBase):
channel_cls = channel_types_for_converting.get(data["type"], Channel)
return channel_cls.from_dict(data)
async def active_threads(self) -> ThreadsList:
"""|coro|
Returns a Threadslist of active ``Thread`` that the client can access.
This includes both private and public threads.
Raises
-------
HTTPException
The request to perform the action failed with other http exception.
Returns
-------
:class:`~melisa.models.channel.ThreadsList`
The active threads.
"""
return ThreadsList.from_dict(
await self._http.get(
f"/guilds/{self.id}/threads/active"
)
)
@dataclass(repr=False)
class UnavailableGuild(APIModelBase):