From 743668a10d4cd141b2b819a1769a342523840ef3 Mon Sep 17 00:00:00 2001 From: Frangu Vlad Date: Mon, 2 Oct 2017 16:54:18 +0300 Subject: [PATCH] fix: setPosition taking wrong IDs and edit with position 0 breaking (#1989) * Fix typo in setPosition * Same typo in Role * Fix edit with position breaking when the position was 0 * Eslint * Revert code but fix the position issue --- src/structures/GuildChannel.js | 4 ++-- src/structures/Role.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 313aaf383..48cd45a5a 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -280,7 +280,7 @@ class GuildChannel extends Channel { data: { name: (data.name || this.name).trim(), topic: data.topic, - position: data.position || this.rawPosition, + 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, @@ -357,7 +357,7 @@ class GuildChannel extends Channel { this.guild._sortedChannels(this), this.client.api.guilds(this.guild.id).channels, reason) .then(updatedChannels => { this.client.actions.GuildChannelsPositionUpdate.handle({ - guild_id: this.id, + guild_id: this.guild.id, channels: updatedChannels, }); return this; diff --git a/src/structures/Role.js b/src/structures/Role.js index 57985127b..34e8449b7 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -279,7 +279,7 @@ class Role extends Base { this.guild._sortedRoles(), this.client.api.guilds(this.guild.id).roles, reason) .then(updatedRoles => { this.client.actions.GuildRolesPositionUpdate.handle({ - guild_id: this.id, + guild_id: this.guild.id, channels: updatedRoles, }); return this;