mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 08:56:19 +00:00
Use typing.Literal for channel and component type annotation
This commit is contained in:
committed by
GitHub
parent
7fca030107
commit
7ee15e1d68
@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, Dict, Iterable, List, Optional, Union, TYPE_CHECKING
|
||||
from typing import Callable, Dict, Iterable, List, Literal, Optional, Union, TYPE_CHECKING
|
||||
from datetime import datetime
|
||||
|
||||
from .mixins import Hashable
|
||||
@ -58,6 +58,8 @@ if TYPE_CHECKING:
|
||||
from .permissions import Permissions
|
||||
from .state import ConnectionState
|
||||
|
||||
ThreadChannelType = Literal[ChannelType.news_thread, ChannelType.public_thread, ChannelType.private_thread]
|
||||
|
||||
|
||||
class Thread(Messageable, Hashable):
|
||||
"""Represents a Discord thread.
|
||||
@ -172,7 +174,7 @@ class Thread(Messageable, Hashable):
|
||||
self.parent_id: int = int(data['parent_id'])
|
||||
self.owner_id: int = int(data['owner_id'])
|
||||
self.name: str = data['name']
|
||||
self._type: ChannelType = try_enum(ChannelType, data['type'])
|
||||
self._type: ThreadChannelType = try_enum(ChannelType, data['type']) # type: ignore
|
||||
self.last_message_id: Optional[int] = _get_as_snowflake(data, 'last_message_id')
|
||||
self.slowmode_delay: int = data.get('rate_limit_per_user', 0)
|
||||
self.message_count: int = data['message_count']
|
||||
@ -211,7 +213,7 @@ class Thread(Messageable, Hashable):
|
||||
pass
|
||||
|
||||
@property
|
||||
def type(self) -> ChannelType:
|
||||
def type(self) -> ThreadChannelType:
|
||||
""":class:`ChannelType`: The channel's Discord type."""
|
||||
return self._type
|
||||
|
||||
|
Reference in New Issue
Block a user