1
0
mirror of https://github.com/Rapptz/discord.py.git synced 2025-05-09 23:39:50 +00:00

Type-Hint http.py

This commit is contained in:
Josh 2021-06-10 21:34:41 +10:00 committed by GitHub
parent 11e23c534a
commit 35a9533e8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 617 additions and 252 deletions

File diff suppressed because it is too large Load Diff

@ -28,9 +28,12 @@ from .snowflake import Snowflake
from .threads import ThreadMetadata, ThreadMember
OverwriteType = Literal[0, 1]
class PermissionOverwrite(TypedDict):
id: Snowflake
type: Literal[0, 1]
type: OverwriteType
allow: str
deny: str

@ -39,3 +39,8 @@ class Emoji(PartialEmoji, total=False):
managed: bool
animated: bool
available: bool
class EditEmoji(TypedDict):
name: str
roles: Optional[SnowflakeList]

41
discord/types/gateway.py Normal file

@ -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 TypedDict
class SessionStartLimit(TypedDict):
total: int
remaining: int
reset_after: int
max_concurrency: int
class Gateway(TypedDict):
url: str
class GatewayBot(Gateway):
shards: int
session_start_limit: SessionStartLimit

@ -140,3 +140,20 @@ class InviteGuild(Guild, total=False):
class GuildWithCounts(Guild, _GuildPreviewUnique):
...
class GuildPrune(TypedDict):
pruned: Optional[int]
class ChannelPositionUpdate(TypedDict):
id: Snowflake
position: Optional[int]
lock_permissions: Optional[bool]
parent_id: Optional[Snowflake]
class _RolePositionRequired(TypedDict):
id: Snowflake
class RolePositionUpdate(_RolePositionRequired, total=False):
position: Optional[Snowflake]

@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE.
from __future__ import annotations
from typing import TYPE_CHECKING, Dict, TypedDict, Union, List, Literal
from typing import Optional, TYPE_CHECKING, Dict, TypedDict, Union, List, Literal
from .snowflake import Snowflake
from .components import Component, ComponentType
from .embed import Embed
@ -77,11 +77,14 @@ class ApplicationCommandPermissions(TypedDict):
permission: bool
class PartialGuildApplicationCommandPermissions(TypedDict):
id: Snowflake
class BaseGuildApplicationCommandPermissions(TypedDict):
permissions: List[ApplicationCommandPermissions]
class PartialGuildApplicationCommandPermissions(BaseGuildApplicationCommandPermissions):
id: Snowflake
class GuildApplicationCommandPermissions(PartialGuildApplicationCommandPermissions):
application_id: Snowflake
guild_id: Snowflake
@ -95,7 +98,9 @@ class _ApplicationCommandInteractionDataOptionOptional(TypedDict, total=False):
options: List[ApplicationCommandInteractionDataOption]
class ApplicationCommandInteractionDataOption(_ApplicationCommandInteractionDataOptionOptional):
class ApplicationCommandInteractionDataOption(
_ApplicationCommandInteractionDataOptionOptional
):
name: str
type: ApplicationCommandOptionType
@ -149,6 +154,7 @@ class Interaction(_InteractionOptional):
token: str
version: int
class InteractionApplicationCommandCallbackData(TypedDict, total=False):
tts: bool
content: str
@ -174,3 +180,10 @@ class MessageInteraction(TypedDict):
type: InteractionType
name: str
user: User
class EditApplicationCommand(TypedDict):
name: str
description: str
options: Optional[List[ApplicationCommandOption]]
default_permission: bool

@ -52,6 +52,10 @@ class _InviteMetadata(TypedDict, total=False):
expires_at: Optional[str]
class VanityInvite(_InviteMetadata):
code: Optional[str]
class IncompleteInvite(_InviteMetadata):
code: str
channel: PartialChannel

@ -27,6 +27,10 @@ from .snowflake import SnowflakeList
from .user import User
class Nickname(TypedDict):
nick: str
class PartialMember(TypedDict):
roles: SnowflakeList
joined_at: str

@ -30,6 +30,11 @@ from .user import User
from .guild import Guild
class CreateTemplate(TypedDict):
name: str
icon: Optional[bytes]
class Template(TypedDict):
code: str
name: str

@ -27,7 +27,7 @@ from typing import List, Literal, Optional, TypedDict
from .snowflake import Snowflake
ThreadTypes = Literal[10, 11, 12]
ThreadType = Literal[10, 11, 12]
ThreadArchiveDuration = Literal[60, 1440, 4320, 10080]
@ -61,7 +61,7 @@ class Thread(_ThreadOptional):
parent_id: Snowflake
owner_id: Snowflake
name: str
type: ThreadTypes
type: ThreadType
member_count: int
message_count: int
rate_limit_per_user: int