Skip to content

Commit fc038fa

Browse files
authored
Support new options for editChannelPosition() (#1034)
1 parent cb7178d commit fc038fa

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

index.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,11 @@ declare namespace Eris {
12781278
static from(data: BaseData, client: Client): AnyChannel;
12791279
}
12801280

1281+
export interface EditChannelPositionOptions {
1282+
lockPermissions?: string;
1283+
parentID?: string;
1284+
}
1285+
12811286
export class Client extends EventEmitter {
12821287
application?: { id: string; flags: number };
12831288
bot: boolean;
@@ -1455,7 +1460,7 @@ declare namespace Eris {
14551460
type: string,
14561461
reason?: string
14571462
): Promise<void>;
1458-
editChannelPosition(channelID: string, position: number): Promise<void>;
1463+
editChannelPosition(channelID: string, position: number, options?: EditChannelPositionOptions): Promise<void>;
14591464
editGuild(guildID: string, options: GuildOptions, reason?: string): Promise<Guild>;
14601465
editGuildDiscovery(guildID: string, options?: DiscoveryOptions): Promise<DiscoveryMetadata>;
14611466
editGuildEmoji(
@@ -1917,7 +1922,7 @@ declare namespace Eris {
19171922
type: PermissionType,
19181923
reason?: string
19191924
): Promise<PermissionOverwrite>;
1920-
editPosition(position: number): Promise<void>;
1925+
editPosition(position: number, options?: EditChannelPositionOptions): Promise<void>;
19211926
getInvites(): Promise<Invite[]>;
19221927
permissionsOf(memberID: string | Member): Permission;
19231928
}

lib/Client.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,12 @@ class Client extends EventEmitter {
930930
* Edit a guild channel's position. Note that channel position numbers are lowest on top and highest at the bottom.
931931
* @arg {String} channelID The ID of the channel
932932
* @arg {Number} position The new position of the channel
933+
* @arg {Object} [options] Additional options when editing position
934+
* @arg {Boolean} [options.lockPermissions] Whether to sync the permissions with the new parent if moving to a new category
935+
* @arg {String} [options.parentID] The new parent ID (category channel) for the channel that is moved
933936
* @returns {Promise}
934937
*/
935-
editChannelPosition(channelID, position) {
938+
editChannelPosition(channelID, position, options = {}) {
936939
let channels = this.guilds.get(this.channelGuildMap[channelID]).channels;
937940
const channel = channels.get(channelID);
938941
if(!channel) {
@@ -956,7 +959,9 @@ class Client extends EventEmitter {
956959
}
957960
return this.requestHandler.request("PATCH", Endpoints.GUILD_CHANNELS(this.channelGuildMap[channelID]), true, channels.map((channel, index) => ({
958961
id: channel.id,
959-
position: index + min
962+
position: index + min,
963+
lock_permissions: options.lockPermissions,
964+
parent_id: options.parentID
960965
})));
961966
}
962967

lib/structures/GuildChannel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ class GuildChannel extends Channel {
102102
/**
103103
* Edit the channel's position. Note that channel position numbers are lowest on top and highest at the bottom.
104104
* @arg {Number} position The new position of the channel
105+
* @arg {Object} [options] Additional options when editing position
106+
* @arg {Boolean} [options.lockPermissions] Whether to sync the permissions with the new parent if moving to a new category
107+
* @arg {String} [options.parentID] The new parent ID (category channel) for the channel that is moved
105108
* @returns {Promise}
106109
*/
107-
editPosition(position) {
108-
return this.client.editChannelPosition.call(this.client, this.id, position);
110+
editPosition(position, options) {
111+
return this.client.editChannelPosition.call(this.client, this.id, position, options);
109112
}
110113

111114
/**

0 commit comments

Comments
 (0)