aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
Diffstat (limited to 'discord')
-rw-r--r--discord/types/channel.py2
-rw-r--r--discord/types/emoji.py41
-rw-r--r--discord/types/member.py42
-rw-r--r--discord/types/message.py134
-rw-r--r--discord/types/user.py17
5 files changed, 234 insertions, 2 deletions
diff --git a/discord/types/channel.py b/discord/types/channel.py
index 95644392..d9c9f74d 100644
--- a/discord/types/channel.py
+++ b/discord/types/channel.py
@@ -46,7 +46,7 @@ class PartialChannel(TypedDict):
class _TextChannelOptional(PartialChannel, total=False):
topic: str
last_message_id: Optional[Snowflake]
- last_pin_timestamp: int
+ last_pin_timestamp: str
rate_limit_per_user: int
diff --git a/discord/types/emoji.py b/discord/types/emoji.py
new file mode 100644
index 00000000..7c5e4d80
--- /dev/null
+++ b/discord/types/emoji.py
@@ -0,0 +1,41 @@
+"""
+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 Optional, TypedDict
+from .snowflake import Snowflake, SnowflakeList
+from .user import User
+
+
+class PartialEmoji(TypedDict):
+ id: Optional[Snowflake]
+ name: Optional[str]
+
+
+class Emoji(PartialEmoji, total=False):
+ roles: SnowflakeList
+ user: User
+ required_colons: bool
+ managed: bool
+ animated: bool
+ available: bool
diff --git a/discord/types/member.py b/discord/types/member.py
new file mode 100644
index 00000000..4c162ef1
--- /dev/null
+++ b/discord/types/member.py
@@ -0,0 +1,42 @@
+"""
+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 TypedDict
+from .snowflake import SnowflakeList
+from .user import User
+
+
+class PartialMember(TypedDict):
+ roles: SnowflakeList
+ joined_at: str
+ deaf: str
+ mute: str
+
+
+class Member(PartialMember, total=False):
+ user: User
+ nick: str
+ premium_since: str
+ pending: bool
+ permissions: str
diff --git a/discord/types/message.py b/discord/types/message.py
new file mode 100644
index 00000000..8f5de254
--- /dev/null
+++ b/discord/types/message.py
@@ -0,0 +1,134 @@
+"""
+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 __future__ import annotations
+
+from typing import List, Literal, Optional, TypedDict, Union
+from .snowflake import Snowflake, SnowflakeList
+from .member import Member
+from .user import User
+from .emoji import PartialEmoji
+from .embed import Embed
+from .channel import ChannelType
+
+
+class ChannelMention(TypedDict):
+ id: Snowflake
+ guild_id: Snowflake
+ type: ChannelType
+ name: str
+
+
+class Reaction(TypedDict):
+ count: int
+ me: bool
+ emoji: PartialEmoji
+
+
+class Attachment(TypedDict):
+ id: Snowflake
+ filename: str
+ size: int
+ url: str
+ proxy_url: str
+ height: Optional[int]
+ width: Optional[int]
+
+
+MessageActivityType = Literal[1, 2, 3, 5]
+
+
+class MessageActivity(TypedDict):
+ type: MessageActivityType
+ party_id: str
+
+
+class _MessageApplicationOptional(TypedDict, total=False):
+ cover_image: str
+
+
+class MessageApplication(_MessageApplicationOptional):
+ id: Snowflake
+ description: str
+ icon: Optional[str]
+ name: str
+
+
+class MessageReference(TypedDict, total=False):
+ message_id: Snowflake
+ channel_id: Snowflake
+ guild_id: Snowflake
+ fail_if_not_exists: bool
+
+
+class _StickerOptional(TypedDict, total=False):
+ tags: str
+
+
+StickerFormatType = Literal[1, 2, 3]
+
+
+class Sticker(_StickerOptional):
+ id: Snowflake
+ pack_id: Snowflake
+ name: str
+ description: str
+ asset: str
+ preview_asset: str
+ format_type: StickerFormatType
+
+
+class _MessageOptional(TypedDict, total=False):
+ guild_id: Snowflake
+ member: Member
+ mention_channels: List[ChannelMention]
+ reactions: List[Reaction]
+ nonce: Union[int, str]
+ webhook_id: int
+ activity: MessageActivity
+ application: MessageApplication
+ message_reference: MessageReference
+ flags: int
+ stickers: List[Sticker]
+ referenced_message: Optional[Message]
+
+
+MessageType = Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 19, 20]
+
+
+class Message(_MessageOptional):
+ id: Snowflake
+ channel_id: Snowflake
+ author: User
+ content: str
+ timestamp: str
+ edited_timestamp: Optional[str]
+ tts: bool
+ mention_everyone: bool
+ mentions: List[User]
+ mention_roles: SnowflakeList
+ attachments: List[Attachment]
+ embeds: List[Embed]
+ pinned: bool
+ type: MessageType
diff --git a/discord/types/user.py b/discord/types/user.py
index 2951254f..fba5aef5 100644
--- a/discord/types/user.py
+++ b/discord/types/user.py
@@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE.
"""
from .snowflake import Snowflake
-from typing import Optional, TypedDict
+from typing import Literal, Optional, TypedDict
class PartialUser(TypedDict):
@@ -31,3 +31,18 @@ class PartialUser(TypedDict):
username: str
discriminator: str
avatar: Optional[str]
+
+
+PremiumType = Literal[0, 1, 2]
+
+
+class User(PartialUser, total=False):
+ bot: bool
+ system: bool
+ mfa_enabled: bool
+ local: str
+ verified: bool
+ email: Optional[str]
+ flags: int
+ premium_type: PremiumType
+ public_flags: int