mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-21 10:26:47 +00:00
Add self_deaf and self_mute params to voice connect methods
This commit is contained in:
parent
862eba1e59
commit
89b9f1616c
@ -1783,6 +1783,8 @@ class Connectable(Protocol):
|
|||||||
timeout: float = 60.0,
|
timeout: float = 60.0,
|
||||||
reconnect: bool = True,
|
reconnect: bool = True,
|
||||||
cls: Callable[[Client, Connectable], T] = MISSING,
|
cls: Callable[[Client, Connectable], T] = MISSING,
|
||||||
|
self_deaf: bool = False,
|
||||||
|
self_mute: bool = False,
|
||||||
) -> T:
|
) -> T:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
@ -1802,6 +1804,14 @@ class Connectable(Protocol):
|
|||||||
cls: Type[:class:`~discord.VoiceProtocol`]
|
cls: Type[:class:`~discord.VoiceProtocol`]
|
||||||
A type that subclasses :class:`~discord.VoiceProtocol` to connect with.
|
A type that subclasses :class:`~discord.VoiceProtocol` to connect with.
|
||||||
Defaults to :class:`~discord.VoiceClient`.
|
Defaults to :class:`~discord.VoiceClient`.
|
||||||
|
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
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
@ -1838,7 +1848,7 @@ class Connectable(Protocol):
|
|||||||
state._add_voice_client(key_id, voice)
|
state._add_voice_client(key_id, voice)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await voice.connect(timeout=timeout, reconnect=reconnect)
|
await voice.connect(timeout=timeout, reconnect=reconnect, self_deaf=self_deaf, self_mute=self_mute)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
try:
|
try:
|
||||||
await voice.disconnect(force=True)
|
await voice.disconnect(force=True)
|
||||||
|
@ -149,7 +149,7 @@ class VoiceProtocol:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
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|
|
"""|coro|
|
||||||
|
|
||||||
An abstract method called when the client initiates the connection request.
|
An abstract method called when the client initiates the connection request.
|
||||||
@ -169,6 +169,14 @@ class VoiceProtocol:
|
|||||||
The timeout for the connection.
|
The timeout for the connection.
|
||||||
reconnect: :class:`bool`
|
reconnect: :class:`bool`
|
||||||
Whether reconnection is expected.
|
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
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -339,8 +347,8 @@ class VoiceClient(VoiceProtocol):
|
|||||||
|
|
||||||
self._voice_server_complete.set()
|
self._voice_server_complete.set()
|
||||||
|
|
||||||
async def voice_connect(self) -> None:
|
async def voice_connect(self, self_deaf: bool = False, self_mute: bool = False) -> None:
|
||||||
await self.channel.guild.change_voice_state(channel=self.channel)
|
await self.channel.guild.change_voice_state(channel=self.channel, self_deaf=self_deaf, self_mute=self_mute)
|
||||||
|
|
||||||
async def voice_disconnect(self) -> None:
|
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)
|
_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()
|
self._connected.set()
|
||||||
return ws
|
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...')
|
_log.info('Connecting to voice...')
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
@ -381,7 +389,7 @@ class VoiceClient(VoiceProtocol):
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Start the connection flow
|
# Start the connection flow
|
||||||
await self.voice_connect()
|
await self.voice_connect(self_deaf=self_deaf, self_mute=self_mute)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await utils.sane_wait_for(futures, timeout=timeout)
|
await utils.sane_wait_for(futures, timeout=timeout)
|
||||||
|
@ -1212,6 +1212,11 @@ The following changes have been made:
|
|||||||
|
|
||||||
- :attr:`File.filename` will no longer be ``None``, in situations where previously this was the case the filename is set to `'untitled'`.
|
- :attr:`File.filename` will no longer be ``None``, in situations where previously this was the case the filename is set to `'untitled'`.
|
||||||
|
|
||||||
|
:meth:`VoiceProtocol.connect` signature changes.
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
:meth:`VoiceProtocol.connect` will now be passed 2 keyword only arguments, ``self_deaf`` and ``self_mute``. These indicate
|
||||||
|
whether or not the client should join the voice chat being deafened or muted.
|
||||||
|
|
||||||
.. _migrating_2_0_commands:
|
.. _migrating_2_0_commands:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user