From 799eea957e282519865f8ca80b685842ef15aa68 Mon Sep 17 00:00:00 2001 From: bdistin Date: Thu, 8 Mar 2018 10:15:06 -0600 Subject: [PATCH] consistency: getters return null instead of undefined (#2385) --- src/structures/GroupDMChannel.js | 4 ++-- src/structures/Guild.js | 10 +++++----- src/structures/GuildChannel.js | 2 +- src/structures/GuildMember.js | 2 +- src/structures/User.js | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/structures/GroupDMChannel.js b/src/structures/GroupDMChannel.js index 1919ea575..697d9daec 100644 --- a/src/structures/GroupDMChannel.js +++ b/src/structures/GroupDMChannel.js @@ -103,11 +103,11 @@ class GroupDMChannel extends Channel { /** * The owner of this Group DM - * @type {User} + * @type {?User} * @readonly */ get owner() { - return this.client.users.get(this.ownerID); + return this.client.users.get(this.ownerID) || null; } /** diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 7ac1f88be..f06d1708a 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -301,11 +301,11 @@ class Guild extends Base { /** * The owner of the guild - * @type {GuildMember} + * @type {?GuildMember} * @readonly */ get owner() { - return this.members.get(this.ownerID); + return this.members.get(this.ownerID) || null; } /** @@ -411,11 +411,11 @@ class Guild extends Base { /** * The `@everyone` role of the guild - * @type {Role} + * @type {?Role} * @readonly */ get defaultRole() { - return this.roles.get(this.id); + return this.roles.get(this.id) || null; } /** @@ -424,7 +424,7 @@ class Guild extends Base { * @readonly */ get me() { - return this.members.get(this.client.user.id); + return this.members.get(this.client.user.id) || null; } /** diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index d9bf0d3ae..b694ea822 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -63,7 +63,7 @@ class GuildChannel extends Channel { * @readonly */ get parent() { - return this.guild.channels.get(this.parentID); + return this.guild.channels.get(this.parentID) || null; } /** diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index 03f767e90..ad450c5dd 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -189,7 +189,7 @@ class GuildMember extends Base { * @readonly */ get voiceChannel() { - return this.guild.channels.get(this.voiceChannelID); + return this.guild.channels.get(this.voiceChannelID) || null; } /** diff --git a/src/structures/User.js b/src/structures/User.js index 95b00c208..f765ce3b5 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -186,7 +186,7 @@ class User extends Base { * @readonly */ get dmChannel() { - return this.client.channels.filter(c => c.type === 'dm').find(c => c.recipient.id === this.id); + return this.client.channels.filter(c => c.type === 'dm').find(c => c.recipient.id === this.id) || null; } /**