From dd0bb3baa1b0b49396c98599db302de4b23b64f7 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 29 Dec 2015 13:29:39 -0500 Subject: [PATCH] Add ability to move members to a different voice channel. --- discord/client.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/discord/client.py b/discord/client.py index b2789b33a..82d1e3aab 100644 --- a/discord/client.py +++ b/discord/client.py @@ -2279,6 +2279,49 @@ class Client: # Voice management + @asyncio.coroutine + def move_member(self, member, channel): + """|coro| + + Moves a :class:`Member` to a different voice channel. + + You must have proper permissions to do this. + + Note + ----- + You cannot pass in a :class:`Object` in place of a :class:`Channel` + object in this function. + + Parameters + ----------- + member : :class:`Member` + The member to move to another voice channel. + channel : :class:`Channel` + The voice channel to move the member to. + + Raises + ------- + InvalidArgument + The channel provided is not a voice channel. + HTTPException + Moving the member failed. + Forbidden + You do not have permissions to move the member. + """ + + url = '{0}/{1.server.id}/members/{2.id}'.format(endpoints.SERVERS, member) + + if getattr(channel, 'type', ChannelType.text) != ChannelType.voice: + raise InvalidArgument('The channel provided must be a voice channel.') + + payload = utils.to_json({ + 'channel_id': channel.id + }) + response = yield from aiohttp.patch(url, data=payload, headers=self.headers, loop=self.loop) + log.debug(request_logging_format.format(method='PATCH', response=response)) + yield from utils._verify_successful_response(response) + yield from response.release() + @asyncio.coroutine def join_voice_channel(self, channel): """|coro|