From 4df2adc801b6a17acbd7146a824247b4c452c8ab Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Fri, 1 Sep 2017 16:14:20 +0200 Subject: [PATCH] Backporting #1863, allowing the afk and systemchannel to be set to null (#1865) * fix(Guild): Allow the afk and system channel to be set to null. * make the getter return null --- src/structures/Guild.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 600e93aa..fac0141b 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -304,7 +304,7 @@ class Guild { * @readonly */ get afkChannel() { - return this.client.channels.get(this.afkChannelID); + return this.client.channels.get(this.afkChannelID) || null; } /** @@ -313,7 +313,7 @@ class Guild { * @readonly */ get systemChannel() { - return this.client.channels.get(this.systemChannelID); + return this.client.channels.get(this.systemChannelID) || null; } /** @@ -611,8 +611,12 @@ class Guild { if (data.name) _data.name = data.name; if (data.region) _data.region = data.region; if (typeof data.verificationLevel !== 'undefined') _data.verification_level = Number(data.verificationLevel); - if (data.afkChannel) _data.afk_channel_id = this.client.resolver.resolveChannel(data.afkChannel).id; - if (data.systemChannel) _data.system_channel_id = this.client.resolver.resolveChannel(data.systemChannel).id; + if (typeof data.afkChannel !== 'undefined') { + _data.afk_channel_id = this.client.resolver.resolveChannelID(data.afkChannel); + } + if (typeof data.systemChannel !== 'undefined') { + _data.system_channel_id = this.client.resolver.resolveChannelID(data.systemChannel); + } if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout); if (typeof data.icon !== 'undefined') _data.icon = data.icon; if (data.owner) _data.owner_id = this.client.resolver.resolveUser(data.owner).id;