From 87e64dff0627abb460d2d1d71ea272d224c38add Mon Sep 17 00:00:00 2001
From: Nadir Chowdhury <chowdhurynadir0@outlook.com>
Date: Wed, 7 Apr 2021 12:56:56 +0100
Subject: [PATCH] Add typings for channels and `PartialUser`

---
 discord/types/channel.py   | 91 ++++++++++++++++++++++++++++++++++++++
 discord/types/snowflake.py | 28 ++++++++++++
 discord/types/user.py      | 33 ++++++++++++++
 3 files changed, 152 insertions(+)
 create mode 100644 discord/types/channel.py
 create mode 100644 discord/types/snowflake.py
 create mode 100644 discord/types/user.py

diff --git a/discord/types/channel.py b/discord/types/channel.py
new file mode 100644
index 000000000..95644392c
--- /dev/null
+++ b/discord/types/channel.py
@@ -0,0 +1,91 @@
+"""
+The MIT License (MIT)
+
+Copyright (c) 2015-present Rapptz
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+"""
+
+from .user import PartialUser
+from .snowflake import Snowflake
+from typing import List, Literal, Optional, TypedDict
+
+
+class PermissionOverwrite(TypedDict):
+    id: Snowflake
+    type: Literal[0, 1]
+    allow: str
+    deny: str
+
+
+ChannelType = Literal[0, 1, 2, 3, 4, 5, 6, 13]
+
+
+class PartialChannel(TypedDict):
+    id: str
+    type: ChannelType
+    name: str
+
+
+class _TextChannelOptional(PartialChannel, total=False):
+    topic: str
+    last_message_id: Optional[Snowflake]
+    last_pin_timestamp: int
+    rate_limit_per_user: int
+
+
+class _VoiceChannelOptional(PartialChannel, total=False):
+    rtc_region: Optional[str]
+    bitrate: int
+    user_limit: int
+
+
+class _CategoryChannelOptional(PartialChannel, total=False):
+    ...
+
+
+class _StoreChannelOptional(PartialChannel, total=False):
+    ...
+
+
+class _StageChannelOptional(PartialChannel, total=False):
+    rtc_region: Optional[str]
+    bitrate: int
+    user_limit: int
+    topic: str
+
+
+class GuildChannel(
+    _TextChannelOptional, _VoiceChannelOptional, _CategoryChannelOptional, _StoreChannelOptional, _StageChannelOptional
+):
+    guild_id: Snowflake
+    position: int
+    permission_overwrites: List[PermissionOverwrite]
+    nsfw: bool
+    parent_id: Optional[Snowflake]
+
+
+class DMChannel(PartialChannel):
+    last_message_id: Optional[Snowflake]
+    recipients: List[PartialUser]
+
+
+class GroupDMChannel(DMChannel):
+    icon: Optional[str]
+    owner_id: Snowflake
diff --git a/discord/types/snowflake.py b/discord/types/snowflake.py
new file mode 100644
index 000000000..341bd7670
--- /dev/null
+++ b/discord/types/snowflake.py
@@ -0,0 +1,28 @@
+"""
+The MIT License (MIT)
+
+Copyright (c) 2015-present Rapptz
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+"""
+
+from typing import List
+
+Snowflake = str
+SnowflakeList = List[Snowflake]
diff --git a/discord/types/user.py b/discord/types/user.py
new file mode 100644
index 000000000..2951254fa
--- /dev/null
+++ b/discord/types/user.py
@@ -0,0 +1,33 @@
+"""
+The MIT License (MIT)
+
+Copyright (c) 2015-present Rapptz
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+"""
+
+from .snowflake import Snowflake
+from typing import Optional, TypedDict
+
+
+class PartialUser(TypedDict):
+    id: Snowflake
+    username: str
+    discriminator: str
+    avatar: Optional[str]