@@ -1162,14 +1162,18 @@ def component_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable]
11621162 Your callback will be given a single argument, `ComponentContext`
11631163
11641164 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.
11661168
11671169 Args:
11681170 *custom_id: The custom ID of the component to wait for
11691171
11701172 """
11711173
11721174 def wrapper (func : AsyncCallable ) -> ComponentCommand :
1175+ custom_id = custom_id or [func .__name__ ] # noqa: F823
1176+
11731177 if not asyncio .iscoroutinefunction (func ):
11741178 raise ValueError ("Commands must be coroutines" )
11751179
@@ -1188,14 +1192,18 @@ def modal_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable], Mo
11881192 Your callback will be given a single argument, `ModalContext`
11891193
11901194 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.
11921198
11931199
11941200 Args:
11951201 *custom_id: The custom ID of the modal to wait for
11961202 """
11971203
11981204 def wrapper (func : AsyncCallable ) -> ModalCommand :
1205+ custom_id = custom_id or [func .__name__ ] # noqa: F823
1206+
11991207 if not asyncio .iscoroutinefunction (func ):
12001208 raise ValueError ("Commands must be coroutines" )
12011209
0 commit comments