|
47 | 47 | TypeVar, |
48 | 48 | ) |
49 | 49 |
|
| 50 | +from typing_extensions import Protocol |
| 51 | + |
50 | 52 | from .client import Client |
51 | 53 | from .cog import CogMixin |
52 | 54 | from .commands import ( |
|
69 | 71 | from .utils.private import async_all, maybe_awaitable |
70 | 72 |
|
71 | 73 | if TYPE_CHECKING: |
| 74 | + from typing import Unpack |
| 75 | + |
72 | 76 | from .interactions import ComponentInteraction, ModalInteraction |
73 | 77 | from .member import Member |
74 | 78 |
|
@@ -1101,11 +1105,10 @@ async def invoke_application_command(self, ctx: ApplicationContext) -> None: |
1101 | 1105 | def _bot(self) -> Bot | AutoShardedBot: ... |
1102 | 1106 |
|
1103 | 1107 |
|
1104 | | -T = TypeVar("T") |
| 1108 | +class ComponentListener(Protocol): |
| 1109 | + async def __call__(self, interaction: ComponentInteraction[Any]) -> Any: ... |
1105 | 1110 |
|
1106 | | -Listener: TypeAlias = Callable[[T], Coroutine[Any, Any, Any]] # pyright: ignore[reportExplicitAny] |
1107 | 1111 |
|
1108 | | -ComponentListener: TypeAlias = "Listener[ComponentInteraction]" |
1109 | 1112 | CL_t = TypeVar("CL_t", bound=ComponentListener) |
1110 | 1113 |
|
1111 | 1114 |
|
@@ -1222,7 +1225,10 @@ def wrapper(func: CL_t) -> CL_t: |
1222 | 1225 | def _bot(self) -> Bot | AutoShardedBot: ... |
1223 | 1226 |
|
1224 | 1227 |
|
1225 | | -ModalListener: TypeAlias = "Listener[ModalInteraction]" |
| 1228 | +class ModalListener(Protocol): |
| 1229 | + async def __call__(self, interaction: ModalInteraction[Unpack[tuple[Any, ...]]]) -> Any: ... |
| 1230 | + |
| 1231 | + |
1226 | 1232 | ML_t = TypeVar("ML_t", bound=ModalListener) |
1227 | 1233 |
|
1228 | 1234 |
|
|
0 commit comments