diff options
| author | Rapptz <[email protected]> | 2016-05-11 20:34:37 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-05-12 06:06:37 -0400 |
| commit | 339e26275f79cbfa141da1b22aa6103234c7b35b (patch) | |
| tree | 6962f90dab6c9fe804c4f42574a2bba103912b16 | |
| parent | Add clarification for purge_from and delete_messages (diff) | |
| download | discord.py-339e26275f79cbfa141da1b22aa6103234c7b35b.tar.xz discord.py-339e26275f79cbfa141da1b22aa6103234c7b35b.zip | |
Add VoiceClient.move_to for quick switching of voice channels.
| -rw-r--r-- | discord/voice_client.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/discord/voice_client.py b/discord/voice_client.py index 5da25684..0826ad1e 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -227,6 +227,32 @@ class VoiceClient: yield from self.ws.close() yield from self.main_ws.voice_state(self.guild_id, None, self_mute=True) + @asyncio.coroutine + def move_to(self, channel): + """|coro| + + Moves you to a different voice channel. + + .. warning:: + + :class:`Object` instances do not work with this function. + + Parameters + ----------- + channel : :class:`Channel` + The channel to move to. Must be a voice channel. + + Raises + ------- + InvalidArgument + Not a voice channel. + """ + + if str(getattr(channel, 'type', 'text')) != 'voice': + raise InvalidArgument('Must be a voice channel.') + + yield from self.main_ws.voice_state(self.guild_id, channel.id) + def is_connected(self): """bool : Indicates if the voice client is connected to voice.""" return self._connected.is_set() |