diff --git a/discord/abc.py b/discord/abc.py index d8b8dd873..ab7465e0b 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -105,6 +105,7 @@ if TYPE_CHECKING: ) MessageableChannel = Union[TextChannel, VoiceChannel, StageChannel, Thread, DMChannel, PartialMessageable, GroupChannel] + VocalChannel = Union[VoiceChannel, StageChannel, DMChannel, GroupChannel] SnowflakeTime = Union["Snowflake", datetime] MISSING = utils.MISSING @@ -2115,7 +2116,7 @@ class Connectable(Protocol): *, timeout: float = 60.0, reconnect: bool = True, - cls: Callable[[Client, Connectable], T] = VoiceClient, + cls: Callable[[Client, VocalChannel], T] = VoiceClient, _channel: Optional[Connectable] = None, self_deaf: bool = False, self_mute: bool = False, @@ -2168,7 +2169,7 @@ class Connectable(Protocol): if state._get_voice_client(key_id): raise ClientException('Already connected to a voice channel') - voice: T = cls(state.client, self) + voice: T = cls(state.client, channel) if not isinstance(voice, VoiceProtocol): raise TypeError('Type must meet VoiceProtocol abstract base class') diff --git a/discord/channel.py b/discord/channel.py index 06b3eb57f..0fdef6c78 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -3023,7 +3023,7 @@ class DMChannel(discord.abc.Messageable, discord.abc.Connectable, discord.abc.Pr *, timeout: float = 60.0, reconnect: bool = True, - cls: Callable[[Client, discord.abc.Connectable], T] = VoiceClient, + cls: Callable[[Client, discord.abc.VocalChannel], T] = VoiceClient, ring: bool = True, ) -> T: """|coro| @@ -3555,7 +3555,7 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, discord.abc *, timeout: float = 60.0, reconnect: bool = True, - cls: Callable[[Client, discord.abc.Connectable], T] = VoiceClient, + cls: Callable[[Client, discord.abc.VocalChannel], T] = VoiceClient, ring: bool = True, ) -> T: await self._get_channel() diff --git a/discord/guild.py b/discord/guild.py index 7eb36e84d..b4dca52fe 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -491,7 +491,7 @@ class Guild(Hashable): for c in guild.get('channels', []): factory, _ = _guild_channel_factory(c['type']) if factory: - self._add_channel(factory(guild=self, data=c, state=state)) + self._add_channel(factory(guild=self, data=c, state=state)) # type: ignore for t in guild.get('threads', []): self._add_thread(Thread(guild=self, state=self._state, data=t)) diff --git a/discord/voice_client.py b/discord/voice_client.py index 6a19fb9c5..f3a673fbb 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -59,7 +59,6 @@ if TYPE_CHECKING: from .state import ConnectionState from .user import ClientUser from .opus import Encoder - from .channel import StageChannel, VoiceChannel, DMChannel, GroupChannel from . import abc from .types.voice import ( @@ -68,7 +67,7 @@ if TYPE_CHECKING: SupportedModes, ) - VocalChannel = Union[VoiceChannel, StageChannel, DMChannel, GroupChannel] + VocalChannel = abc.VocalChannel has_nacl: bool