Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editChannelPositions): add support for endpoint #1328

Merged
merged 18 commits into from
Jun 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,30 @@ class Client extends EventEmitter {
})));
}

/**
* Edit guild channels' positions. Note that channel position numbers are lowest on top and highest at the bottom.
* @arg {String} guildID The ID of the guild
* @arg {Array<Object>} channelPositions An array of [channel positions](https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions)
* @arg {String} channelPositions[].id The ID of the channel
* @arg {Number} channelPositions[].position The new position of the channel
* @arg {Boolean} [channelPositions[].lockPermissions] Whether to sync the permissions with the new parent if moving to a new category
* @arg {String} [channelPositions[].parentID] The new parent ID (category channel) for the channel that is moved (only one channel can change category per request)
xaxim marked this conversation as resolved.
Show resolved Hide resolved
* @returns {Promise}
*/
editChannelPositions(guildID, channelPositions) {
const guild = this.guilds.get(guildID);
if(!guild) {
return Promise.reject(new Error(`Guild ${guildID} not found`));
}
channelPositions.forEach((channelPosition) => {
const channel = guild.channels.get(channelPosition.id);
if(!channel) {
return Promise.reject(new Error(`Channel ${channelPosition.id} not found`));
}
});
return this.requestHandler.request("PATCH", Endpoints.GUILD_CHANNELS(guildID), true, channelPositions);
}

/**
* Edit a global application command
* @arg {String} commandID The command id
Expand Down