mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 16:32:59 +00:00
[types] Refactor and add Application Command types
This commit is contained in:
@@ -25,7 +25,6 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from typing import (
|
from typing import (
|
||||||
@@ -68,6 +67,7 @@ if TYPE_CHECKING:
|
|||||||
appinfo,
|
appinfo,
|
||||||
audit_log,
|
audit_log,
|
||||||
channel,
|
channel,
|
||||||
|
command,
|
||||||
components,
|
components,
|
||||||
emoji,
|
emoji,
|
||||||
embed,
|
embed,
|
||||||
@@ -1699,12 +1699,12 @@ class HTTPClient:
|
|||||||
|
|
||||||
# Application commands (global)
|
# Application commands (global)
|
||||||
|
|
||||||
def get_global_commands(self, application_id: Snowflake) -> Response[List[interactions.ApplicationCommand]]:
|
def get_global_commands(self, application_id: Snowflake) -> Response[List[command.ApplicationCommand]]:
|
||||||
return self.request(Route('GET', '/applications/{application_id}/commands', application_id=application_id))
|
return self.request(Route('GET', '/applications/{application_id}/commands', application_id=application_id))
|
||||||
|
|
||||||
def get_global_command(
|
def get_global_command(
|
||||||
self, application_id: Snowflake, command_id: Snowflake
|
self, application_id: Snowflake, command_id: Snowflake
|
||||||
) -> Response[interactions.ApplicationCommand]:
|
) -> Response[command.ApplicationCommand]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'GET',
|
'GET',
|
||||||
'/applications/{application_id}/commands/{command_id}',
|
'/applications/{application_id}/commands/{command_id}',
|
||||||
@@ -1713,7 +1713,7 @@ class HTTPClient:
|
|||||||
)
|
)
|
||||||
return self.request(r)
|
return self.request(r)
|
||||||
|
|
||||||
def upsert_global_command(self, application_id: Snowflake, payload) -> Response[interactions.ApplicationCommand]:
|
def upsert_global_command(self, application_id: Snowflake, payload) -> Response[command.ApplicationCommand]:
|
||||||
r = Route('POST', '/applications/{application_id}/commands', application_id=application_id)
|
r = Route('POST', '/applications/{application_id}/commands', application_id=application_id)
|
||||||
return self.request(r, json=payload)
|
return self.request(r, json=payload)
|
||||||
|
|
||||||
@@ -1721,8 +1721,8 @@ class HTTPClient:
|
|||||||
self,
|
self,
|
||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
command_id: Snowflake,
|
command_id: Snowflake,
|
||||||
payload: interactions.EditApplicationCommand,
|
payload: Dict[str, Any],
|
||||||
) -> Response[interactions.ApplicationCommand]:
|
) -> Response[command.ApplicationCommand]:
|
||||||
valid_keys = (
|
valid_keys = (
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
@@ -1748,7 +1748,7 @@ class HTTPClient:
|
|||||||
|
|
||||||
def bulk_upsert_global_commands(
|
def bulk_upsert_global_commands(
|
||||||
self, application_id: Snowflake, payload
|
self, application_id: Snowflake, payload
|
||||||
) -> Response[List[interactions.ApplicationCommand]]:
|
) -> Response[List[command.ApplicationCommand]]:
|
||||||
r = Route('PUT', '/applications/{application_id}/commands', application_id=application_id)
|
r = Route('PUT', '/applications/{application_id}/commands', application_id=application_id)
|
||||||
return self.request(r, json=payload)
|
return self.request(r, json=payload)
|
||||||
|
|
||||||
@@ -1756,7 +1756,7 @@ class HTTPClient:
|
|||||||
|
|
||||||
def get_guild_commands(
|
def get_guild_commands(
|
||||||
self, application_id: Snowflake, guild_id: Snowflake
|
self, application_id: Snowflake, guild_id: Snowflake
|
||||||
) -> Response[List[interactions.ApplicationCommand]]:
|
) -> Response[List[command.ApplicationCommand]]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'GET',
|
'GET',
|
||||||
'/applications/{application_id}/guilds/{guild_id}/commands',
|
'/applications/{application_id}/guilds/{guild_id}/commands',
|
||||||
@@ -1770,7 +1770,7 @@ class HTTPClient:
|
|||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
command_id: Snowflake,
|
command_id: Snowflake,
|
||||||
) -> Response[interactions.ApplicationCommand]:
|
) -> Response[command.ApplicationCommand]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'GET',
|
'GET',
|
||||||
'/applications/{application_id}/guilds/{guild_id}/commands/{command_id}',
|
'/applications/{application_id}/guilds/{guild_id}/commands/{command_id}',
|
||||||
@@ -1784,8 +1784,8 @@ class HTTPClient:
|
|||||||
self,
|
self,
|
||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
payload: interactions.EditApplicationCommand,
|
payload: Dict[str, Any],
|
||||||
) -> Response[interactions.ApplicationCommand]:
|
) -> Response[command.ApplicationCommand]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'POST',
|
'POST',
|
||||||
'/applications/{application_id}/guilds/{guild_id}/commands',
|
'/applications/{application_id}/guilds/{guild_id}/commands',
|
||||||
@@ -1799,8 +1799,8 @@ class HTTPClient:
|
|||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
command_id: Snowflake,
|
command_id: Snowflake,
|
||||||
payload: interactions.EditApplicationCommand,
|
payload: Dict[str, Any],
|
||||||
) -> Response[interactions.ApplicationCommand]:
|
) -> Response[command.ApplicationCommand]:
|
||||||
valid_keys = (
|
valid_keys = (
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
@@ -1835,8 +1835,8 @@ class HTTPClient:
|
|||||||
self,
|
self,
|
||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
payload: List[interactions.EditApplicationCommand],
|
payload: List[Dict[str, Any]],
|
||||||
) -> Response[List[interactions.ApplicationCommand]]:
|
) -> Response[List[command.ApplicationCommand]]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'PUT',
|
'PUT',
|
||||||
'/applications/{application_id}/guilds/{guild_id}/commands',
|
'/applications/{application_id}/guilds/{guild_id}/commands',
|
||||||
@@ -1889,7 +1889,7 @@ class HTTPClient:
|
|||||||
token: str,
|
token: str,
|
||||||
*,
|
*,
|
||||||
type: InteractionResponseType,
|
type: InteractionResponseType,
|
||||||
data: Optional[interactions.InteractionApplicationCommandCallbackData] = None,
|
data: Optional[Dict[str, Any]] = None,
|
||||||
) -> Response[None]:
|
) -> Response[None]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'POST',
|
'POST',
|
||||||
@@ -2003,7 +2003,7 @@ class HTTPClient:
|
|||||||
self,
|
self,
|
||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
) -> Response[List[interactions.GuildApplicationCommandPermissions]]:
|
) -> Response[List[command.GuildApplicationCommandPermissions]]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'GET',
|
'GET',
|
||||||
'/applications/{application_id}/guilds/{guild_id}/commands/permissions',
|
'/applications/{application_id}/guilds/{guild_id}/commands/permissions',
|
||||||
@@ -2017,7 +2017,7 @@ class HTTPClient:
|
|||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
command_id: Snowflake,
|
command_id: Snowflake,
|
||||||
) -> Response[interactions.GuildApplicationCommandPermissions]:
|
) -> Response[command.GuildApplicationCommandPermissions]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'GET',
|
'GET',
|
||||||
'/applications/{application_id}/guilds/{guild_id}/commands/{command_id}/permissions',
|
'/applications/{application_id}/guilds/{guild_id}/commands/{command_id}/permissions',
|
||||||
@@ -2032,7 +2032,7 @@ class HTTPClient:
|
|||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
command_id: Snowflake,
|
command_id: Snowflake,
|
||||||
payload: interactions.BaseGuildApplicationCommandPermissions,
|
payload: Dict[str, Any],
|
||||||
) -> Response[None]:
|
) -> Response[None]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'PUT',
|
'PUT',
|
||||||
@@ -2047,7 +2047,7 @@ class HTTPClient:
|
|||||||
self,
|
self,
|
||||||
application_id: Snowflake,
|
application_id: Snowflake,
|
||||||
guild_id: Snowflake,
|
guild_id: Snowflake,
|
||||||
payload: List[interactions.PartialGuildApplicationCommandPermissions],
|
payload: List[Dict[str, Any]],
|
||||||
) -> Response[None]:
|
) -> Response[None]:
|
||||||
r = Route(
|
r = Route(
|
||||||
'PUT',
|
'PUT',
|
||||||
|
220
discord/types/command.py
Normal file
220
discord/types/command.py
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
"""
|
||||||
|
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, TypedDict, Union
|
||||||
|
|
||||||
|
from discord.types.channel import ChannelType
|
||||||
|
from discord.types.snowflake import Snowflake
|
||||||
|
|
||||||
|
ApplicationCommandType = Literal[1, 2, 3]
|
||||||
|
ApplicationCommandOptionType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseApplicationCommandOption(TypedDict):
|
||||||
|
name: str
|
||||||
|
description: str
|
||||||
|
|
||||||
|
|
||||||
|
class _SubCommandCommandOption(_BaseApplicationCommandOption):
|
||||||
|
type: Literal[1]
|
||||||
|
options: List[_ValueApplicationCommandOption]
|
||||||
|
|
||||||
|
|
||||||
|
class _SubCommandGroupCommandOption(_BaseApplicationCommandOption):
|
||||||
|
type: Literal[2]
|
||||||
|
options: List[_SubCommandCommandOption]
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseValueApplicationCommandOption(_BaseApplicationCommandOption, total=False):
|
||||||
|
required: bool
|
||||||
|
|
||||||
|
|
||||||
|
class _StringApplicationCommandOptionChoice(TypedDict, total=False):
|
||||||
|
name: str
|
||||||
|
value: str
|
||||||
|
|
||||||
|
|
||||||
|
class _StringApplicationCommandOptionOptional(_BaseValueApplicationCommandOption, total=False):
|
||||||
|
choices: List[_StringApplicationCommandOptionChoice]
|
||||||
|
autocomplete: bool
|
||||||
|
|
||||||
|
|
||||||
|
class _StringApplicationCommandOption(_StringApplicationCommandOptionOptional):
|
||||||
|
type: Literal[3]
|
||||||
|
|
||||||
|
|
||||||
|
class _IntegerApplicationCommandOptionChoice(TypedDict, total=False):
|
||||||
|
name: str
|
||||||
|
value: int
|
||||||
|
|
||||||
|
|
||||||
|
class _IntegerApplicationCommandOptionOptional(_BaseValueApplicationCommandOption, total=False):
|
||||||
|
min_value: int
|
||||||
|
max_value: int
|
||||||
|
choices: List[_IntegerApplicationCommandOptionChoice]
|
||||||
|
autocomplete: bool
|
||||||
|
|
||||||
|
|
||||||
|
class _IntegerApplicationCommandOption(_IntegerApplicationCommandOptionOptional):
|
||||||
|
type: Literal[4]
|
||||||
|
|
||||||
|
|
||||||
|
class _BooleanApplicationCommandOption(_BaseValueApplicationCommandOption):
|
||||||
|
type: Literal[5]
|
||||||
|
|
||||||
|
|
||||||
|
class _ChannelApplicationCommandOptionChoiceOptional(_BaseApplicationCommandOption, total=False):
|
||||||
|
channel_types: List[ChannelType]
|
||||||
|
|
||||||
|
|
||||||
|
class _ChannelApplicationCommandOptionChoice(_ChannelApplicationCommandOptionChoiceOptional):
|
||||||
|
type: Literal[7]
|
||||||
|
|
||||||
|
|
||||||
|
class _NonChannelSnowflakeApplicationCommandOptionChoice(_BaseValueApplicationCommandOption):
|
||||||
|
type: Literal[6, 8, 9, 11]
|
||||||
|
|
||||||
|
|
||||||
|
_SnowflakeApplicationCommandOptionChoice = Union[
|
||||||
|
_ChannelApplicationCommandOptionChoice,
|
||||||
|
_NonChannelSnowflakeApplicationCommandOptionChoice,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class _NumberApplicationCommandOptionChoice(TypedDict, total=False):
|
||||||
|
name: str
|
||||||
|
value: float
|
||||||
|
|
||||||
|
|
||||||
|
class _NumberApplicationCommandOptionOptional(_BaseValueApplicationCommandOption, total=False):
|
||||||
|
min_value: float
|
||||||
|
max_value: float
|
||||||
|
choices: List[_NumberApplicationCommandOptionChoice]
|
||||||
|
autocomplete: bool
|
||||||
|
|
||||||
|
|
||||||
|
class _NumberApplicationCommandOption(_NumberApplicationCommandOptionOptional):
|
||||||
|
type: Literal[10]
|
||||||
|
|
||||||
|
|
||||||
|
_ValueApplicationCommandOption = Union[
|
||||||
|
_StringApplicationCommandOption,
|
||||||
|
_IntegerApplicationCommandOption,
|
||||||
|
_BooleanApplicationCommandOption,
|
||||||
|
_SnowflakeApplicationCommandOptionChoice,
|
||||||
|
_NumberApplicationCommandOption,
|
||||||
|
]
|
||||||
|
|
||||||
|
ApplicationCommandOption = Union[
|
||||||
|
_SubCommandGroupCommandOption,
|
||||||
|
_SubCommandCommandOption,
|
||||||
|
_ValueApplicationCommandOption,
|
||||||
|
]
|
||||||
|
|
||||||
|
ApplicationCommandOptionChoice = Union[
|
||||||
|
_StringApplicationCommandOptionChoice,
|
||||||
|
_IntegerApplicationCommandOptionChoice,
|
||||||
|
_NumberApplicationCommandOptionChoice,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseApplicationCommand(TypedDict):
|
||||||
|
id: Snowflake
|
||||||
|
application_id: Snowflake
|
||||||
|
name: str
|
||||||
|
version: Snowflake
|
||||||
|
|
||||||
|
|
||||||
|
class _ChatInputApplicationCommandOptional(_BaseApplicationCommand, total=False):
|
||||||
|
type: Literal[1]
|
||||||
|
options: Union[
|
||||||
|
List[_ValueApplicationCommandOption],
|
||||||
|
List[Union[_SubCommandCommandOption, _SubCommandGroupCommandOption]],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class _ChatInputApplicationCommand(_ChatInputApplicationCommandOptional):
|
||||||
|
description: str
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseContextMenuApplicationCommand(_BaseApplicationCommand):
|
||||||
|
description: Literal[""]
|
||||||
|
|
||||||
|
|
||||||
|
class _UserApplicationCommand(_BaseContextMenuApplicationCommand):
|
||||||
|
type: Literal[2]
|
||||||
|
|
||||||
|
|
||||||
|
class _MessageApplicationCommand(_BaseContextMenuApplicationCommand):
|
||||||
|
type: Literal[3]
|
||||||
|
|
||||||
|
|
||||||
|
GlobalApplicationCommand = Union[
|
||||||
|
_ChatInputApplicationCommand,
|
||||||
|
_UserApplicationCommand,
|
||||||
|
_MessageApplicationCommand,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class _GuildChatInputApplicationCommand(_ChatInputApplicationCommand):
|
||||||
|
guild_id: Snowflake
|
||||||
|
|
||||||
|
|
||||||
|
class _GuildUserApplicationCommand(_UserApplicationCommand):
|
||||||
|
guild_id: Snowflake
|
||||||
|
|
||||||
|
|
||||||
|
class _GuildMessageApplicationCommand(_MessageApplicationCommand):
|
||||||
|
guild_id: Snowflake
|
||||||
|
|
||||||
|
|
||||||
|
GuildApplicationCommand = Union[
|
||||||
|
_GuildChatInputApplicationCommand,
|
||||||
|
_GuildUserApplicationCommand,
|
||||||
|
_GuildMessageApplicationCommand,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
ApplicationCommand = Union[
|
||||||
|
GlobalApplicationCommand,
|
||||||
|
GuildApplicationCommand,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
ApplicationCommandPermissionType = Literal[1, 2]
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicationCommandPermissions(TypedDict):
|
||||||
|
id: Snowflake
|
||||||
|
type: ApplicationCommandPermissionType
|
||||||
|
permission: bool
|
||||||
|
|
||||||
|
|
||||||
|
class GuildApplicationCommandPermissions(TypedDict):
|
||||||
|
id: Snowflake
|
||||||
|
application_id: Snowflake
|
||||||
|
guild_id: Snowflake
|
||||||
|
permissions: List[ApplicationCommandPermissions]
|
@@ -24,195 +24,206 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional, TYPE_CHECKING, Dict, TypedDict, Union, List, Literal
|
from typing import TYPE_CHECKING, Dict, List, Literal, TypedDict, Union
|
||||||
from .snowflake import Snowflake
|
|
||||||
from .components import Component, ComponentType
|
from .channel import ChannelType, ThreadMetadata
|
||||||
from .embed import Embed
|
|
||||||
from .channel import ChannelType
|
|
||||||
from .member import Member
|
from .member import Member
|
||||||
|
from .message import Attachment
|
||||||
from .role import Role
|
from .role import Role
|
||||||
|
from .snowflake import Snowflake
|
||||||
from .user import User
|
from .user import User
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .message import AllowedMentions, Message
|
from .message import Message
|
||||||
|
|
||||||
|
|
||||||
ApplicationCommandType = Literal[1, 2, 3]
|
InteractionType = Literal[1, 2, 3, 4, 5]
|
||||||
|
|
||||||
class _ApplicationCommandOptional(TypedDict, total=False):
|
|
||||||
options: List[ApplicationCommandOption]
|
|
||||||
type: ApplicationCommandType
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommand(_ApplicationCommandOptional):
|
class PartialChannel(TypedDict):
|
||||||
id: Snowflake
|
id: Snowflake
|
||||||
application_id: Snowflake
|
|
||||||
name: str
|
name: str
|
||||||
description: str
|
type: ChannelType
|
||||||
|
permissions: str
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandOptionOptional(TypedDict, total=False):
|
class PartialThread(PartialChannel):
|
||||||
choices: List[ApplicationCommandOptionChoice]
|
thread_metadata: ThreadMetadata
|
||||||
options: List[ApplicationCommandOption]
|
parent_id: Snowflake
|
||||||
|
|
||||||
|
|
||||||
ApplicationCommandOptionType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
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]
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommandOption(_ApplicationCommandOptionOptional):
|
class _BaseApplicationCommandInteractionDataOption(TypedDict):
|
||||||
type: ApplicationCommandOptionType
|
|
||||||
name: str
|
|
||||||
description: str
|
|
||||||
required: bool
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommandOptionChoice(TypedDict):
|
|
||||||
name: str
|
|
||||||
value: Union[str, int]
|
|
||||||
|
|
||||||
|
|
||||||
ApplicationCommandPermissionType = Literal[1, 2]
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommandPermissions(TypedDict):
|
|
||||||
id: Snowflake
|
|
||||||
type: ApplicationCommandPermissionType
|
|
||||||
permission: bool
|
|
||||||
|
|
||||||
|
|
||||||
class BaseGuildApplicationCommandPermissions(TypedDict):
|
|
||||||
permissions: List[ApplicationCommandPermissions]
|
|
||||||
|
|
||||||
|
|
||||||
class PartialGuildApplicationCommandPermissions(BaseGuildApplicationCommandPermissions):
|
|
||||||
id: Snowflake
|
|
||||||
|
|
||||||
|
|
||||||
class GuildApplicationCommandPermissions(PartialGuildApplicationCommandPermissions):
|
|
||||||
application_id: Snowflake
|
|
||||||
guild_id: Snowflake
|
|
||||||
|
|
||||||
|
|
||||||
InteractionType = Literal[1, 2, 3]
|
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOption(TypedDict):
|
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOptionSubcommand(_ApplicationCommandInteractionDataOption):
|
class _CommandGroupApplicationCommandInteractionDataOption(_BaseApplicationCommandInteractionDataOption):
|
||||||
type: Literal[1, 2]
|
type: Literal[1, 2]
|
||||||
options: List[ApplicationCommandInteractionDataOption]
|
options: List[ApplicationCommandInteractionDataOption]
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOptionString(_ApplicationCommandInteractionDataOption):
|
class _BaseValueApplicationCommandInteractionDataOption(_BaseApplicationCommandInteractionDataOption, total=False):
|
||||||
|
focused: bool
|
||||||
|
|
||||||
|
|
||||||
|
class _StringValueApplicationCommandInteractionDataOption(_BaseValueApplicationCommandInteractionDataOption):
|
||||||
type: Literal[3]
|
type: Literal[3]
|
||||||
value: str
|
value: str
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOptionInteger(_ApplicationCommandInteractionDataOption):
|
class _IntegerValueApplicationCommandInteractionDataOption(_BaseValueApplicationCommandInteractionDataOption):
|
||||||
type: Literal[4]
|
type: Literal[4]
|
||||||
value: int
|
value: int
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOptionBoolean(_ApplicationCommandInteractionDataOption):
|
class _BooleanValueApplicationCommandInteractionDataOption(_BaseValueApplicationCommandInteractionDataOption):
|
||||||
type: Literal[5]
|
type: Literal[5]
|
||||||
value: bool
|
value: bool
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOptionSnowflake(_ApplicationCommandInteractionDataOption):
|
class _SnowflakeValueApplicationCommandInteractionDataOption(_BaseValueApplicationCommandInteractionDataOption):
|
||||||
type: Literal[6, 7, 8, 9]
|
type: Literal[6, 7, 8, 9, 11]
|
||||||
value: Snowflake
|
value: Snowflake
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOptionNumber(_ApplicationCommandInteractionDataOption):
|
class _NumberValueApplicationCommandInteractionDataOption(_BaseValueApplicationCommandInteractionDataOption):
|
||||||
type: Literal[10]
|
type: Literal[10]
|
||||||
value: float
|
value: float
|
||||||
|
|
||||||
|
|
||||||
ApplicationCommandInteractionDataOption = Union[
|
_ValueApplicationCommandInteractionDataOption = Union[
|
||||||
_ApplicationCommandInteractionDataOptionString,
|
_StringValueApplicationCommandInteractionDataOption,
|
||||||
_ApplicationCommandInteractionDataOptionInteger,
|
_IntegerValueApplicationCommandInteractionDataOption,
|
||||||
_ApplicationCommandInteractionDataOptionSubcommand,
|
_BooleanValueApplicationCommandInteractionDataOption,
|
||||||
_ApplicationCommandInteractionDataOptionBoolean,
|
_SnowflakeValueApplicationCommandInteractionDataOption,
|
||||||
_ApplicationCommandInteractionDataOptionSnowflake,
|
_NumberValueApplicationCommandInteractionDataOption,
|
||||||
_ApplicationCommandInteractionDataOptionNumber,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommandResolvedPartialChannel(TypedDict):
|
ApplicationCommandInteractionDataOption = Union[
|
||||||
|
_CommandGroupApplicationCommandInteractionDataOption,
|
||||||
|
_ValueApplicationCommandInteractionDataOption,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseApplicationCommandInteractionDataOptional(TypedDict):
|
||||||
|
resolved: ResolvedData
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseApplicationCommandInteractionData(_BaseApplicationCommandInteractionDataOptional):
|
||||||
id: Snowflake
|
id: Snowflake
|
||||||
type: ChannelType
|
|
||||||
permissions: str
|
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommandInteractionDataResolved(TypedDict, total=False):
|
class ChatInputApplicationCommandInteractionData(_BaseApplicationCommandInteractionData, total=False):
|
||||||
users: Dict[Snowflake, User]
|
type: Literal[1]
|
||||||
members: Dict[Snowflake, Member]
|
|
||||||
roles: Dict[Snowflake, Role]
|
|
||||||
channels: Dict[Snowflake, ApplicationCommandResolvedPartialChannel]
|
|
||||||
|
|
||||||
|
|
||||||
class _ApplicationCommandInteractionDataOptional(TypedDict, total=False):
|
|
||||||
options: List[ApplicationCommandInteractionDataOption]
|
options: List[ApplicationCommandInteractionDataOption]
|
||||||
resolved: ApplicationCommandInteractionDataResolved
|
|
||||||
|
|
||||||
|
class _BaseNonChatInputApplicationCommandInteractionData(_BaseApplicationCommandInteractionData):
|
||||||
target_id: Snowflake
|
target_id: Snowflake
|
||||||
type: ApplicationCommandType
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationCommandInteractionData(_ApplicationCommandInteractionDataOptional):
|
class UserApplicationCommandInteractionData(_BaseNonChatInputApplicationCommandInteractionData):
|
||||||
id: Snowflake
|
type: Literal[2]
|
||||||
name: str
|
|
||||||
|
|
||||||
|
|
||||||
class _ComponentInteractionDataOptional(TypedDict, total=False):
|
class MessageApplicationCommandInteractionData(_BaseNonChatInputApplicationCommandInteractionData):
|
||||||
|
type: Literal[3]
|
||||||
|
|
||||||
|
|
||||||
|
ApplicationCommandInteractionData = Union[
|
||||||
|
ChatInputApplicationCommandInteractionData,
|
||||||
|
UserApplicationCommandInteractionData,
|
||||||
|
MessageApplicationCommandInteractionData,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseMessageComponentInteractionData(TypedDict):
|
||||||
|
custom_id: str
|
||||||
|
|
||||||
|
|
||||||
|
class ButtonMessageComponentInteractionData(_BaseMessageComponentInteractionData):
|
||||||
|
type: Literal[2]
|
||||||
|
|
||||||
|
|
||||||
|
class SelectMessageComponentInteractionData(_BaseMessageComponentInteractionData):
|
||||||
|
component_type: Literal[3]
|
||||||
values: List[str]
|
values: List[str]
|
||||||
|
|
||||||
|
|
||||||
class ComponentInteractionData(_ComponentInteractionDataOptional):
|
MessageComponentInteractionData = Union[ButtonMessageComponentInteractionData, SelectMessageComponentInteractionData]
|
||||||
|
|
||||||
|
|
||||||
|
class ModalSubmitInputTextInteractionData(TypedDict):
|
||||||
|
type: Literal[4]
|
||||||
custom_id: str
|
custom_id: str
|
||||||
component_type: ComponentType
|
value: str
|
||||||
|
|
||||||
|
|
||||||
InteractionData = Union[ApplicationCommandInteractionData, ComponentInteractionData]
|
ModalSubmitComponentItemInteractionData = ModalSubmitInputTextInteractionData
|
||||||
|
|
||||||
|
|
||||||
class _InteractionOptional(TypedDict, total=False):
|
class ModalSubmitActionRowInteractionData(TypedDict):
|
||||||
data: InteractionData
|
type: Literal[1]
|
||||||
|
components: List[ModalSubmitComponentItemInteractionData]
|
||||||
|
|
||||||
|
|
||||||
|
ModalSubmitComponentInteractionData = Union[ModalSubmitActionRowInteractionData, ModalSubmitComponentItemInteractionData]
|
||||||
|
|
||||||
|
|
||||||
|
class ModalSubmitInteractionData(TypedDict):
|
||||||
|
custom_id: str
|
||||||
|
components: List[ModalSubmitActionRowInteractionData]
|
||||||
|
|
||||||
|
|
||||||
|
InteractionData = Union[
|
||||||
|
ApplicationCommandInteractionData,
|
||||||
|
MessageComponentInteractionData,
|
||||||
|
ModalSubmitInteractionData,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseInteractionOptional(TypedDict, total=False):
|
||||||
guild_id: Snowflake
|
guild_id: Snowflake
|
||||||
channel_id: Snowflake
|
channel_id: Snowflake
|
||||||
member: Member
|
|
||||||
user: User
|
|
||||||
message: Message
|
|
||||||
|
|
||||||
|
|
||||||
class Interaction(_InteractionOptional):
|
class _BaseInteraction(_BaseInteractionOptional):
|
||||||
id: Snowflake
|
id: Snowflake
|
||||||
application_id: Snowflake
|
application_id: Snowflake
|
||||||
type: InteractionType
|
|
||||||
token: str
|
token: str
|
||||||
version: int
|
version: Literal[1]
|
||||||
|
|
||||||
|
|
||||||
class InteractionApplicationCommandCallbackData(TypedDict, total=False):
|
class PingInteraction(_BaseInteraction):
|
||||||
tts: bool
|
type: Literal[1]
|
||||||
content: str
|
|
||||||
embeds: List[Embed]
|
|
||||||
allowed_mentions: AllowedMentions
|
|
||||||
flags: int
|
|
||||||
components: List[Component]
|
|
||||||
|
|
||||||
|
|
||||||
InteractionResponseType = Literal[1, 4, 5, 6, 7]
|
class ApplicationCommandInteraction(_BaseInteraction):
|
||||||
|
type: Literal[2, 4]
|
||||||
|
data: ApplicationCommandInteractionData
|
||||||
|
|
||||||
|
|
||||||
class _InteractionResponseOptional(TypedDict, total=False):
|
class MessageComponentInteraction(_BaseInteraction):
|
||||||
data: InteractionApplicationCommandCallbackData
|
type: Literal[3]
|
||||||
|
data: MessageComponentInteractionData
|
||||||
|
|
||||||
|
|
||||||
class InteractionResponse(_InteractionResponseOptional):
|
class ModalSubmitInteraction(_BaseInteraction):
|
||||||
type: InteractionResponseType
|
type: Literal[5]
|
||||||
|
data: ModalSubmitInteractionData
|
||||||
|
|
||||||
|
|
||||||
|
Interaction = Union[PingInteraction, ApplicationCommandInteraction, MessageComponentInteraction, ModalSubmitInteraction]
|
||||||
|
|
||||||
|
|
||||||
class MessageInteraction(TypedDict):
|
class MessageInteraction(TypedDict):
|
||||||
@@ -220,17 +231,3 @@ class MessageInteraction(TypedDict):
|
|||||||
type: InteractionType
|
type: InteractionType
|
||||||
name: str
|
name: str
|
||||||
user: User
|
user: User
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _EditApplicationCommandOptional(TypedDict, total=False):
|
|
||||||
description: str
|
|
||||||
options: Optional[List[ApplicationCommandOption]]
|
|
||||||
type: ApplicationCommandType
|
|
||||||
|
|
||||||
|
|
||||||
class EditApplicationCommand(_EditApplicationCommandOptional):
|
|
||||||
name: str
|
|
||||||
default_permission: bool
|
|
||||||
|
Reference in New Issue
Block a user