mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Clean up and simplify some code
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user