mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
fix(GuildChannel|Role.edit) Editing with a position not being right (#2010)
* Fix GuildChannel.edit and Role.edit for positions * Re-use Util.setPosition And also make it even more compact! And it works! \o/
This commit is contained in:
@@ -275,12 +275,21 @@ class GuildChannel extends Channel {
|
||||
* .then(c => console.log(`Edited channel ${c}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(data, reason) {
|
||||
async edit(data, reason) {
|
||||
if (typeof data.position !== 'undefined') {
|
||||
await Util.setPosition(this, data.position, false,
|
||||
this.guild._sortedChannels(this), this.client.api.guilds(this.guild.id).channels, reason)
|
||||
.then(updatedChannels => {
|
||||
this.client.actions.GuildChannelsPositionUpdate.handle({
|
||||
guild_id: this.guild.id,
|
||||
channels: updatedChannels,
|
||||
});
|
||||
});
|
||||
}
|
||||
return this.client.api.channels(this.id).patch({
|
||||
data: {
|
||||
name: (data.name || this.name).trim(),
|
||||
topic: data.topic,
|
||||
position: typeof data.position === 'number' ? data.position : this.rawPosition,
|
||||
bitrate: data.bitrate || (this.bitrate ? this.bitrate * 1000 : undefined),
|
||||
user_limit: data.userLimit != null ? data.userLimit : this.userLimit, // eslint-disable-line eqeqeq
|
||||
parent_id: data.parentID,
|
||||
|
||||
Reference in New Issue
Block a user