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(Guild): setChannelPositions parent, lockPermissions keys #5507

Merged
merged 4 commits into from Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/structures/Guild.js
Expand Up @@ -1251,15 +1251,25 @@ 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 {number} [position] New position for the channel
* @property {CategoryChannelResolvable} [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.
* <info>Only one channel's parent can be changed at a time</info>
* @param {ChannelPosition[]} channelPositions Channel positions to update
* @returns {Promise<Guild>}
* @example
Expand All @@ -1271,6 +1281,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
Expand Down
6 changes: 5 additions & 1 deletion typings/index.d.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -2422,7 +2424,9 @@ declare module 'discord.js' {

interface ChannelPosition {
channel: ChannelResolvable;
position: number;
lockPermissions?: boolean;
parent?: CategoryChannelResolvable;
position?: number;
}

type ChannelResolvable = Channel | Snowflake;
Expand Down