From fab3153de68880e775453f9c0cb26ad824a45347 Mon Sep 17 00:00:00 2001 From: Souji Date: Tue, 11 Aug 2020 21:00:29 +0200 Subject: [PATCH] fix: consider #nsfw false if not present in data (#4593) --- src/structures/StoreChannel.js | 16 +++++++++++++--- src/structures/TextChannel.js | 14 ++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/structures/StoreChannel.js b/src/structures/StoreChannel.js index 87cb04064..1c518a7f5 100644 --- a/src/structures/StoreChannel.js +++ b/src/structures/StoreChannel.js @@ -7,15 +7,25 @@ const GuildChannel = require('./GuildChannel'); * @extends {GuildChannel} */ class StoreChannel extends GuildChannel { - _patch(data) { - super._patch(data); + /** + * @param {*} guild The guild the store channel is part of + * @param {*} data The data for the store channel + */ + constructor(guild, data) { + super(guild, data); /** * If the guild considers this channel NSFW * @type {boolean} * @readonly */ - this.nsfw = data.nsfw; + this.nsfw = Boolean(data.nsfw); + } + + _patch(data) { + super._patch(data); + + if (typeof data.nsfw !== 'undefined') this.nsfw = Boolean(data.nsfw); } } diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index 65ec13d06..b92e0c7e6 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -24,6 +24,13 @@ class TextChannel extends GuildChannel { * @type {MessageManager} */ this.messages = new MessageManager(this); + + /** + * If the guild considers this channel NSFW + * @type {boolean} + * @readonly + */ + this.nsfw = Boolean(data.nsfw); this._typing = new Map(); } @@ -36,12 +43,7 @@ class TextChannel extends GuildChannel { */ this.topic = data.topic; - /** - * If the guild considers this channel NSFW - * @type {boolean} - * @readonly - */ - this.nsfw = data.nsfw; + if (typeof data.nsfw !== 'undefined') this.nsfw = Boolean(data.nsfw); /** * The ID of the last message sent in this channel, if one was sent