Browse Source

[types] Fix types for channels and interactions

pull/7494/head
Rapptz 3 years ago
parent
commit
0b5c3cf256
  1. 5
      discord/types/channel.py
  2. 28
      discord/types/interactions.py

5
discord/types/channel.py

@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
from typing import List, Literal, Optional, TypedDict, Union
from .user import PartialUser
from .snowflake import Snowflake
from .threads import ThreadMetadata, ThreadMember, ThreadArchiveDuration
from .threads import ThreadMetadata, ThreadMember, ThreadArchiveDuration, ThreadType
OverwriteType = Literal[0, 1]
@ -38,7 +38,8 @@ class PermissionOverwrite(TypedDict):
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):

28
discord/types/interactions.py

@ -26,7 +26,9 @@ from __future__ import annotations
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 .message import Attachment
from .role import Role
@ -40,25 +42,29 @@ if TYPE_CHECKING:
InteractionType = Literal[1, 2, 3, 4, 5]
class PartialChannel(TypedDict):
class _BasePartialChannel(TypedDict):
id: Snowflake
name: str
type: ChannelType
permissions: str
class PartialThread(PartialChannel):
class PartialChannel(_BasePartialChannel):
type: ChannelTypeWithoutThread
class PartialThread(_BasePartialChannel):
type: ThreadType
thread_metadata: ThreadMetadata
parent_id: Snowflake
class ResolvedData(TypedDict, total=False):
users: Dict[Snowflake, User]
members: Dict[Snowflake, Member]
roles: Dict[Snowflake, Role]
channels: Dict[Snowflake, Union[PartialChannel, PartialThread]]
messages: Dict[Snowflake, Message]
attachments: Dict[Snowflake, Attachment]
users: Dict[str, User]
members: Dict[str, Member]
roles: Dict[str, Role]
channels: Dict[str, Union[PartialChannel, PartialThread]]
messages: Dict[str, Message]
attachments: Dict[str, Attachment]
class _BaseApplicationCommandInteractionDataOption(TypedDict):
@ -114,7 +120,7 @@ ApplicationCommandInteractionDataOption = Union[
]
class _BaseApplicationCommandInteractionDataOptional(TypedDict):
class _BaseApplicationCommandInteractionDataOptional(TypedDict, total=False):
resolved: ResolvedData

Loading…
Cancel
Save