From b35588d7cbd31ce127603d857e1e7a6b19cd8936 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Thu, 8 Apr 2021 23:36:29 +0200 Subject: [PATCH 1/4] feat(Guild): new options in setChannelpos Signed-off-by: almostSouji --- src/structures/Guild.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index d2690101a677..b387a21ce6c4 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -1255,11 +1255,14 @@ class Guild extends Base { * The data needed for updating a channel's position. * @typedef {Object} ChannelPosition * @property {ChannelResolvable} channel Channel to update - * @property {number} position New position for the channel + * @property {number} [position] New position for the channel + * @property {ChannelResolvable} [parent] Parent channel for this channel + * @property {boolean} [lockPermissions] If the overwrites should be locked to the parents overwrites */ /** * Batch-updates the guild's channels' positions. + * Only one channel's parent can be changed at a time * @param {ChannelPosition[]} channelPositions Channel positions to update * @returns {Promise} * @example @@ -1271,6 +1274,8 @@ class Guild extends Base { const updatedChannels = channelPositions.map(r => ({ id: this.client.channels.resolveID(r.channel), position: r.position, + lock_permissions: r.lockPermissions, + parent_id: this.channels.resolveID(r.parent), })); return this.client.api From b2de544ce15803bb5b956ed823fd1750019bb335 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Thu, 8 Apr 2021 23:36:45 +0200 Subject: [PATCH 2/4] feat: typings --- typings/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index ea41f7e95631..02f8c90923a8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -194,6 +194,8 @@ declare module 'discord.js' { public type: 'category'; } + type CategoryChannelResolvable = Snowflake | CategoryChannel; + export class Channel extends Base { constructor(client: Client, data?: object); public readonly createdAt: Date; @@ -2422,7 +2424,9 @@ declare module 'discord.js' { interface ChannelPosition { channel: ChannelResolvable; - position: number; + position?: number; + parent?: ChannelResolvable; + lockPermissions?: boolean; } type ChannelResolvable = Channel | Snowflake; From 0423ee9469e039cacf822874d784514e375b3128 Mon Sep 17 00:00:00 2001 From: Souji Date: Fri, 9 Apr 2021 10:55:45 +0200 Subject: [PATCH 3/4] chore: alphabetical sorting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antonio Román --- typings/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 02f8c90923a8..cb30723ac050 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2424,9 +2424,9 @@ declare module 'discord.js' { interface ChannelPosition { channel: ChannelResolvable; - position?: number; - parent?: ChannelResolvable; lockPermissions?: boolean; + parent?: ChannelResolvable; + position?: number; } type ChannelResolvable = Channel | Snowflake; From c732669d49713efa707fe5df9731028f40ffbc2e Mon Sep 17 00:00:00 2001 From: almostSouji Date: Mon, 12 Apr 2021 10:29:25 +0200 Subject: [PATCH 4/4] fix: use and document CategoryChannelResolvable --- src/structures/Guild.js | 9 ++++++++- typings/index.d.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index b387a21ce6c4..b20f63ce698a 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -1251,12 +1251,19 @@ class Guild extends Base { return this.edit({ preferredLocale }, reason); } + /** + * Data that can be resolved to give a Category Channel object. This can be: + * * A CategoryChannel object + * * A Snowflake + * @typedef {CategoryChannel|Snowflake} CategoryChannelResolvable + */ + /** * The data needed for updating a channel's position. * @typedef {Object} ChannelPosition * @property {ChannelResolvable} channel Channel to update * @property {number} [position] New position for the channel - * @property {ChannelResolvable} [parent] Parent channel for this channel + * @property {CategoryChannelResolvable} [parent] Parent channel for this channel * @property {boolean} [lockPermissions] If the overwrites should be locked to the parents overwrites */ diff --git a/typings/index.d.ts b/typings/index.d.ts index cb30723ac050..47e04c4286a0 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2425,7 +2425,7 @@ declare module 'discord.js' { interface ChannelPosition { channel: ChannelResolvable; lockPermissions?: boolean; - parent?: ChannelResolvable; + parent?: CategoryChannelResolvable; position?: number; }