Clean up and simplify some code

This commit is contained in:
Schuyler Cebulskie
2016-10-17 00:02:48 -04:00
parent e04dbbdb82
commit 62b93659e6
5 changed files with 8 additions and 8 deletions

View File

@@ -50,7 +50,7 @@ class EvaluatedPermissions {
* @returns {boolean} * @returns {boolean}
*/ */
hasPermissions(permissions, explicit = false) { hasPermissions(permissions, explicit = false) {
return permissions.map(p => this.hasPermission(p, explicit)).every(v => v); return permissions.every(p => this.hasPermission(p, explicit));
} }
/** /**

View File

@@ -239,12 +239,12 @@ class GuildChannel extends Channel {
this.name === channel.name; this.name === channel.name;
if (equal) { if (equal) {
if (channel.permission_overwrites) { if (this.permissionOverwrites && channel.permissionOverwrites) {
const thisIDSet = Array.from(this.permissionOverwrites.keys()); const thisIDSet = this.permissionOverwrites.keyArray();
const otherIDSet = channel.permission_overwrites.map(overwrite => overwrite.id); const otherIDSet = channel.permissionOverwrites.keyArray();
equal = arraysEqual(thisIDSet, otherIDSet); equal = arraysEqual(thisIDSet, otherIDSet);
} else { } else {
equal = false; equal = !this.permissionOverwrites && !channel.permissionOverwrites;
} }
} }

View File

@@ -248,7 +248,7 @@ class GuildMember {
*/ */
hasPermissions(permissions, explicit = false) { hasPermissions(permissions, explicit = false) {
if (!explicit && this.user.id === this.guild.ownerID) return true; 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));
} }
/** /**

View File

@@ -150,7 +150,7 @@ class Role {
* @returns {boolean} * @returns {boolean}
*/ */
hasPermissions(permissions, explicit = false) { hasPermissions(permissions, explicit = false) {
return permissions.map(p => this.hasPermission(p, explicit)).every(v => v); return permissions.every(p => this.hasPermission(p, explicit));
} }
/** /**

View File

@@ -319,7 +319,7 @@ class TextBasedChannel {
if (!(messages instanceof Array || messages instanceof Collection)) { if (!(messages instanceof Array || messages instanceof Collection)) {
return Promise.reject(new TypeError('Messages must be an Array or 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); return this.client.rest.methods.bulkDeleteMessages(this, messageIDs);
} }