diff options
| author | Rapptz <[email protected]> | 2016-01-22 18:08:19 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-01-22 18:12:09 -0500 |
| commit | e7931eccc8e4e169f98ef669dd2f5a57e87a8ffd (patch) | |
| tree | 8e991176b0146a2c11c2552a93941b294ed9c78b | |
| parent | [commands] Add Command.no_pm attribute to block a command in PM. (diff) | |
| download | discord.py-e7931eccc8e4e169f98ef669dd2f5a57e87a8ffd.tar.xz discord.py-e7931eccc8e4e169f98ef669dd2f5a57e87a8ffd.zip | |
Support changing owners in Client.edit_server.
| -rw-r--r-- | discord/client.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/discord/client.py b/discord/client.py index 971d4f62..83a7325c 100644 --- a/discord/client.py +++ b/discord/client.py @@ -1695,6 +1695,9 @@ class Client: The new channel that is the AFK channel. Could be ``None`` for no AFK channel. afk_timeout : int The number of seconds until someone is moved to the AFK channel. + owner : :class:`Member` + The new owner of the server to transfer ownership to. Note that you must + be owner of the server to do this. Raises ------- @@ -1706,7 +1709,8 @@ class Client: Editing the server failed. InvalidArgument The image format passed in to ``icon`` is invalid. It must be - PNG or JPG. + PNG or JPG. This is also raised if you are not the owner of the + server and request an ownership transfer. """ try: @@ -1732,6 +1736,12 @@ class Client: payload['afk_channel'] = getattr(afk_channel, 'id', None) + if 'owner' in fields: + if server.owner != server.me: + raise InvalidArgument('To transfer ownership you must be the owner of the server.') + + payload['owner_id'] = fields['owner'].id + url = '{0}/{1.id}'.format(endpoints.SERVERS, server) r = yield from aiohttp.patch(url, headers=self.headers, data=utils.to_json(payload), loop=self.loop) log.debug(request_logging_format.format(method='PATCH', response=r)) |