-
-
Notifications
You must be signed in to change notification settings - Fork 456
/
interactions.py
243 lines (175 loc) · 6.72 KB
/
interactions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
"""
The MIT License (MIT)
Copyright (c) 2015-2021 Rapptz
Copyright (c) 2021-present Pycord Development
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 TYPE_CHECKING, Literal, Union
from ..permissions import Permissions
from .channel import ChannelType
from .components import Component, ComponentType
from .embed import Embed
from .member import Member
from .message import Attachment
from .role import Role
from .snowflake import Snowflake
from .user import User
if TYPE_CHECKING:
from .message import AllowedMentions, Message
from ..interactions import InteractionChannel
from .._typed_dict import NotRequired, TypedDict
ApplicationCommandType = Literal[1, 2, 3]
class ApplicationCommand(TypedDict):
options: NotRequired[list[ApplicationCommandOption]]
type: NotRequired[ApplicationCommandType]
name_localized: NotRequired[str]
name_localizations: NotRequired[dict[str, str]]
description_localized: NotRequired[str]
description_localizations: NotRequired[dict[str, str]]
id: Snowflake
application_id: Snowflake
name: str
description: str
ApplicationCommandOptionType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
class ApplicationCommandOption(TypedDict):
choices: NotRequired[list[ApplicationCommandOptionChoice]]
options: NotRequired[list[ApplicationCommandOption]]
name_localizations: NotRequired[dict[str, str]]
description_localizations: NotRequired[dict[str, str]]
type: ApplicationCommandOptionType
name: str
description: str
required: bool
class ApplicationCommandOptionChoice(TypedDict):
name_localizations: NotRequired[dict[str, str]]
name: str
value: str | int
ApplicationCommandPermissionType = Literal[1, 2, 3]
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
class _ApplicationCommandInteractionDataOptionSubcommand(
_ApplicationCommandInteractionDataOption
):
type: Literal[1, 2]
options: list[ApplicationCommandInteractionDataOption]
class _ApplicationCommandInteractionDataOptionString(
_ApplicationCommandInteractionDataOption
):
type: Literal[3]
value: str
class _ApplicationCommandInteractionDataOptionInteger(
_ApplicationCommandInteractionDataOption
):
type: Literal[4]
value: int
class _ApplicationCommandInteractionDataOptionBoolean(
_ApplicationCommandInteractionDataOption
):
type: Literal[5]
value: bool
class _ApplicationCommandInteractionDataOptionSnowflake(
_ApplicationCommandInteractionDataOption
):
type: Literal[6, 7, 8, 9, 11]
value: Snowflake
class _ApplicationCommandInteractionDataOptionNumber(
_ApplicationCommandInteractionDataOption
):
type: Literal[10]
value: float
ApplicationCommandInteractionDataOption = Union[
_ApplicationCommandInteractionDataOptionString,
_ApplicationCommandInteractionDataOptionInteger,
_ApplicationCommandInteractionDataOptionSubcommand,
_ApplicationCommandInteractionDataOptionBoolean,
_ApplicationCommandInteractionDataOptionSnowflake,
_ApplicationCommandInteractionDataOptionNumber,
]
class ApplicationCommandResolvedPartialChannel(TypedDict):
id: Snowflake
type: ChannelType
permissions: str
name: str
class ApplicationCommandInteractionDataResolved(TypedDict, total=False):
users: dict[Snowflake, User]
members: dict[Snowflake, Member]
roles: dict[Snowflake, Role]
channels: dict[Snowflake, ApplicationCommandResolvedPartialChannel]
attachments: dict[Snowflake, Attachment]
class ApplicationCommandInteractionData(TypedDict):
options: NotRequired[list[ApplicationCommandInteractionDataOption]]
resolved: NotRequired[ApplicationCommandInteractionDataResolved]
target_id: NotRequired[Snowflake]
type: NotRequired[ApplicationCommandType]
id: Snowflake
name: str
class ComponentInteractionData(TypedDict):
values: NotRequired[list[str]]
custom_id: str
component_type: ComponentType
InteractionData = Union[ApplicationCommandInteractionData, ComponentInteractionData]
class Interaction(TypedDict):
data: NotRequired[InteractionData]
guild_id: NotRequired[Snowflake]
channel_id: NotRequired[Snowflake]
channel: NotRequired[InteractionChannel]
member: NotRequired[Member]
user: NotRequired[User]
message: NotRequired[Message]
locale: NotRequired[str]
guild_locale: NotRequired[str]
app_permissions: NotRequired[Permissions]
id: Snowflake
application_id: Snowflake
type: InteractionType
token: str
version: int
class InteractionApplicationCommandCallbackData(TypedDict, total=False):
tts: bool
content: str
embeds: list[Embed]
allowed_mentions: AllowedMentions
flags: int
components: list[Component]
InteractionResponseType = Literal[1, 4, 5, 6, 7]
class InteractionResponse(TypedDict):
data: NotRequired[InteractionApplicationCommandCallbackData]
type: InteractionResponseType
class MessageInteraction(TypedDict):
id: Snowflake
type: InteractionType
name: str
user: User
class EditApplicationCommand(TypedDict):
description: NotRequired[str]
options: NotRequired[list[ApplicationCommandOption] | None]
type: NotRequired[ApplicationCommandType]
name: str
default_permission: bool