Skip to content

Commit

Permalink
Merge pull request #1522 from interactions-py/unstable
Browse files Browse the repository at this point in the history
5.9.1
  • Loading branch information
silasary authored Aug 8, 2023
2 parents 43a565c + 8a29c4f commit 6e9c9fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions interactions/models/internal/application_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,17 +1170,20 @@ def component_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable]
*custom_id: The custom ID of the component to wait for
"""
resolved_custom_id: tuple[str | re.Pattern, ...] | list[str] = []

def wrapper(func: AsyncCallable) -> ComponentCommand:
custom_id = custom_id or [func.__name__] # noqa: F823
resolved_custom_id = custom_id or [func.__name__]

if not asyncio.iscoroutinefunction(func):
raise ValueError("Commands must be coroutines")

return ComponentCommand(name=f"ComponentCallback::{custom_id}", callback=func, listeners=custom_id)
return ComponentCommand(
name=f"ComponentCallback::{resolved_custom_id}", callback=func, listeners=resolved_custom_id
)

custom_id = _unpack_helper(custom_id)
custom_ids_validator(*custom_id)
custom_id = _unpack_helper(resolved_custom_id)
custom_ids_validator(*resolved_custom_id)
return wrapper


Expand All @@ -1200,17 +1203,18 @@ def modal_callback(*custom_id: str | re.Pattern) -> Callable[[AsyncCallable], Mo
Args:
*custom_id: The custom ID of the modal to wait for
"""
resolved_custom_id: tuple[str | re.Pattern, ...] | list[str] = []

def wrapper(func: AsyncCallable) -> ModalCommand:
custom_id = custom_id or [func.__name__] # noqa: F823
resolved_custom_id = custom_id or [func.__name__]

if not asyncio.iscoroutinefunction(func):
raise ValueError("Commands must be coroutines")

return ModalCommand(name=f"ModalCallback::{custom_id}", callback=func, listeners=custom_id)
return ModalCommand(name=f"ModalCallback::{resolved_custom_id}", callback=func, listeners=resolved_custom_id)

custom_id = _unpack_helper(custom_id)
custom_ids_validator(*custom_id)
custom_id = _unpack_helper(resolved_custom_id)
custom_ids_validator(*resolved_custom_id)
return wrapper


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "interactions.py"
version = "5.9.0"
version = "5.9.1"
description = "Easy, simple, scalable and modular: a Python API wrapper for interactions."
authors = [
"LordOfPolls <dev@lordofpolls.com>",
Expand Down

0 comments on commit 6e9c9fd

Please sign in to comment.