mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-08 04:38:42 +00:00
[types] Fix types for channels and interactions
This commit is contained in:
parent
e13997f35e
commit
0b5c3cf256
@ -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, ThreadArchiveDuration
|
from .threads import ThreadMetadata, ThreadMember, ThreadArchiveDuration, ThreadType
|
||||||
|
|
||||||
|
|
||||||
OverwriteType = Literal[0, 1]
|
OverwriteType = Literal[0, 1]
|
||||||
@ -38,7 +38,8 @@ class PermissionOverwrite(TypedDict):
|
|||||||
deny: str
|
deny: str
|
||||||
|
|
||||||
|
|
||||||
ChannelType = Literal[0, 1, 2, 3, 4, 5, 6, 10, 11, 12, 13]
|
ChannelTypeWithoutThread = Literal[0, 1, 2, 3, 4, 5, 6, 13]
|
||||||
|
ChannelType = Union[ChannelTypeWithoutThread, ThreadType]
|
||||||
|
|
||||||
|
|
||||||
class _BaseChannel(TypedDict):
|
class _BaseChannel(TypedDict):
|
||||||
|
@ -26,7 +26,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING, Dict, List, Literal, TypedDict, Union
|
from typing import TYPE_CHECKING, Dict, List, Literal, TypedDict, Union
|
||||||
|
|
||||||
from .channel import ChannelType, ThreadMetadata
|
|
||||||
|
from .channel import ChannelType, ChannelTypeWithoutThread, ThreadMetadata
|
||||||
|
from .threads import ThreadType
|
||||||
from .member import Member
|
from .member import Member
|
||||||
from .message import Attachment
|
from .message import Attachment
|
||||||
from .role import Role
|
from .role import Role
|
||||||
@ -40,25 +42,29 @@ if TYPE_CHECKING:
|
|||||||
InteractionType = Literal[1, 2, 3, 4, 5]
|
InteractionType = Literal[1, 2, 3, 4, 5]
|
||||||
|
|
||||||
|
|
||||||
class PartialChannel(TypedDict):
|
class _BasePartialChannel(TypedDict):
|
||||||
id: Snowflake
|
id: Snowflake
|
||||||
name: str
|
name: str
|
||||||
type: ChannelType
|
|
||||||
permissions: str
|
permissions: str
|
||||||
|
|
||||||
|
|
||||||
class PartialThread(PartialChannel):
|
class PartialChannel(_BasePartialChannel):
|
||||||
|
type: ChannelTypeWithoutThread
|
||||||
|
|
||||||
|
|
||||||
|
class PartialThread(_BasePartialChannel):
|
||||||
|
type: ThreadType
|
||||||
thread_metadata: ThreadMetadata
|
thread_metadata: ThreadMetadata
|
||||||
parent_id: Snowflake
|
parent_id: Snowflake
|
||||||
|
|
||||||
|
|
||||||
class ResolvedData(TypedDict, total=False):
|
class ResolvedData(TypedDict, total=False):
|
||||||
users: Dict[Snowflake, User]
|
users: Dict[str, User]
|
||||||
members: Dict[Snowflake, Member]
|
members: Dict[str, Member]
|
||||||
roles: Dict[Snowflake, Role]
|
roles: Dict[str, Role]
|
||||||
channels: Dict[Snowflake, Union[PartialChannel, PartialThread]]
|
channels: Dict[str, Union[PartialChannel, PartialThread]]
|
||||||
messages: Dict[Snowflake, Message]
|
messages: Dict[str, Message]
|
||||||
attachments: Dict[Snowflake, Attachment]
|
attachments: Dict[str, Attachment]
|
||||||
|
|
||||||
|
|
||||||
class _BaseApplicationCommandInteractionDataOption(TypedDict):
|
class _BaseApplicationCommandInteractionDataOption(TypedDict):
|
||||||
@ -114,7 +120,7 @@ ApplicationCommandInteractionDataOption = Union[
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class _BaseApplicationCommandInteractionDataOptional(TypedDict):
|
class _BaseApplicationCommandInteractionDataOptional(TypedDict, total=False):
|
||||||
resolved: ResolvedData
|
resolved: ResolvedData
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user