Browse Source

Type-Hint http.py

pull/7040/head
Josh 4 years ago
committed by GitHub
parent
commit
35a9533e8d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 763
      discord/http.py
  2. 5
      discord/types/channel.py
  3. 5
      discord/types/emoji.py
  4. 41
      discord/types/gateway.py
  5. 17
      discord/types/guild.py
  6. 21
      discord/types/interactions.py
  7. 4
      discord/types/invite.py
  8. 4
      discord/types/member.py
  9. 5
      discord/types/template.py
  10. 4
      discord/types/threads.py

763
discord/http.py

File diff suppressed because it is too large

5
discord/types/channel.py

@ -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

5
discord/types/emoji.py

@ -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

@ -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

17
discord/types/guild.py

@ -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]

21
discord/types/interactions.py

@ -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

4
discord/types/invite.py

@ -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

4
discord/types/member.py

@ -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

5
discord/types/template.py

@ -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

4
discord/types/threads.py

@ -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

Loading…
Cancel
Save