Skip to content

Commit

Permalink
consistency: getters return null instead of undefined (#2385)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdistin authored and Lewdcario committed Mar 8, 2018
1 parent a68f145 commit 799eea9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/structures/GroupDMChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/structures/GuildChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/structures/GuildMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/structures/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 799eea9

Please sign in to comment.