Merge branch 'indev' of https://github.com/hydrabolt/discord.js into indev

This commit is contained in:
Amish Shah
2016-10-23 20:51:07 +01:00
2 changed files with 15 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@@ -121,6 +121,7 @@ class TextBasedChannel {
/** /**
* Gets a single message from this channel, regardless of it being cached or not. * Gets a single message from this channel, regardless of it being cached or not.
* <warn>Only OAuth bot accounts can use this method.</warn>
* @param {string} messageID The ID of the message to get * @param {string} messageID The ID of the message to get
* @returns {Promise<Message>} * @returns {Promise<Message>}
* @example * @example
@@ -310,17 +311,22 @@ class TextBasedChannel {
} }
/** /**
* Bulk delete a given Collection or Array of messages in one go. Returns the deleted messages after. * Bulk delete given messages.
* Only OAuth Bot accounts may use this method. * Only OAuth Bot accounts may use this method.
* @param {Collection<string, Message>|Message[]} messages The messages to delete * @param {Collection<string, Message>|Message[]|number} messages Messages to delete, or number of messages to delete
* @returns {Collection<string, Message>} * @returns {Promise<Collection<string, Message>>} Deleted messages
*/ */
bulkDelete(messages) { bulkDelete(messages) {
if (!(messages instanceof Array || messages instanceof Collection)) { return new Promise((resolve, reject) => {
return Promise.reject(new TypeError('Messages must be an Array or Collection.')); if (!isNaN(messages)) {
} this.fetchMessages({ limit: messages }).then(msgs => resolve(this.bulkDelete(msgs)));
const messageIDs = messages instanceof Collection ? messages.keyArray() : messages.map(m => m.id); } else if (messages instanceof Array || messages instanceof Collection) {
return this.client.rest.methods.bulkDeleteMessages(this, messageIDs); const messageIDs = messages instanceof Collection ? messages.keyArray() : messages.map(m => m.id);
resolve(this.client.rest.methods.bulkDeleteMessages(this, messageIDs));
} else {
reject(new TypeError('Messages must be an Array, Collection, or number.'));
}
});
} }
_cacheMessage(message) { _cacheMessage(message) {