@@ -1170,17 +1170,20 @@ def component_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable]
1170
1170
*custom_id: The custom ID of the component to wait for
1171
1171
1172
1172
"""
1173
+ resolved_custom_id : tuple [str | re .Pattern , ...] | list [str ] = []
1173
1174
1174
1175
def wrapper (func : AsyncCallable ) -> ComponentCommand :
1175
- custom_id = custom_id or [func .__name__ ] # noqa: F823
1176
+ resolved_custom_id = custom_id or [func .__name__ ]
1176
1177
1177
1178
if not asyncio .iscoroutinefunction (func ):
1178
1179
raise ValueError ("Commands must be coroutines" )
1179
1180
1180
- return ComponentCommand (name = f"ComponentCallback::{ custom_id } " , callback = func , listeners = custom_id )
1181
+ return ComponentCommand (
1182
+ name = f"ComponentCallback::{ resolved_custom_id } " , callback = func , listeners = resolved_custom_id
1183
+ )
1181
1184
1182
- custom_id = _unpack_helper (custom_id )
1183
- custom_ids_validator (* custom_id )
1185
+ custom_id = _unpack_helper (resolved_custom_id )
1186
+ custom_ids_validator (* resolved_custom_id )
1184
1187
return wrapper
1185
1188
1186
1189
@@ -1200,17 +1203,18 @@ def modal_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable], Mo
1200
1203
Args:
1201
1204
*custom_id: The custom ID of the modal to wait for
1202
1205
"""
1206
+ resolved_custom_id : tuple [str | re .Pattern , ...] | list [str ] = []
1203
1207
1204
1208
def wrapper (func : AsyncCallable ) -> ModalCommand :
1205
- custom_id = custom_id or [func .__name__ ] # noqa: F823
1209
+ resolved_custom_id = custom_id or [func .__name__ ]
1206
1210
1207
1211
if not asyncio .iscoroutinefunction (func ):
1208
1212
raise ValueError ("Commands must be coroutines" )
1209
1213
1210
- return ModalCommand (name = f"ModalCallback::{ custom_id } " , callback = func , listeners = custom_id )
1214
+ return ModalCommand (name = f"ModalCallback::{ resolved_custom_id } " , callback = func , listeners = resolved_custom_id )
1211
1215
1212
- custom_id = _unpack_helper (custom_id )
1213
- custom_ids_validator (* custom_id )
1216
+ custom_id = _unpack_helper (resolved_custom_id )
1217
+ custom_ids_validator (* resolved_custom_id )
1214
1218
return wrapper
1215
1219
1216
1220
0 commit comments