mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
make positions for channels and roles nicer (#1211)
* make role calculated position nicer * make channels sortable in a nice way too * stupid git web rebase editor * Update Guild.js * Update Guild.js * Update Guild.js * Update Guild.js * Update RESTMethods.js
This commit is contained in:
@@ -46,6 +46,15 @@ class GuildChannel extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The position of the channel
|
||||
* @type {number}
|
||||
*/
|
||||
get calculatedPosition() {
|
||||
const sorted = this.guild._sortedChannels(this.type);
|
||||
return sorted.array().indexOf(sorted.get(this.id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the overall set of permissions for a user in this channel, taking into account roles and permission
|
||||
* overwrites.
|
||||
@@ -220,6 +229,7 @@ class GuildChannel extends Channel {
|
||||
/**
|
||||
* Set a new position for the guild channel
|
||||
* @param {number} position The new position for the guild channel
|
||||
* @param {boolean} [relative=false] Move the position relative to its current value
|
||||
* @returns {Promise<GuildChannel>}
|
||||
* @example
|
||||
* // set a new channel position
|
||||
@@ -227,8 +237,8 @@ class GuildChannel extends Channel {
|
||||
* .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setPosition(position) {
|
||||
return this.client.rest.methods.updateChannel(this, { position });
|
||||
setPosition(position, relative) {
|
||||
return this.guild.setChannelPosition(this, position, relative).then(() => this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user