26
26
Union ,
27
27
Awaitable ,
28
28
Tuple ,
29
+ TypeVar ,
30
+ overload ,
29
31
)
30
32
31
33
from aiohttp import BasicAuth
40
42
from interactions .client import errors
41
43
from interactions .client .const import (
42
44
GLOBAL_SCOPE ,
45
+ Missing ,
43
46
MISSING ,
44
47
Absent ,
45
48
EMBED_MAX_DESC_LENGTH ,
122
125
if TYPE_CHECKING :
123
126
from interactions .models import Snowflake_Type , TYPE_ALL_CHANNEL
124
127
128
+ EventT = TypeVar ("EventT" , bound = BaseEvent )
129
+
125
130
__all__ = ("Client" ,)
126
131
127
132
# see https://discord.com/developers/docs/topics/gateway#list-of-intents
@@ -1061,12 +1066,36 @@ async def wait_until_ready(self) -> None:
1061
1066
"""Waits for the client to become ready."""
1062
1067
await self ._ready .wait ()
1063
1068
1069
+ @overload
1070
+ def wait_for (
1071
+ self ,
1072
+ event : type [EventT ],
1073
+ checks : Absent [Callable [[EventT ], bool ] | Callable [[EventT ], Awaitable [bool ]]] = MISSING ,
1074
+ timeout : Optional [float ] = None ,
1075
+ ) -> "Awaitable[EventT]" : ...
1076
+
1077
+ @overload
1064
1078
def wait_for (
1065
1079
self ,
1066
- event : Union [ str , "BaseEvent" ] ,
1067
- checks : Absent [ Optional [ Union [ Callable [... , bool ], Callable [... , Awaitable [bool ]]]]] = MISSING ,
1080
+ event : str ,
1081
+ checks : Callable [[ EventT ] , bool ] | Callable [[ EventT ] , Awaitable [bool ]],
1068
1082
timeout : Optional [float ] = None ,
1069
- ) -> Any :
1083
+ ) -> "Awaitable[EventT]" : ...
1084
+
1085
+ @overload
1086
+ def wait_for (
1087
+ self ,
1088
+ event : str ,
1089
+ checks : Missing = MISSING ,
1090
+ timeout : Optional [float ] = None ,
1091
+ ) -> Awaitable [Any ]: ...
1092
+
1093
+ def wait_for (
1094
+ self ,
1095
+ event : Union [str , "type[BaseEvent]" ],
1096
+ checks : Absent [Callable [[BaseEvent ], bool ] | Callable [[BaseEvent ], Awaitable [bool ]]] = MISSING ,
1097
+ timeout : Optional [float ] = None ,
1098
+ ) -> Awaitable [Any ]:
1070
1099
"""
1071
1100
Waits for a WebSocket event to be dispatched.
1072
1101
@@ -1112,17 +1141,68 @@ async def wait_for_modal(
1112
1141
"""
1113
1142
author = to_snowflake (author ) if author else None
1114
1143
1115
- def predicate (event ) -> bool :
1144
+ def predicate (event : events . ModalCompletion ) -> bool :
1116
1145
if modal .custom_id != event .ctx .custom_id :
1117
1146
return False
1118
1147
return author == to_snowflake (event .ctx .author ) if author else True
1119
1148
1120
1149
resp = await self .wait_for ("modal_completion" , predicate , timeout )
1121
1150
return resp .ctx
1122
1151
1152
+ @overload
1153
+ async def wait_for_component (
1154
+ self ,
1155
+ messages : Union [Message , int , list ],
1156
+ components : Union [
1157
+ List [List [Union ["BaseComponent" , dict ]]],
1158
+ List [Union ["BaseComponent" , dict ]],
1159
+ "BaseComponent" ,
1160
+ dict ,
1161
+ ],
1162
+ check : Optional [Callable [[events .Component ], bool ] | Callable [[events .Component ], Awaitable [bool ]]] = None ,
1163
+ timeout : Optional [float ] = None ,
1164
+ ) -> "events.Component" : ...
1165
+
1166
+ @overload
1167
+ async def wait_for_component (
1168
+ self ,
1169
+ * ,
1170
+ components : Union [
1171
+ List [List [Union ["BaseComponent" , dict ]]],
1172
+ List [Union ["BaseComponent" , dict ]],
1173
+ "BaseComponent" ,
1174
+ dict ,
1175
+ ],
1176
+ check : Optional [Callable [[events .Component ], bool ] | Callable [[events .Component ], Awaitable [bool ]]] = None ,
1177
+ timeout : Optional [float ] = None ,
1178
+ ) -> "events.Component" : ...
1179
+
1180
+ @overload
1181
+ async def wait_for_component (
1182
+ self ,
1183
+ messages : None ,
1184
+ components : Union [
1185
+ List [List [Union ["BaseComponent" , dict ]]],
1186
+ List [Union ["BaseComponent" , dict ]],
1187
+ "BaseComponent" ,
1188
+ dict ,
1189
+ ],
1190
+ check : Optional [Callable [[events .Component ], bool ] | Callable [[events .Component ], Awaitable [bool ]]] = None ,
1191
+ timeout : Optional [float ] = None ,
1192
+ ) -> "events.Component" : ...
1193
+
1194
+ @overload
1195
+ async def wait_for_component (
1196
+ self ,
1197
+ messages : Union [Message , int , list ],
1198
+ components : None = None ,
1199
+ check : Optional [Callable [[events .Component ], bool ] | Callable [[events .Component ], Awaitable [bool ]]] = None ,
1200
+ timeout : Optional [float ] = None ,
1201
+ ) -> "events.Component" : ...
1202
+
1123
1203
async def wait_for_component (
1124
1204
self ,
1125
- messages : Union [Message , int , list ] = None ,
1205
+ messages : Optional [ Union [Message , int , list ] ] = None ,
1126
1206
components : Optional [
1127
1207
Union [
1128
1208
List [List [Union ["BaseComponent" , dict ]]],
@@ -1131,7 +1211,7 @@ async def wait_for_component(
1131
1211
dict ,
1132
1212
]
1133
1213
] = None ,
1134
- check : Absent [ Optional [Union [ Callable [... , bool ], Callable [... , Awaitable [bool ]]]]] | None = None ,
1214
+ check : Optional [Callable [[ events . Component ] , bool ] | Callable [[ events . Component ] , Awaitable [bool ]]] = None ,
1135
1215
timeout : Optional [float ] = None ,
1136
1216
) -> "events.Component" :
1137
1217
"""
0 commit comments