aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-06-19 04:22:42 -0400
committerRapptz <[email protected]>2017-06-19 04:22:42 -0400
commit06c99533def2fccbbd53c6ee76558d667bacf3a9 (patch)
treeba829c7c735c2f453aa1290a2ec5bc9355082c4c
parent[commands] Try to use the proper name when conversion fails. (diff)
downloaddiscord.py-06c99533def2fccbbd53c6ee76558d667bacf3a9.tar.xz
discord.py-06c99533def2fccbbd53c6ee76558d667bacf3a9.zip
Fix passing None to afk_channel in Guild.edit.
-rw-r--r--discord/guild.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 31b98abe..215dff84 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -587,7 +587,7 @@ class Guild(Hashable):
feature.
region: :class:`VoiceRegion`
The new region for the guild's voice communication.
- afk_channel: :class:`VoiceChannel`
+ afk_channel: Optional[:class:`VoiceChannel`]
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.
@@ -643,8 +643,16 @@ class Guild(Hashable):
fields['icon'] = icon
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 self.owner != self.me: