Fix afk_channel being None in Client.edit_server

This commit is contained in:
Rapptz 2017-06-19 04:25:05 -04:00
parent f57ec81eec
commit 7b806667cd

View File

@ -2307,7 +2307,7 @@ class Client:
``INVITE_SPLASH`` feature. ``INVITE_SPLASH`` feature.
region: :class:`ServerRegion` region: :class:`ServerRegion`
The new region for the server's voice communication. The new region for the server's voice communication.
afk_channel: :class:`Channel` afk_channel: Optional[:class:`Channel`]
The new channel that is the AFK channel. Could be ``None`` for no AFK channel. The new channel that is the AFK channel. Could be ``None`` for no AFK channel.
afk_timeout: int afk_timeout: int
The number of seconds until someone is moved to the AFK channel. The number of seconds until someone is moved to the AFK channel.
@ -2353,8 +2353,16 @@ class Client:
fields['icon'] = icon fields['icon'] = icon
fields['splash'] = splash fields['splash'] = splash
if 'afk_channel' in fields:
fields['afk_channel_id'] = fields['afk_channel'].id try:
afk_channel = fields.pop('afk_channel')
except KeyError:
pass
else:
if afk_channel is None:
fields['afk_channel_id'] = afk_channel
else:
fields['afk_channel_id'] = afk_channel.id
if 'owner' in fields: if 'owner' in fields:
if server.owner != server.me: if server.owner != server.me: