diff options
| author | Rapptz <[email protected]> | 2015-12-29 13:29:39 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-29 13:29:39 -0500 |
| commit | dd0bb3baa1b0b49396c98599db302de4b23b64f7 (patch) | |
| tree | d7c1529cac4fe3f7a6cf6ede7505d76031ca229f | |
| parent | Remove Client.voice_channel (diff) | |
| download | discord.py-dd0bb3baa1b0b49396c98599db302de4b23b64f7.tar.xz discord.py-dd0bb3baa1b0b49396c98599db302de4b23b64f7.zip | |
Add ability to move members to a different voice channel.
| -rw-r--r-- | discord/client.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py index b2789b33..82d1e3aa 100644 --- a/discord/client.py +++ b/discord/client.py @@ -2280,6 +2280,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| |