@@ -1162,14 +1162,18 @@ def component_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable]
1162
1162
Your callback will be given a single argument, `ComponentContext`
1163
1163
1164
1164
Note:
1165
- This can optionally take a regex pattern, which will be used to match against the custom ID of the component
1165
+ This can optionally take a regex pattern, which will be used to match against the custom ID of the component.
1166
+
1167
+ If you do not supply a `custom_id`, the name of the coroutine will be used instead.
1166
1168
1167
1169
Args:
1168
1170
*custom_id: The custom ID of the component to wait for
1169
1171
1170
1172
"""
1171
1173
1172
1174
def wrapper (func : AsyncCallable ) -> ComponentCommand :
1175
+ custom_id = custom_id or [func .__name__ ] # noqa: F823
1176
+
1173
1177
if not asyncio .iscoroutinefunction (func ):
1174
1178
raise ValueError ("Commands must be coroutines" )
1175
1179
@@ -1188,14 +1192,18 @@ def modal_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable], Mo
1188
1192
Your callback will be given a single argument, `ModalContext`
1189
1193
1190
1194
Note:
1191
- This can optionally take a regex pattern, which will be used to match against the custom ID of the modal
1195
+ This can optionally take a regex pattern, which will be used to match against the custom ID of the modal.
1196
+
1197
+ If you do not supply a `custom_id`, the name of the coroutine will be used instead.
1192
1198
1193
1199
1194
1200
Args:
1195
1201
*custom_id: The custom ID of the modal to wait for
1196
1202
"""
1197
1203
1198
1204
def wrapper (func : AsyncCallable ) -> ModalCommand :
1205
+ custom_id = custom_id or [func .__name__ ] # noqa: F823
1206
+
1199
1207
if not asyncio .iscoroutinefunction (func ):
1200
1208
raise ValueError ("Commands must be coroutines" )
1201
1209
0 commit comments