Add self_deaf and self_mute params to voice connect methods

This commit is contained in:
Vaskel
2022-04-14 19:06:22 -04:00
committed by GitHub
parent 862eba1e59
commit 89b9f1616c
3 changed files with 29 additions and 6 deletions

View File

@ -149,7 +149,7 @@ class VoiceProtocol:
"""
raise NotImplementedError
async def connect(self, *, timeout: float, reconnect: bool) -> None:
async def connect(self, *, timeout: float, reconnect: bool, self_deaf: bool = False, self_mute: bool = False) -> None:
"""|coro|
An abstract method called when the client initiates the connection request.
@ -169,6 +169,14 @@ class VoiceProtocol:
The timeout for the connection.
reconnect: :class:`bool`
Whether reconnection is expected.
self_mute: :class:`bool`
Indicates if the client should be self-muted.
.. versionadded: 2.0
self_deaf: :class:`bool`
Indicates if the client should be self-deafened.
.. versionadded: 2.0
"""
raise NotImplementedError
@ -339,8 +347,8 @@ class VoiceClient(VoiceProtocol):
self._voice_server_complete.set()
async def voice_connect(self) -> None:
await self.channel.guild.change_voice_state(channel=self.channel)
async def voice_connect(self, self_deaf: bool = False, self_mute: bool = False) -> None:
await self.channel.guild.change_voice_state(channel=self.channel, self_deaf=self_deaf, self_mute=self_mute)
async def voice_disconnect(self) -> None:
_log.info('The voice handshake is being terminated for Channel ID %s (Guild ID %s)', self.channel.id, self.guild.id)
@ -367,7 +375,7 @@ class VoiceClient(VoiceProtocol):
self._connected.set()
return ws
async def connect(self, *, reconnect: bool, timeout: float) -> None:
async def connect(self, *, reconnect: bool, timeout: float, self_deaf: bool = False, self_mute: bool = False) -> None:
_log.info('Connecting to voice...')
self.timeout = timeout
@ -381,7 +389,7 @@ class VoiceClient(VoiceProtocol):
]
# Start the connection flow
await self.voice_connect()
await self.voice_connect(self_deaf=self_deaf, self_mute=self_mute)
try:
await utils.sane_wait_for(futures, timeout=timeout)