Skip to content

Commit 75d2f98

Browse files
committed
✨ Better, class based, implementation for events, components and modals
1 parent 4c98a78 commit 75d2f98

File tree

3 files changed

+296
-152
lines changed

3 files changed

+296
-152
lines changed

discord/gears/base.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,19 @@
2323
"""
2424

2525
from abc import ABC, abstractmethod
26-
from collections import defaultdict
27-
from collections.abc import Awaitable, Callable, Collection, Sequence
28-
from functools import partial
26+
from collections.abc import Awaitable, Callable
2927
from typing import (
3028
TYPE_CHECKING,
3129
Any,
32-
Protocol,
3330
TypeAlias,
3431
TypeVar,
35-
cast,
36-
runtime_checkable,
3732
)
3833

3934
from ..app.event_emitter import Event
4035
from ..utils import MISSING, Undefined
41-
from ..utils.annotations import get_annotations
42-
from ..utils.private import hybridmethod
36+
37+
if TYPE_CHECKING:
38+
from .gear import EventListener
4339

4440
E = TypeVar("E", bound="Event", covariant=True)
4541

@@ -55,12 +51,15 @@ def add_listener(
5551
event: type[E] | Undefined = MISSING,
5652
is_instance_function: bool = False,
5753
once: bool = False,
58-
) -> None: ...
54+
) -> "EventListener[E]": ...
5955

6056
@abstractmethod
6157
def remove_listener(
62-
self, callback: EventCallback[E], event: type[E] | Undefined = MISSING, is_instance_function: bool = False
58+
self,
59+
listener: "EventListener[E]",
60+
event: type[E] | Undefined = MISSING,
61+
is_instance_function: bool = False,
6362
) -> None: ...
6463

6564
@abstractmethod
66-
def listen(self, *args: Any, **kwargs: Any) -> Callable[[Callable[[E], Awaitable[None]]], EventCallback[E]]: ...
65+
def listen(self, *args: Any, **kwargs: Any) -> Any: ...

0 commit comments

Comments
 (0)