feature(CategoryChannel): backport (#2117)

* feature(CategoryChannel): backport


fix


no

* ????

* bad ternary
This commit is contained in:
Isabella
2017-11-19 22:19:46 -06:00
committed by Schuyler Cebulskie
parent b274dba6ec
commit cce2480bb5
7 changed files with 55 additions and 5 deletions

View File

@@ -35,6 +35,12 @@ class GuildChannel extends Channel {
*/
this.position = data.position;
/**
* The ID of the category parent of this channel
* @type {?Snowflake}
*/
this.parentID = data.parent_id;
/**
* A map of permission overwrites in this channel for roles and users
* @type {Collection<Snowflake, PermissionOverwrites>}
@@ -57,6 +63,15 @@ class GuildChannel extends Channel {
return sorted.array().indexOf(sorted.get(this.id));
}
/**
* The category parent of this channel
* @type {?CategoryChannel}
* @readonly
*/
get parent() {
return this.guild.channels.get(this.parentID) || null;
}
/**
* Gets the overall set of permissions for a user in this channel, taking into account roles and permission
* overwrites.
@@ -213,7 +228,7 @@ class GuildChannel extends Channel {
* .catch(console.error);
*/
edit(data, reason) {
return this.client.rest.methods.updateChannel(this, data, reason);
return this.client.rest.methods.updateChannel(this, data, reason).then(() => this);
}
/**
@@ -243,7 +258,18 @@ class GuildChannel extends Channel {
* .catch(console.error);
*/
setPosition(position, relative) {
return this.guild.setChannelPosition(this, position, relative).then(() => this);
return this.guild.setChannelPosition(this, position, relative);
}
/**
* Set a new parent for the guild channel.
* @param {GuildChannel|SnowFlake} parent The new parent for the guild channel
* @param {string} [reason] Reason for changing the guild channel's parent
* @returns {Promise<GuildChannel>}
*/
setParent(parent, reason) {
parent = this.client.resolver.resolveChannelID(parent);
return this.edit({ parent }, reason);
}
/**