Browse Source

Allow callables in abc.Connectable.Connect

pull/7297/head
Josh 4 years ago
committed by GitHub
parent
commit
41e2d3c637
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      discord/abc.py

10
discord/abc.py

@ -28,6 +28,7 @@ import copy
import asyncio import asyncio
from typing import ( from typing import (
Any, Any,
Callable,
Dict, Dict,
List, List,
Mapping, Mapping,
@ -68,6 +69,7 @@ T = TypeVar('T', bound=VoiceProtocol)
if TYPE_CHECKING: if TYPE_CHECKING:
from datetime import datetime from datetime import datetime
from .client import Client
from .user import ClientUser from .user import ClientUser
from .asset import Asset from .asset import Asset
from .state import ConnectionState from .state import ConnectionState
@ -1611,7 +1613,13 @@ class Connectable(Protocol):
def _get_voice_state_pair(self) -> Tuple[int, int]: def _get_voice_state_pair(self) -> Tuple[int, int]:
raise NotImplementedError raise NotImplementedError
async def connect(self, *, timeout: float = 60.0, reconnect: bool = True, cls: Type[T] = VoiceClient) -> T: async def connect(
self,
*,
timeout: float = 60.0,
reconnect: bool = True,
cls: Callable[[Client, Connectable], T] = VoiceClient,
) -> T:
"""|coro| """|coro|
Connects to voice and creates a :class:`VoiceClient` to establish Connects to voice and creates a :class:`VoiceClient` to establish

Loading…
Cancel
Save