Remove unnecessary array conversions

This commit is contained in:
Schuyler Cebulskie
2016-10-16 21:14:59 -04:00
parent 13aae621b8
commit fc307fab8a
6 changed files with 11 additions and 10 deletions

View File

@@ -95,7 +95,7 @@ class Emoji {
* @returns {string}
* @example
* // send an emoji:
* const emoji = guild.emojis.array()[0];
* const emoji = guild.emojis.first();
* msg.reply(`Hello! ${emoji}`);
*/
toString() {

View File

@@ -101,8 +101,8 @@ class GroupDMChannel extends Channel {
this.ownerID === channel.ownerID;
if (equal) {
const thisIDs = this.recipients.array().map(r => r.id);
const otherIDs = channel.recipients.map(r => r.id);
const thisIDs = this.recipients.keyArray();
const otherIDs = channel.recipients.keyArray();
return arraysEqual(thisIDs, otherIDs);
}

View File

@@ -316,8 +316,9 @@ class TextBasedChannel {
* @returns {Collection<string, Message>}
*/
bulkDelete(messages) {
if (messages instanceof Collection) messages = messages.array();
if (!(messages instanceof Array)) return Promise.reject(new TypeError('Messages must be an Array or Collection.'));
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);
return this.client.rest.methods.bulkDeleteMessages(this, messageIDs);
}