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