mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 04:52:22 +00:00
Clean up and simplify some code
This commit is contained in:
parent
e04dbbdb82
commit
62b93659e6
5 changed files with 8 additions and 8 deletions
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue