Implement 'Modify Guild Channel Positions' (#1198)

* Adding shuffleArray method to utils

* Shuffle channels functionality on guild.

* Comment fix

* Removing shuffle functionality and replacing with a simple update

* Code review changes to method/variable names

* Update comment reference to channelId as well

* Updating jsdoc with typedef of ChannelPosition
This commit is contained in:
lipgloss
2017-02-22 13:24:05 -07:00
committed by Amish Shah
parent 566135d25b
commit f068010e96
4 changed files with 54 additions and 1 deletions

View File

@@ -633,7 +633,27 @@ class Guild {
* .catch(console.error);
*/
createChannel(name, type, overwrites) {
return this.client.rest.methods.createChannel(this, name, type, overwrites);
return this.client.rest.methods.updateChannel(this, name, type, overwrites);
}
/**
* The data needed for updating a channel's position.
* @typedef {Object} ChannelPosition
* @property {string} id The channel being updated's unique id.
* @property {number} position The new position of the channel.
*/
/**
* Updates this guild's channel positions as a batch.
* @param {Array<ChannelPosition>} channelPositions Array of objects that defines which channel is going where.
* @returns {Promise<Guild>}
* @example
* guild.updateChannels([{ id: channelID, position: newChannelIndex }])
* .then(guild => console.log(`Updated channels for ${guild.id}`))
* .catch(console.error);
*/
updateChannelPositions(channelPositions) {
return this.client.rest.methods.updateChannelPositions(this.id, channelPositions);
}
/**