From 9124ca78d2a330b41272615526c320c111ad11a7 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Tue, 13 Apr 2021 13:49:27 +0200 Subject: [PATCH 1/2] feat(Guild): nsfw guilds --- src/structures/Guild.js | 8 ++++++++ typings/index.d.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index d2690101a677..181f1a055992 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -101,6 +101,14 @@ class Guild extends Base { * @type {number} */ this.shardID = data.shardID; + + if ('nsfw' in data || typeof this.nsfw !== 'boolean') { + /** + * Whether the guild is designated as not safe for work + * @type {boolean} + */ + this.nsfw = Boolean(data.nsfw); + } } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index ea41f7e95631..a4e1ef483c07 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -624,6 +624,7 @@ declare module 'discord.js' { public mfaLevel: number; public name: string; public readonly nameAcronym: string; + public nsfw: boolean; public readonly owner: GuildMember | null; public ownerID: Snowflake; public readonly partnered: boolean; From dff4110758affd5849c3df135c4ff1036404b235 Mon Sep 17 00:00:00 2001 From: Souji Date: Sun, 18 Apr 2021 12:32:48 +0200 Subject: [PATCH 2/2] refactor: nsfw data is documented as required, simplify handling Co-authored-by: Advaith --- src/structures/Guild.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 4c5eee802027..6672a8b187b9 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -102,12 +102,12 @@ class Guild extends Base { */ this.shardID = data.shardID; - if ('nsfw' in data || typeof this.nsfw !== 'boolean') { + if ('nsfw' in data) { /** * Whether the guild is designated as not safe for work * @type {boolean} */ - this.nsfw = Boolean(data.nsfw); + this.nsfw = data.nsfw; } }