From 62b93659e626f04a96f751bc7ebb729ba0c13499 Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Mon, 17 Oct 2016 00:02:48 -0400 Subject: [PATCH] Clean up and simplify some code --- src/structures/EvaluatedPermissions.js | 2 +- src/structures/GuildChannel.js | 8 ++++---- src/structures/GuildMember.js | 2 +- src/structures/Role.js | 2 +- src/structures/interface/TextBasedChannel.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/structures/EvaluatedPermissions.js b/src/structures/EvaluatedPermissions.js index a4462692a..de92c10d7 100644 --- a/src/structures/EvaluatedPermissions.js +++ b/src/structures/EvaluatedPermissions.js @@ -50,7 +50,7 @@ class EvaluatedPermissions { * @returns {boolean} */ hasPermissions(permissions, explicit = false) { - return permissions.map(p => this.hasPermission(p, explicit)).every(v => v); + return permissions.every(p => this.hasPermission(p, explicit)); } /** diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 3eb97a4f6..de1cd2726 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -239,12 +239,12 @@ class GuildChannel extends Channel { this.name === channel.name; if (equal) { - if (channel.permission_overwrites) { - const thisIDSet = Array.from(this.permissionOverwrites.keys()); - const otherIDSet = channel.permission_overwrites.map(overwrite => overwrite.id); + if (this.permissionOverwrites && channel.permissionOverwrites) { + const thisIDSet = this.permissionOverwrites.keyArray(); + const otherIDSet = channel.permissionOverwrites.keyArray(); equal = arraysEqual(thisIDSet, otherIDSet); } else { - equal = false; + equal = !this.permissionOverwrites && !channel.permissionOverwrites; } } diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index c296aaab4..71472c002 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -248,7 +248,7 @@ class GuildMember { */ hasPermissions(permissions, explicit = false) { if (!explicit && this.user.id === this.guild.ownerID) return true; - return permissions.map(p => this.hasPermission(p, explicit)).every(v => v); + return permissions.every(p => this.hasPermission(p, explicit)); } /** diff --git a/src/structures/Role.js b/src/structures/Role.js index 2c884c26c..f2a52ac87 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -150,7 +150,7 @@ class Role { * @returns {boolean} */ hasPermissions(permissions, explicit = false) { - return permissions.map(p => this.hasPermission(p, explicit)).every(v => v); + return permissions.every(p => this.hasPermission(p, explicit)); } /** diff --git a/src/structures/interface/TextBasedChannel.js b/src/structures/interface/TextBasedChannel.js index 406948701..5687828bb 100644 --- a/src/structures/interface/TextBasedChannel.js +++ b/src/structures/interface/TextBasedChannel.js @@ -319,7 +319,7 @@ class TextBasedChannel { if (!(messages instanceof Array || messages instanceof Collection)) { return Promise.reject(new TypeError('Messages must be an Array or Collection.')); } - const messageIDs = messages.map(m => m.id); + const messageIDs = messages instanceof Collection ? messages.keyArray() : messages.map(m => m.id); return this.client.rest.methods.bulkDeleteMessages(this, messageIDs); }